Skip to content

[pre-commit.ci] pre-commit autoupdate (#133) #462

[pre-commit.ci] pre-commit autoupdate (#133)

[pre-commit.ci] pre-commit autoupdate (#133) #462

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint-test:
name: Lint & test
runs-on: ubuntu-latest
strategy:
matrix:
directory: ["api", "bot"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: "${{ matrix.directory }}/pyproject.toml"
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.12"
- name: Install dependencies
working-directory: ${{ matrix.directory }}
run: pdm sync
- name: Run lints
working-directory: ${{ matrix.directory }}
run: pdm lint
- name: Run tests with coverage
working-directory: ${{ matrix.directory }}
run: pdm test-cov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./${{ matrix.directory }}/coverage.xml
build:
name: Build
needs: lint-test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
strategy:
matrix:
directory: ["api", "bot"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./${{ matrix.directory }}
file: ./${{ matrix.directory }}/Dockerfile
push: true
cache-from: type=registry,ref=ghcr.io/xithrius/xythrion/${{ matrix.directory }}:latest
cache-to: type=inline
tags: |
ghcr.io/xithrius/xythrion/${{ matrix.directory }}:${{ github.sha }}
ghcr.io/xithrius/xythrion/${{ matrix.directory }}:latest
build-args: |
git_sha=${{ github.sha }}