|
1 | 1 | name: Test
|
2 | 2 |
|
3 | 3 | on:
|
4 |
| - push: |
5 |
| - branches: |
6 |
| - - master |
7 |
| - - develop |
8 |
| - pull_request: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' # matches every branch |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: "${{ github.workflow }}-${{ github.ref }}-test" |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +defaults: |
| 13 | + run: |
| 14 | + shell: bash |
| 15 | + |
| 16 | +permissions: |
| 17 | + id-token: write |
| 18 | + attestations: write |
| 19 | + |
9 | 20 |
|
10 | 21 | jobs:
|
11 |
| - lint: |
12 |
| - runs-on: ubuntu-latest |
13 |
| - steps: |
14 |
| - - uses: actions/checkout@v2 |
15 |
| - - uses: actions/setup-python@v2 |
16 |
| - |
17 |
| - - name: Install dependencies |
18 |
| - run: | |
19 |
| - python -m pip install --upgrade pip flake8 isort |
20 |
| - - name: Lint with flake8 |
21 |
| - run: | |
22 |
| - flake8 src |
23 |
| - isort -c src |
24 |
| -
|
25 |
| - test: |
26 |
| - # if: ${{github.event}} && ${{ !contains(github.event.head_commit.message, 'ci skip') }} |
27 |
| - runs-on: ubuntu-latest |
28 |
| - strategy: |
29 |
| - fail-fast: false |
30 |
| - matrix: |
31 |
| - python-version: [ "3.11", "3.12"] |
32 |
| - django-version: [ "4.2", "5.1"] |
33 |
| - env: |
34 |
| - PY_VER: ${{ matrix.python-version}} |
35 |
| - DJ_VER: ${{ matrix.django-version}} |
36 |
| - |
37 |
| - steps: |
38 |
| - - uses: actions/checkout@v2 |
39 |
| - |
40 |
| - - name: Set up Python ${{ matrix.python-version }} |
41 |
| - uses: actions/setup-python@v2 |
42 |
| - with: |
43 |
| - python-version: ${{ matrix.python-version }} |
44 |
| - |
45 |
| - - name: Install dependencies |
46 |
| - run: python -m pip install tox |
47 |
| - |
48 |
| - - name: Test with Tox |
49 |
| - run: tox -e d${DJ_VER//.}-py${PY_VER//.} -- --create-db --cov-report=xml --cov-report=term --junitxml=pytest.xml |
50 |
| - |
51 |
| - - uses: codecov/codecov-action@v1 |
52 |
| - with: |
53 |
| -# files: ./coverage1.xml,./coverage2.xml # optional |
54 |
| -# flags: unittests # optional |
55 |
| -# name: codecov-umbrella # optional |
56 |
| -# fail_ci_if_error: true # optional (default = false) |
57 |
| - verbose: true # optional (default = false) |
| 22 | + changes: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + timeout-minutes: 1 |
| 25 | + defaults: |
| 26 | + run: |
| 27 | + shell: bash |
| 28 | + outputs: |
| 29 | + run_tests: ${{steps.changes.outputs.run_tests }} |
| 30 | + lint: ${{steps.changes.outputs.lint }} |
| 31 | + steps: |
| 32 | + - name: Checkout code |
| 33 | + |
| 34 | + - id: changes |
| 35 | + name: Check for file changes |
| 36 | + uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0 |
| 37 | + with: |
| 38 | + base: ${{ github.ref }} |
| 39 | + token: ${{ github.token }} |
| 40 | + filters: .github/file-filters.yml |
| 41 | + |
| 42 | + ci: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + name: Test py${{ matrix.python-version }}/dj${{matrix.django-version}} |
| 45 | + defaults: |
| 46 | + run: |
| 47 | + shell: bash |
| 48 | + strategy: |
| 49 | + max-parallel: 1 |
| 50 | + matrix: |
| 51 | + python-version: [ "3.11", "3.12" ] |
| 52 | + django-version: [ "4.2", "5.1" ] |
| 53 | + fail-fast: true |
| 54 | + needs: [ changes ] |
| 55 | +# if: needs.changes.outputs.run_tests || needs.changes.outputs.lint |
| 56 | + steps: |
| 57 | + - name: Checkout code |
| 58 | + |
| 59 | + - name: Set up Python ${{ matrix.python-version }} |
| 60 | + uses: actions/setup-python@v5 |
| 61 | + with: |
| 62 | + python-version: ${{ matrix.python-version }} |
| 63 | + architecture: 'x64' |
| 64 | + - name: Restore cached venv |
| 65 | + id: cache-venv-restore |
| 66 | + uses: actions/cache/restore@v4 |
| 67 | + with: |
| 68 | + path: | |
| 69 | + .cache-uv/ |
| 70 | + .venv/ |
| 71 | + key: ${{ matrix.python-version }}-${{matrix.django-version}}-${{ hashFiles('pyproject.toml') }}-venv |
| 72 | + |
| 73 | + - uses: yezz123/setup-uv@v4 |
| 74 | + with: |
| 75 | + python: ${{ matrix.python-version }} |
| 76 | + |
| 77 | + - name: Test |
| 78 | +# if: needs.changes.outputs.run_tests |
| 79 | + run: | |
| 80 | + uv add "django==${{ matrix.django-version }}.*" |
| 81 | + uv run --cache-dir .cache-uv/ \ |
| 82 | + python -m pytest tests/ \ |
| 83 | + --junit-xml junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml \ |
| 84 | + --cov --cov-report xml |
| 85 | + - name: Cache venv |
| 86 | + if: steps.cache-venv-restore.outputs.cache-hit != 'true' |
| 87 | + id: cache-venv-save |
| 88 | + uses: actions/cache/save@v4 |
| 89 | + with: |
| 90 | + path: | |
| 91 | + .cache-uv/ |
| 92 | + .venv/ |
| 93 | + key: ${{ matrix.python-version }}-${{matrix.django-version}}-${{ hashFiles('pyproject.toml') }}-venv |
| 94 | + |
| 95 | + - name: Upload pytest test results |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: pytest-results-${{ matrix.python-version }}-${{matrix.django-version}} |
| 99 | + path: junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml |
| 100 | + if: ${{ always() }} |
| 101 | + |
| 102 | + - name: Upload coverage to Codecov |
| 103 | + uses: codecov/codecov-action@v4 |
| 104 | + if: matrix.python-version == 3.12 |
| 105 | + continue-on-error: true |
| 106 | + with: |
| 107 | + env_vars: OS,PYTHON |
| 108 | + fail_ci_if_error: true |
| 109 | + flags: unittests |
| 110 | + files: ./coverage.xml |
| 111 | + verbose: false |
| 112 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 113 | + name: codecov-${{env.GITHUB_REF_NAME}} |
0 commit comments