Skip to content

Commit

Permalink
Merge pull request psf#17 from exhuma/housekeeping
Browse files Browse the repository at this point in the history
Housekeeping
  • Loading branch information
kevin1024 authored Aug 19, 2023
2 parents e7d491f + 715d6f7 commit 1abaf29
Show file tree
Hide file tree
Showing 19 changed files with 297 additions and 854 deletions.
103 changes: 93 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ name: Run CI
on: [push, pull_request]

permissions:
contents: read
contents: write
packages: write

jobs:
build:
unit-tests:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev", "pypy-3.8", "pypy-3.9", "pypy-3.10"]
os: [ubuntu-22.04, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# from https://github.com/actions/cache/blob/main/examples.md#python---pip
Expand All @@ -36,10 +36,93 @@ jobs:
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-
- name: Install dependencies
- name: Set up environment & install dependencies
run: |
python -m pip install .
python -m pip install -r test-requirements.txt
python -m pip install pip-tools
pip-compile --quiet --generate-hashes --extra mainapp > requirements.txt
python -m pip install --requirement requirements.txt
python -m pip install .[test]
- name: Run tests
run: |
python -m pytest tests
run: tox
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/release-') && github.event_name == 'push'
uses: softprops/action-gh-release@v1
with:
files: |
requirements.txt
Dockerfile
- name: Store tested requirements.txt file as artifact
uses: actions/upload-artifact@v3
with:
name: requirements.txt
path: |
requirements.txt
publish-docker-image:
runs-on: ubuntu-latest
needs: [unit-tests]
steps:
- name: System Dependencies for Packaging
run: |
sudo apt-get update
sudo apt-get install -y python3-pip python3-venv
python3 -m venv /tmp/tomlq
/tmp/tomlq/bin/pip install --upgrade pip
/tmp/tomlq/bin/pip install yq
- name: Checkout
uses: actions/checkout@v3
- name: Set Environment
run: |
echo "APP_VERSION=$(/tmp/tomlq/bin/tomlq -r .project.version pyproject.toml)" >> $GITHUB_ENV
echo "APP_DESC=$(/tmp/tomlq/bin/tomlq -r .project.description pyproject.toml)" >> $GITHUB_ENV
- name: Retrieve tested requirements file
uses: actions/download-artifact@v3
with:
name: requirements.txt
- name: Build Image
run: >
docker build
--build-arg "APP_VERSION=${APP_VERSION}"
--build-arg "APP_DESC=${APP_DESC}"
-t "ghcr.io/${GITHUB_REPOSITORY}:${APP_VERSION}"
-t "ghcr.io/${GITHUB_REPOSITORY}:latest"
.
# - name: Login to Docker Hub
# if: github.event_name == 'push'
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GHCR
if: startsWith(github.ref, 'refs/tags/release-') && github.event_name == 'push'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Docker Image
if: startsWith(github.ref, 'refs/tags/release-') && github.event_name == 'push'
run: |
docker push "ghcr.io/${GITHUB_REPOSITORY}:${APP_VERSION}"
pypi-publish:
needs: [unit-tests]
if: startsWith(github.ref, 'refs/tags/release-') && github.event_name == 'push'
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/httpbin
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Build distribution
run: |
python -m pip install --upgrade pip build
pyproject-build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ dist/
.eggs/
.workon
.epio-app
*.pyc
.tox
*.pyc
*.egg-info
*.swp
.vscode/
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

53 changes: 39 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
FROM python:3.10-slim

LABEL name="httpbin"
LABEL version="0.9.2"
LABEL description="A simple HTTP service."
LABEL org.kennethreitz.vendor="Kenneth Reitz"
FROM python:3.10-slim AS build

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update -y && apt install python3-pip git -y && pip3 install --no-cache-dir pipenv
RUN apt-get -y update
RUN apt-get install -y \
python3-pip \
python3-venv

ADD Pipfile Pipfile.lock /httpbin/
WORKDIR /httpbin
RUN /bin/bash -c "pip3 install --no-cache-dir -r <(pipenv requirements)"
RUN python3 -m venv /opt/httpbin
RUN /opt/httpbin/bin/pip install -U pip

ADD requirements.txt /requirements.txt
RUN /opt/httpbin/bin/pip install --no-deps --requirement /requirements.txt

ADD . /httpbin
RUN pip3 install --no-cache-dir /httpbin
RUN chmod +x /httpbin/httpbin.bash
RUN /opt/httpbin/bin/pip install --no-deps /httpbin


# ----------------------------------------------------------------------------

FROM python:3.10-slim AS prod

ARG APP_VERSION
LABEL name="httpbin"
LABEL version=${APP_VERSION}
LABEL description="A simple HTTP service."
LABEL org.kennethreitz.vendor="Kenneth Reitz"

RUN useradd \
--system \
--shell /bin/nologin \
--no-create-home \
--home /opt/httpbin \
httpbin

COPY --from=build /opt/httpbin /opt/httpbin
WORKDIR /opt/httpbin

EXPOSE 80
ADD httpbin.bash /opt/httpbin/bin
RUN chmod +x /opt/httpbin/bin/httpbin.bash
RUN chown --recursive httpbin /opt/httpbin
EXPOSE 8080
CMD ["/opt/httpbin/bin/httpbin.bash"]

CMD ["/httpbin/httpbin.bash"]
USER httpbin
18 changes: 3 additions & 15 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
ISC License

Copyright (c) 2017 Kenneth Reitz.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
This software is made available under the terms of *either* of the licenses
found in LICENSE.ISC or LICENSE.MIT. Contributions to httpbin are made
under the terms of *both* these licenses.
15 changes: 15 additions & 0 deletions LICENSE.ISC
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2017 Kenneth Reitz.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 changes: 21 additions & 0 deletions LICENSE.MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright 2017 Kenneth Reitz

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include httpbin/VERSION README.md LICENSE AUTHORS test_httpbin.py
include README.md LICENSE.ISC LICENSE.MIT AUTHORS test_httpbin.py
recursive-include httpbin/templates *
recursive-include httpbin/static *
19 changes: 0 additions & 19 deletions Pipfile

This file was deleted.

Loading

0 comments on commit 1abaf29

Please sign in to comment.