Skip to content

Commit

Permalink
github: update CI and dependabot; add Docker and PyPi release actions
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Scherf <[email protected]>
  • Loading branch information
fscherf committed Jul 20, 2024
1 parent 8ea2807 commit 6f4ca32
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 33 deletions.
7 changes: 0 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ updates:
time: "02:00"
open-pull-requests-limit: 10

- package-ecosystem: npm
directory: "."
schedule:
interval: daily
time: "02:00"
open-pull-requests-limit: 10

- package-ecosystem: docker
directory: "/"
schedule:
Expand Down
48 changes: 22 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: ci

name: CI

on:
push:
Expand All @@ -8,41 +7,38 @@ on:
pull_request:
workflow_dispatch:


jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ["py38", "py39", "py310", "py311", "py312"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get install -y
pip install --upgrade setuptools tox
pip install .[test]
python -m playwright install-deps
python -m playwright install
- name: Run Tox
env:
MILAN_CI_TEST: 1
run: tox -e py
- name: Build Docker image
run: docker build -t app .

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
- name: Run pytest inside Docker container
run: |
docker run \
-v ./:/app \
-w /app \
-u root \
-e MILAN_CI_TEST=1 \
app:latest \
tox -e ${{ matrix.python-version }}
- name: Upload artifacts to GitHub
uses: actions/upload-artifact@v4
with:
name: python-${{ matrix.python-version }}-artifacts
name: ${{ matrix.python-version }}-artifacts
path: artifacts

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Docker: release"

on:
push:
tags:
- "v*"

env:
USERNAME: fscherf
IMAGE_NAME: fscherf/milan

jobs:
docker-release:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tags: type=match,pattern=v(.*),group=1

- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != "pull_request" }}
tags: ${{ steps.meta.outputs.tags }},${{ env.IMAGE_NAME }}:latest
45 changes: 45 additions & 0 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "PyPi: Release"

on:
push:
tags:
- "v*"

env:
PROJECT_NAME: milan

jobs:
pypi-release:
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/${{ env.PROJECT_NAME }}

permissions:
id-token: write

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install pypa/build
run: python3 -m pip install build --user

- name: Build a binary wheel and a source tarball
run: python3 -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}

0 comments on commit 6f4ca32

Please sign in to comment.