From 7b8cea504d75d5dd0e0d0fb1500fc2292e97c1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Pfl=C3=BCgner?= Date: Thu, 12 Mar 2026 08:32:54 +0100 Subject: [PATCH] add release gh action pull-ci --- .github/workflows/pull-ci.yml | 92 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 59 ++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 .github/workflows/pull-ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pull-ci.yml b/.github/workflows/pull-ci.yml new file mode 100644 index 0000000..9b7b61c --- /dev/null +++ b/.github/workflows/pull-ci.yml @@ -0,0 +1,92 @@ +name: Pull CI + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + tests: + name: Run lint and tests + runs-on: ubuntu-latest + permissions: + contents: read + services: # database setup for integration and e2e tests + postgres: + image: docker.io/postgres:15 + env: + POSTGRES_DB: test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: secret + ports: + - 5432:5432 + options: >- + --health-cmd="pg_isready -U postgres" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v6 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt -r requirements-dev.txt + + - name: Ruff lint + run: ruff check + + - name: Ruff format check + run: ruff format --check + + - name: Mypy type tests + run: mypy --ignore-missing-imports --explicit-package-bases . + + - name: Run unit tests + run: | + cd tests/unit; PYTHONPATH=../..: pytest --cov=lufa -v + + - name: Run integration tests + run: | + cd tests/integration; PYTHONPATH=../..: pytest --cov=lufa -v + env: + POSTGRES_HOST: localhost + POSTGRES_DB: test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: secret + + - name: Run e2e tests + run: | + cd tests/e2e; PYTHONPATH=../..: pytest --cov=lufa -v + env: + POSTGRES_HOST: localhost + POSTGRES_DB: test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: secret + + docker_dry_run: + name: Docker build (dry run) + runs-on: ubuntu-latest + permissions: + contents: read + packages: read + steps: + - uses: actions/checkout@v4 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Build without push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..76d3c96 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: Release +on: + push: + branches: + - master # for nightly releases + tags: + - "*" + +jobs: + docker_build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-tags: true + fetch-depth: 0 + + - name: Get image tag + id: tag + run: | + if [[ "${GITHUB_REF}" == refs/heads/master ]]; then + echo "tag=nightly" >> $GITHUB_OUTPUT + else + echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + fi + + - name: Get project version + id: project_version + run: | + if [[ "${GITHUB_REF}" == refs/heads/master ]]; then + TAG=$(git describe --tags --abbrev=0) + BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's/\//-/g') + COMMIT=$(git rev-parse --short=8 HEAD) + VERSION="${TAG}-git.${BRANCH}.${COMMIT}" + echo "version=$VERSION" >> $GITHUB_OUTPUT + else + echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + fi + + - name: Set version in pyproject.toml + run: sed -i '/^\[project\]/,/^\[/s/version = "unknown-version"/version = "${{ steps.project_version.outputs.version }}"/' pyproject.toml + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ghcr.io/${{ github.repository }}:{{ steps.tag.outputs.tag }} + cache-from: type=gha + cache-to: type=gha,mode=max