|
| 1 | +name: Run Linting and Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + schedule: |
| 9 | + - cron: "0 7 * * 1" |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint: |
| 14 | + name: Linting (pre-commit and mypy) |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout the repo |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + # Get history and tags for SCM versioning to work |
| 21 | + fetch-depth: 0 |
| 22 | + - name: Install the latest version of uv with cache enabled |
| 23 | + uses: astral-sh/setup-uv@v3 |
| 24 | + with: |
| 25 | + version: "latest" |
| 26 | + enable-cache: true |
| 27 | + cache-dependency-glob: "" |
| 28 | + - name: Run linters with tox |
| 29 | + run: uvx --python 3.9 --with tox-uv tox -e linters |
| 30 | + |
| 31 | + tests: |
| 32 | + name: Test it! |
| 33 | + runs-on: ${{ matrix.os }} |
| 34 | + strategy: |
| 35 | + matrix: |
| 36 | + python-version: [3.9, "3.13"] |
| 37 | + os: [ubuntu-latest, windows-latest] |
| 38 | + steps: |
| 39 | + - name: Checkout the repo |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + # Get history and tags for SCM versioning to work |
| 43 | + fetch-depth: 0 |
| 44 | + - name: Install the latest version of uv with cache enabled |
| 45 | + uses: astral-sh/setup-uv@v3 |
| 46 | + with: |
| 47 | + version: "latest" |
| 48 | + enable-cache: true |
| 49 | + cache-dependency-glob: "" |
| 50 | + - name: Test with tox |
| 51 | + run: uvx --python ${{ matrix.python-version }} --with tox-uv --with tox-gh-actions tox |
| 52 | + - name: Upload Unit Test Results |
| 53 | + if: always() |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: unit-test-results-python${{ matrix.python-version }}-${{ matrix.os }} |
| 57 | + path: | |
| 58 | + test-reports/junit-report.xml |
| 59 | + test-reports/coverage.xml |
| 60 | +
|
| 61 | + publish-test-results: |
| 62 | + name: "Publish Unit Tests Results" |
| 63 | + needs: tests |
| 64 | + runs-on: ubuntu-latest |
| 65 | + if: always() |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Download Artifacts |
| 69 | + uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + path: artifacts |
| 72 | + |
| 73 | + - name: Publish Unit Test Results |
| 74 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 75 | + continue-on-error: true |
| 76 | + with: |
| 77 | + files: artifacts/*/junit-report.xml |
| 78 | + |
| 79 | + - name: Produce the coverage report for Ubuntu |
| 80 | + uses: insightsengineering/coverage-action@v2 |
| 81 | + with: |
| 82 | + # Path to the Cobertura XML report. |
| 83 | + path: artifacts/unit-test-results-python3.13-ubuntu-latest/coverage.xml |
| 84 | + # Minimum total coverage, if you want to the |
| 85 | + # workflow to enforce it as a standard. |
| 86 | + # This has no effect if the `fail` arg is set to `false`. |
| 87 | + threshold: 70 |
| 88 | + # Fail the workflow if the minimum code coverage |
| 89 | + # reuqirements are not satisfied. |
| 90 | + fail: false |
| 91 | + # Publish the rendered output as a PR comment |
| 92 | + publish: true |
| 93 | + # Create a coverage diff report. |
| 94 | + diff: true |
| 95 | + # Branch to diff against. |
| 96 | + # Compare the current coverage to the coverage |
| 97 | + # determined on this branch. |
| 98 | + diff-branch: main |
| 99 | + # This is where the coverage reports for the |
| 100 | + # `diff-branch` are stored. |
| 101 | + # Branch is created if it doesn't already exist'. |
| 102 | + diff-storage: _xml_coverage_reports |
| 103 | + # A custom title that can be added to the code |
| 104 | + # coverage summary in the PR comment. |
| 105 | + coverage-summary-title: "Code Coverage" |
| 106 | + # Make the code coverage report togglable |
| 107 | + togglable-report: true |
| 108 | + |
| 109 | + check-pypi: |
| 110 | + name: Long description check for PyPI |
| 111 | + runs-on: ubuntu-latest |
| 112 | + steps: |
| 113 | + - name: Checkout the repo |
| 114 | + uses: actions/checkout@v4 |
| 115 | + with: |
| 116 | + # Get history and tags for SCM versioning to work |
| 117 | + fetch-depth: 0 |
| 118 | + - name: Install the latest version of uv with cache enabled |
| 119 | + uses: astral-sh/setup-uv@v3 |
| 120 | + with: |
| 121 | + version: "latest" |
| 122 | + enable-cache: true |
| 123 | + cache-dependency-glob: "" |
| 124 | + - name: Testing with tox and sphinx (to have rst2html.py utility available) |
| 125 | + run: uvx --with tox-uv --with sphinx tox -e pypi |
0 commit comments