|
1 | 1 | name: CI |
2 | 2 |
|
3 | 3 | on: |
4 | | - # Run action when pushed to master, or for commits in a pull request. |
5 | 4 | push: |
6 | | - branches: |
7 | | - - master |
| 5 | + branches: [main, master] |
8 | 6 | pull_request: |
9 | | - branches: |
10 | | - - master |
| 7 | + branches: [main, master] |
11 | 8 |
|
12 | 9 | defaults: |
13 | 10 | run: |
14 | 11 | shell: bash |
15 | 12 |
|
16 | 13 | jobs: |
17 | | - checks: |
18 | | - name: Code checks |
19 | | - runs-on: ${{ matrix.os }} |
| 14 | + build-and-test: |
| 15 | + runs-on: ubuntu-latest |
20 | 16 | strategy: |
21 | 17 | fail-fast: false |
22 | 18 | matrix: |
23 | | - os: [ ubuntu-latest ] |
24 | 19 | python-version: [ "3.10", "3.11", "3.12", "3.13" ] |
25 | 20 | steps: |
26 | | - - name: Check out ${{ github.sha }} from repository ${{ github.repository }} |
| 21 | + - name: Check out code |
27 | 22 | uses: actions/checkout@v4 |
28 | 23 |
|
29 | | - - name: Install poetry |
30 | | - run: pipx install poetry |
| 24 | + - name: Show GitHub context variables |
| 25 | + run: | |
| 26 | + echo "GITHUB_SHA: $GITHUB_SHA" |
| 27 | + echo "GITHUB_REPOSITORY: $GITHUB_REPOSITORY" |
31 | 28 |
|
32 | 29 | - name: Set up Python ${{ matrix.python-version }} |
33 | 30 | uses: actions/setup-python@v5 |
34 | 31 | with: |
35 | 32 | python-version: ${{ matrix.python-version }} |
36 | | - cache: 'poetry' |
| 33 | + # ensure activation of poetry cache after poetry installation |
37 | 34 |
|
38 | | - - name: Install dependencies |
39 | | - run: poetry install --no-interaction |
| 35 | + - name: Install Poetry |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip |
| 38 | + pip install poetry |
40 | 39 |
|
41 | | - - name: Run checks |
42 | | - run: make check |
| 40 | + - name: Configure Poetry |
| 41 | + run: | |
| 42 | + poetry config virtualenvs.create true |
| 43 | + poetry config virtualenvs.in-project true |
| 44 | +
|
| 45 | + - name: Cache Poetry dependencies |
| 46 | + uses: actions/cache@v4 |
| 47 | + with: |
| 48 | + path: ~/.cache/pypoetry |
| 49 | + key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} |
| 50 | + restore-keys: | |
| 51 | + ${{ runner.os }}-poetry- |
| 52 | +
|
| 53 | + - name: Install dependencies (with dev) |
| 54 | + run: poetry install --with dev --no-interaction |
| 55 | + |
| 56 | + - name: Run code quality checks |
| 57 | + run: | |
| 58 | + echo "Running pylint..." |
| 59 | + make check-pylint |
| 60 | + echo "Running black format check..." |
| 61 | + make check-black |
| 62 | +
|
| 63 | + - name: Run tests with coverage (if tests exist) |
| 64 | + run: | |
| 65 | + if [ -d "tests" ] && find tests -name "test_*.py" | grep -q .; then |
| 66 | + echo "Running tests..." |
| 67 | + make test |
| 68 | + else |
| 69 | + echo "No test files found, skipping tests" |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Upload coverage to Codecov (optional) |
| 73 | + if: matrix.python-version == '3.12' |
| 74 | + uses: codecov/codecov-action@v4 |
| 75 | + with: |
| 76 | + file: ./coverage.xml |
| 77 | + fail_ci_if_error: false |
0 commit comments