[pre-commit.ci] pre-commit autoupdate #467
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |