Skip to content

Commit

Permalink
ci: add container gh packaging (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo authored May 3, 2023
1 parent a791b44 commit 0dd3ce8
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
78 changes: 78 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -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 }}
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions Manifest.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include *.txt
include *.yml
include tox.ini
graft tests
global-exclude *.py[cod]
4 changes: 4 additions & 0 deletions docker/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
kind: unset
dry_run: true
configs: {}
10 changes: 10 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cloudscale-sdk
cs
hcloud
proxmoxer<2.0
python-digitalocean
python-dotenv
python-json-logger
pyyaml
requests
schedule
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0dd3ce8

Please sign in to comment.