From 0dd3ce863fd723f557e93deca2d9cdcc879416fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Wed, 3 May 2023 09:22:59 +0200 Subject: [PATCH] ci: add container gh packaging (#28) --- .github/dependabot.yml | 4 ++ .github/workflows/container.yml | 78 +++++++++++++++++++++++++++++++++ Dockerfile | 15 +++++++ Makefile | 21 +++++++++ Manifest.in | 5 +++ docker/config.yaml | 4 ++ requirements.in | 10 +++++ requirements.txt | 9 ++++ tox.ini | 30 +++++++++++++ 9 files changed, 176 insertions(+) create mode 100644 .github/workflows/container.yml create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 Manifest.in create mode 100644 docker/config.yaml create mode 100644 requirements.in diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 62be547..9aa4699 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,3 +11,7 @@ updates: directory: "/" schedule: interval: "weekly" + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 0000000..9f4806e --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,78 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. +--- +name: Create and publish a Container image + +on: + push: + branches: + - "master" + tags: + - "v*" +env: + REGISTRY: ghcr.io + IMAGE_NAME: ngine-io/chaotic + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U setuptools wheel + + - name: Build + run: | + python setup.py sdist bdist_wheel + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Build and push Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + push: true + pull: true + platforms: linux/arm64,linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..56f3808 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM docker.io/python:3.11.3-slim + +WORKDIR /build +COPY . . + +RUN pip install . + +WORKDIR /app + +RUN rm -rf /build +COPY ./docker/config.yaml . + +USER 1000 + +ENTRYPOINT ["chaotic-ngine"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..68ff600 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +clean: + rm -rf *.egg-info + rm -rf *.dist-info + rm -rf dist + rm -rf build + find -name '__pycache__' -exec rm -fr {} || true \; + +build: clean + python3 setup.py sdist bdist_wheel + +test-release: + twine upload --repository testpypi dist/* + +release: + twine upload dist/* + +test: + tox + +update: + pip-compile -U --no-header --no-annotate --strip-extras --resolver backtracking diff --git a/Manifest.in b/Manifest.in new file mode 100644 index 0000000..b4c5700 --- /dev/null +++ b/Manifest.in @@ -0,0 +1,5 @@ +include *.txt +include *.yml +include tox.ini +graft tests +global-exclude *.py[cod] diff --git a/docker/config.yaml b/docker/config.yaml new file mode 100644 index 0000000..c509612 --- /dev/null +++ b/docker/config.yaml @@ -0,0 +1,4 @@ +--- +kind: unset +dry_run: true +configs: {} diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..29418cc --- /dev/null +++ b/requirements.in @@ -0,0 +1,10 @@ +cloudscale-sdk +cs +hcloud +proxmoxer<2.0 +python-digitalocean +python-dotenv +python-json-logger +pyyaml +requests +schedule diff --git a/requirements.txt b/requirements.txt index 14f8d5a..4f21e24 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,19 @@ +certifi==2022.12.7 +charset-normalizer==3.1.0 cloudscale-sdk==0.7.0 cs==3.0.0 hcloud==1.19.0 +idna==3.4 +jsonpickle==3.0.1 proxmoxer==1.3.1 +python-dateutil==2.8.2 python-digitalocean==1.17.0 python-dotenv==1.0.0 python-json-logger==2.0.7 +pytz==2023.3 pyyaml==6.0 requests==2.29.0 schedule==1.2.0 +six==1.16.0 +urllib3==1.26.15 +xdg==6.0.0 diff --git a/tox.ini b/tox.ini index e69de29..a589d89 100644 --- a/tox.ini +++ b/tox.ini @@ -0,0 +1,30 @@ +[tox] +envlist = py{310,311} +skip_missing_interpreters = True +skipsdist = True + +[gh-actions] +python = + 3.10: py310 + 3.11: py311 + +[testenv] +changedir = tests +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/requirements.dev.txt +commands = + python --version + pytest -v --cov --cov-append --cov-report=xml + +[testenv:report] +deps = coverage +skip_install = true +commands = + coverage report + coverage html + +[testenv:clean] +deps = coverage +skip_install = true +commands = coverage erase