|
1 | | -name: Unit tests |
| 1 | +name: Unit tests and docs generation |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - "**" |
7 | 7 | pull_request: |
| 8 | + branches: |
| 9 | + - "**" |
8 | 10 | types: [opened, synchronize, reopened, ready_for_review] |
9 | 11 | workflow_dispatch: |
10 | 12 |
|
11 | 13 | jobs: |
12 | 14 | check: |
13 | 15 | if: github.event.pull_request.draft == false |
14 | | - runs-on: ${{matrix.os}} |
| 16 | + runs-on: ${{ matrix.os }} |
15 | 17 | strategy: |
16 | 18 | matrix: |
17 | 19 | os: [ubuntu-latest, windows-latest] |
18 | | - python-version: ['3.8', '3.9', '3.10', '3.11'] |
| 20 | + python-version: ["3.9", "3.11", "3.12"] |
19 | 21 | defaults: |
20 | 22 | run: |
21 | 23 | shell: bash -l {0} |
22 | 24 |
|
23 | 25 | steps: |
| 26 | + - name: Set OS and Python version |
| 27 | + id: set-vars |
| 28 | + run: | |
| 29 | + if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/dev" ]]; then |
| 30 | + echo "os-matrix=ubuntu-latest,windows-latest" >> $GITHUB_ENV |
| 31 | + echo "python-matrix=3.9,3.11,3.12" >> $GITHUB_ENV |
| 32 | + else |
| 33 | + echo "os-matrix=ubuntu-latest" >> $GITHUB_ENV |
| 34 | + echo "python-matrix=3.12" >> $GITHUB_ENV |
| 35 | + fi |
24 | 36 | - name: Checkout |
25 | 37 | uses: actions/checkout@v3 |
26 | 38 | - name: Python |
27 | 39 | uses: actions/setup-python@v4 |
28 | 40 | with: |
29 | 41 | python-version: ${{ matrix.python-version }} |
| 42 | + - name: Cache Poetry |
| 43 | + uses: actions/cache@v3 |
| 44 | + with: |
| 45 | + path: | |
| 46 | + ~/.cache/pypoetry |
| 47 | + ~/.cache/pip |
| 48 | + key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-poetry-${{ matrix.python-version }}- |
30 | 51 | - name: Poetry |
31 | 52 | uses: snok/install-poetry@v1 |
32 | 53 | with: |
|
41 | 62 | uses: codecov/codecov-action@v3 |
42 | 63 | env: |
43 | 64 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 65 | + - name: Check Changed Files |
| 66 | + id: changed-files |
| 67 | + run: | |
| 68 | + git fetch origin ${{ github.base_ref }}:${{ github.base_ref }} --depth=1 |
| 69 | + git diff --name-only ${{ github.base_ref }} > changed_files.txt |
| 70 | + - name: Build Docs |
| 71 | + if: contains(fromJSON('["docs/", ".rst"]').join(','), fromJSON('["${{ steps.changed-files.outputs.files }}"]').join(',')) |
| 72 | + run: | |
| 73 | + poetry run sphinx-build -b html docs/ _build/html |
0 commit comments