Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7a7efc4
Merge setup.py into pyproject.toml
exhuma Aug 14, 2023
72a22b8
Remove pipenv & Pipfile
exhuma Aug 14, 2023
0444fe8
Remove obsolete docker-compose file
exhuma Aug 14, 2023
8100b34
Add requirements.txt
exhuma Aug 14, 2023
526c064
Remove Pipfile from Dockerfile
exhuma Aug 14, 2023
c835bce
Add workflow to build docker image
exhuma Aug 14, 2023
90d6f8b
Update to actions/checkout v3
exhuma Aug 14, 2023
414ad5a
Add example required unit-test job
exhuma Aug 14, 2023
b6240fe
Remove travis CI in favor of GitHub actions
exhuma Aug 14, 2023
d5023dc
Install package for testing
exhuma Aug 14, 2023
bf7970d
Use real dependencies in the CI runs
exhuma Aug 14, 2023
275b87f
Upgrade to actions/checkout v3
exhuma Aug 14, 2023
23f3957
Upgrade to actions/setup-python v4
exhuma Aug 14, 2023
5d7cd43
Remove the job-timeout
exhuma Aug 14, 2023
44f1b66
Switch to MIT License
exhuma Aug 15, 2023
59b558e
Remove requirements.txt & use multi-stage build
exhuma Aug 15, 2023
a2bdcd3
Update README
exhuma Aug 15, 2023
c102374
Switch to docker-login action
exhuma Aug 15, 2023
61999b9
Merge CI-workflows
exhuma Aug 15, 2023
e30c5ec
Exclude some steps from pull-requests
exhuma Aug 15, 2023
24d7294
Always build docker image to detect errors
exhuma Aug 15, 2023
95032d6
Update docker-image references & provide "latest"
exhuma Aug 15, 2023
06ed149
Fix repository URL in pyproject.toml
exhuma Aug 16, 2023
4e6d656
Update project classifiers
exhuma Aug 16, 2023
0e5435f
Use OIDC for pypi publishing
exhuma Aug 16, 2023
8c3844d
Reconstitute MIT License alongside ISCL
exhuma Aug 16, 2023
e11e2be
Reconstitute tox
exhuma Aug 16, 2023
a9af10f
Remove unused dependencies
exhuma Aug 16, 2023
8b9bf33
Drop unused envs from tox
exhuma Aug 16, 2023
354f147
Better referencing for dual-license
exhuma Aug 17, 2023
3cb9f38
Add missing files to manifest
exhuma Aug 17, 2023
3e528ee
Build docker image from a requirements.txt file
exhuma Aug 17, 2023
15be581
Fix minor typos
exhuma Aug 18, 2023
719ba4d
Fix CI jobs for Windows
exhuma Aug 18, 2023
286cb6d
Use a venv for tomlq
exhuma Aug 18, 2023
82e8556
Fix issue with pip (see pypa/pip#9644)
exhuma Aug 18, 2023
4759eb1
Add missing dependency
exhuma Aug 18, 2023
4923332
Run as non-privileged user
exhuma Aug 18, 2023
715d6f7
Fix greenlet issue for Python 3.12
exhuma Aug 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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