update Github pipeline #230
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: core-tests | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "pypy-3.11"] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Pipx cache for uv | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| /opt/pipx/venvs/uv | |
| /opt/pipx_bin/uv | |
| key: pipx-venvs-uv | |
| - name: Setup uv cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| /home/runner/.cache/uv | |
| key: 'uv-cache-${{ matrix.python-version }}' | |
| - name: Install uv and sync virtual environment | |
| run: | | |
| pipx install uv | |
| uv sync -p ${{ matrix.python-version }} | |
| echo $HOME | |
| du -h $HOME/.cache | |
| - name: Unit tests with pytest | |
| if: ${{ !startsWith(matrix.python-version, 'pypy') }} | |
| run: | | |
| uv run pytest | |
| env: | |
| COVERAGE_FILE: .coverage.${{ matrix.python-version }} | |
| - name: Upload coverage data | |
| if: success() || failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: coverage-data-${{ matrix.python-version }} | |
| if-no-files-found: warn | |
| include-hidden-files: true | |
| path: ./.coverage* | |
| compression-level: 0 # no compression | |
| retention-days: 1 | |
| - name: Static typechecking with mypy | |
| if: ${{ !startsWith(matrix.python-version, 'pypy') }} | |
| run: | | |
| uv run mypy ./zammadoo | |
| - name: Static code analysis with pylint | |
| if: ${{ !startsWith(matrix.python-version, 'pypy') }} | |
| run: | | |
| uv run pylint ./zammadoo | |
| process-test-data: | |
| if: success() || failure() | |
| runs-on: ubuntu-latest | |
| needs: test | |
| env: | |
| TOTAL_COVERAGE: '-' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download coverage data | |
| uses: actions/download-artifact@v8 | |
| with: | |
| merge-multiple: true | |
| - name: Pipx cache for coverage | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| /opt/pipx/venvs/coverage | |
| /opt/pipx_bin/coverage | |
| key: pipx-venvs-coverage | |
| - name: Install Python coverage | |
| run: | | |
| pipx install coverage[toml] | |
| pipx list --verbose | |
| - name: Merge coverage data and compute total coverage | |
| continue-on-error: true | |
| run: | | |
| coverage combine .coverage.* | |
| coverage json | |
| export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") | |
| echo "TOTAL_COVERAGE=$TOTAL" >> $GITHUB_ENV | |
| echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY | |
| coverage report | |
| - name: Update coverage badge | |
| continue-on-error: true | |
| uses: schneegans/dynamic-badges-action@v1.8.0 | |
| with: | |
| auth: ${{ secrets.GIST_TOKEN }} | |
| gistID: 1a66c9e88a9e4267f7e0b1d185be98f4 | |
| filename: 'covbadge.json' | |
| label: coverage | |
| message: ${{ env.TOTAL_COVERAGE }}% | |
| minColorRange: 50 | |
| maxColorRange: 90 | |
| valColorRange: ${{ env.TOTAL_COVERAGE }} | |
| isError: ${{ env.TOTAL_COVERAGE == '-' }} |