Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
92 changes: 92 additions & 0 deletions .github/workflows/pull-ci.yml
Original file line number Diff line number Diff line change
@@ -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
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
Loading