Skip to content

Commit f56248e

Browse files
authored
Merge pull request #20 from IthacaDream/feat/github-ci
feat: Set up GitHub Actions CI for tests and Python style checks
2 parents 2e9ca7c + 8807f34 commit f56248e

File tree

5 files changed

+156
-0
lines changed

5 files changed

+156
-0
lines changed

.github/linters/.isort.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[settings]
2+
line_length=120

.github/linters/.yaml-lint.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extends: default
2+
3+
rules:
4+
brackets:
5+
max-spaces-inside: 1
6+
comments-indentation: disable
7+
document-start: disable
8+
line-length: disable
9+
truthy: disable

.github/workflows/check-style.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Style Check
2+
3+
on:
4+
workflow_call:
5+
6+
concurrency:
7+
group: style-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
checks: write
12+
statuses: write
13+
contents: read
14+
15+
jobs:
16+
python-style:
17+
name: Python Style
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v6
23+
with:
24+
persist-credentials: false
25+
26+
- name: Check changed files
27+
id: changed-files
28+
uses: tj-actions/changed-files@v47
29+
with:
30+
files: |
31+
*
32+
.github/workflows/style.yml
33+
34+
- name: Setup UV and Python
35+
if: steps.changed-files.outputs.any_changed == 'true'
36+
uses: astral-sh/setup-uv@v7
37+
with:
38+
enable-cache: false
39+
python-version: "3.10"
40+
cache-dependency-glob: uv.lock
41+
42+
- name: Install dependencies
43+
if: steps.changed-files.outputs.any_changed == 'true'
44+
run: uv sync --dev --frozen
45+
46+
- name: Run Ruff Checks
47+
if: steps.changed-files.outputs.any_changed == 'true'
48+
run: uv run --dev ruff check

.github/workflows/main-ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Main CI Pipeline
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
push:
7+
branches: ["main"]
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
checks: write
13+
statuses: write
14+
15+
concurrency:
16+
group: main-ci-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
check-changes:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
code_changes: ${{ steps.changes.outputs.code_changes }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v6
27+
with:
28+
persist-credentials: false
29+
fetch-depth: 0
30+
- name: Check for file changes
31+
uses: dorny/paths-filter@v3
32+
id: changes
33+
with:
34+
base: ${{ github.base_ref || github.ref_name }}
35+
filters: |
36+
code_changes:
37+
- '*'
38+
- '**/*'
39+
# run-tests:
40+
# name: Run Tests
41+
# needs: check-changes
42+
# if: needs.check-changes.outputs.code_changes == 'true'
43+
# uses: ./.github/workflows/run-tests.yml
44+
45+
check-style:
46+
name: Style Check
47+
uses: ./.github/workflows/check-style.yml

.github/workflows/run-tests.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_call:
5+
6+
concurrency:
7+
group: api-tests-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
pytest:
12+
name: Run All python tests
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
shell: bash
17+
strategy:
18+
matrix:
19+
python-version:
20+
- "3.10"
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v6
25+
with:
26+
persist-credentials: false
27+
28+
- name: Install system dependencies
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y cmake portaudio19-dev python3-pyaudio libgl1-mesa-dev libglu1-mesa-dev
32+
33+
- name: Setup UV and Python
34+
uses: astral-sh/setup-uv@v7
35+
with:
36+
enable-cache: true
37+
python-version: ${{ matrix.python-version }}
38+
cache-dependency-glob: uv.lock
39+
40+
- name: Check UV lockfile
41+
run: uv lock --check
42+
43+
- name: Install dependencies
44+
run: uv sync --dev --all-extras --frozen
45+
46+
- name: Run Tests
47+
env:
48+
DEBUG: true
49+
run: |
50+
uv run --dev pytest

0 commit comments

Comments
 (0)