Overhaul CI Design

This commit is contained in:
Arbion Halili
2025-06-28 12:29:01 +01:00
parent f7f779da19
commit e4c4b3e95a
10 changed files with 143 additions and 136 deletions

View File

@@ -0,0 +1,16 @@
name: Commit if changed
description: "Create a commit when the working tree is dirty"
inputs:
message:
description: "Commit message"
required: true
runs:
using: composite
steps:
- name: Commit changed files
shell: bash
run: |
git diff --quiet && exit 0
git commit -am "${{ inputs.message }}"

10
.github/actions/format/action.yml vendored Normal file
View File

@@ -0,0 +1,10 @@
name: Format Code
description: "Run code formatter"
runs:
using: "composite"
steps:
- name: Format code
run: uv run poe fmt
shell: bash

10
.github/actions/lint/action.yml vendored Normal file
View File

@@ -0,0 +1,10 @@
name: Lint Code
description: "Run code linter"
runs:
using: "composite"
steps:
- name: Lint code
run: uv run poe lint
shell: bash

View File

@@ -0,0 +1,10 @@
name: Regenerate Protobufs
description: "Regenerate protobuf files"
runs:
using: "composite"
steps:
- name: Regenerate protobufs
run: nix develop -c just regenerate-protobufs
shell: bash

View File

@@ -0,0 +1,20 @@
name: Setup Python & uv
description: "Regenerate Python environment from uv.lock"
runs:
using: "composite"
steps:
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install Python
run: uv python install
shell: bash
- name: Sync
run: uv sync --locked --all-extras --dev
shell: bash

10
.github/actions/typecheck/action.yml vendored Normal file
View File

@@ -0,0 +1,10 @@
name: Type Check
description: "Run static type checker"
runs:
using: "composite"
steps:
- name: Run type checker
run: uv run poe check
shell: bash

View File

@@ -1,49 +0,0 @@
name: format
on:
push:
branches:
- staging
- main
pull_request:
branches:
- staging
- main
jobs:
format:
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install Python
run: uv python install
- name: Sync dependencies
run: uv sync --locked --all-extras --dev
- name: Format code
run: uv run poe fmt
- name: Push formatted code
run: |
git diff --quiet && exit 0
git config --local user.email "github-actions@users.noreply.github.com"
git config --local user.name "github-actions bot"
git commit -am "chore(format)"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,49 +0,0 @@
name: lint
on:
push:
branches:
- staging
- main
pull_request:
branches:
- staging
- main
jobs:
format:
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install Python
run: uv python install
- name: Sync dependencies
run: uv sync --locked --all-extras --dev
- name: Lint code
run: uv run poe lint
- name: Push linted code
run: |
git diff --quiet && exit 0
git config --local user.email "github-actions@users.noreply.github.com"
git config --local user.name "github-actions bot"
git commit -am "chore(lint)"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

67
.github/workflows/pipeline.yml vendored Normal file
View File

@@ -0,0 +1,67 @@
name: ci-pipeline
on:
push:
branches:
- staging
- main
pull_request:
branches:
- staging
- main
jobs:
typecheck:
runs-on: ubuntu-22.04
steps:
- uses: ./.github/workflows/type-check.yml
ci:
needs: typecheck
runs-on: ubuntu-22.04
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git user
run: |
git config --local user.email "github-actions@users.noreply.github.com"
git config --local user.name "github-actions bot"
shell: bash
- uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Python and uv
uses: ./.github/actions/setup-python-uv
- uses: ./.github/actions/regenerate-protobufs
- name: Commit regenerated protobufs
uses: ./.github/actions/conditional-commit
with:
message: "chore(proto) regenerate protobufs"
- uses: ./.github/actions/format
- name: Commit formatted code
uses: ./.github/actions/conditional-commit
with:
message: "chore(format): format code"
- uses: ./.github/actions/lint
- name: Commit lint fixes
uses: ./.github/actions/conditional-commit
with:
message: "chore(lint): fix linting errors"
- name: Push changes
run: git push
shell: bash

View File

@@ -1,38 +0,0 @@
name: type-check
on:
push:
branches:
- staging
- main
pull_request:
branches:
- staging
- main
jobs:
typecheck:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install Python
run: uv python install
- name: Sync dependencies
run: uv sync --locked --all-extras --dev
- name: Run type checker
run: uv run poe check