ref: mapper api overhaul #582
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: π Tests and linting | |
| env: | |
| COLUMNS: 120 # Makes the error summary table printed by pytest-pretty much easier to read | |
| PROJECT_NAME: "strawchemy" | |
| on: | |
| push: | |
| branches: [ main, ci/*, dependabot/*, renovate/* ] | |
| tags: | |
| - "v*.*.*" | |
| pull_request: | |
| branches: [ main ] | |
| concurrency: | |
| group: ${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| pre: | |
| runs-on: ubuntu-latest | |
| # Map a step output to a job output | |
| outputs: | |
| should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
| steps: | |
| - name: Skip check | |
| id: skip_check | |
| uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5 | |
| with: | |
| concurrent_skipping: "never" | |
| skip_after_successful_duplicate: "true" | |
| paths_ignore: '["**/**.md", "**/.vscode/**", "**/.dockerignore", "Makefile"]' | |
| paths: '["src/**", "tests/**", "uv.lock", "pyproject.toml", ".github/workflows/ci.yaml", "noxfile.py", "mise.toml"]' | |
| generate-jobs-tests: | |
| name: π» Generate test matrix | |
| needs: pre | |
| if: github.ref_type == 'tag' || needs.pre.outputs.should_skip != 'true' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| sessions: ${{ steps.set-matrix.outputs.sessions }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Setup mise | |
| uses: jdx/mise-action@146a28175021df8ca24f8ee1828cc2a60f980bd5 # v3 | |
| with: | |
| cache: true | |
| log_level: debug | |
| - name: Generate test matrix | |
| id: set-matrix | |
| shell: bash | |
| run: | | |
| echo sessions=$(mise run ci:test-matrix) | tee --append $GITHUB_OUTPUT | |
| tests: | |
| name: π¬ ${{ matrix.session.job_name }} | |
| needs: [ pre, generate-jobs-tests ] | |
| if: github.ref_type == 'tag' || needs.pre.outputs.should_skip != 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| session: ${{ fromJson(needs.generate-jobs-tests.outputs.sessions) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Set up Docker Buildx | |
| if: contains(matrix.session.tags, 'docker') | |
| id: docker-buildx | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3 | |
| - name: Pip and nox cache | |
| id: cache | |
| uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5 | |
| with: | |
| path: | | |
| ~/.cache | |
| ~/.nox | |
| .nox | |
| key: | |
| ${{ runner.os }}-nox-${{ matrix.session.session }}-${{ env.pythonLocation }}-${{ | |
| hashFiles('**/uv.lock') }}-${{ hashFiles('**/noxfile.py') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nox-${{ matrix.session.session }}-${{ env.pythonLocation }} | |
| - name: Setup mise | |
| uses: jdx/mise-action@146a28175021df8ca24f8ee1828cc2a60f980bd5 # v3 | |
| with: | |
| cache: true | |
| log_level: debug | |
| - name: Run tests | |
| run: mise run ci:test "${{ matrix.session.session }}" | |
| - name: Rename coverage and junit files | |
| run: | | |
| mv .coverage* .coverage.${{ matrix.session.session }} | |
| mv junit* junit-${{ matrix.session.session }}.xml | |
| - name: Upload coverage data | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 | |
| id: upload-coverage-data | |
| if: ${{ always() }} | |
| with: | |
| name: coverage-${{ matrix.session.session }} | |
| path: .coverage.${{ matrix.session.session }} | |
| include-hidden-files: true | |
| - name: Upload test results data | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 | |
| id: upload-test-results-data | |
| if: ${{ always() }} | |
| with: | |
| name: test-results-${{ matrix.session.session }} | |
| path: junit-${{ matrix.session.session }}.xml | |
| upload-coverage: | |
| name: π Upload Coverage | |
| needs: [ tests, generate-jobs-tests ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Download test artifacts | |
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 | |
| with: | |
| pattern: coverage-* | |
| merge-multiple: true | |
| - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6 | |
| with: | |
| python-version: "3.13" | |
| - name: Combine coverage files | |
| run: | | |
| python -Im pip install coverage covdefaults | |
| python -Im coverage combine | |
| python -Im coverage xml -i | |
| - name: Upload coverage to Codeocv | |
| id: upload-coverage | |
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5 | |
| with: | |
| name: ${{env.PROJECT_NAME}}-tests | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| verbose: true | |
| upload-test-results: | |
| name: π Upload test results | |
| needs: [ tests, generate-jobs-tests ] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| session: ${{ fromJson(needs.generate-jobs-tests.outputs.sessions) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Download test artifacts | |
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7 | |
| with: | |
| pattern: test-results-* | |
| - name: Upload test results to Codecov | |
| id: upload-test-results | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1 | |
| with: | |
| name: ${{env.PROJECT_NAME}}-test-results | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: ${{ matrix.session.session }} | |
| verbose: true | |
| lint: | |
| name: β¨ Lint | |
| needs: pre | |
| if: github.ref_type == 'tag' || needs.pre.outputs.should_skip != 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Setup mise | |
| uses: jdx/mise-action@146a28175021df8ca24f8ee1828cc2a60f980bd5 # v3 | |
| with: | |
| cache: true | |
| log_level: debug | |
| - name: Install dependencies | |
| run: mise run uv:install | |
| - name: Run linting | |
| run: mise run lint | |
| # Ensure the workflow is successful only if all job in matrixes are successful | |
| result: | |
| name: β Result | |
| if: (github.ref_type == 'tag' || needs.pre.outputs.should_skip != 'true') && always() | |
| runs-on: ubuntu-latest | |
| needs: | |
| - pre | |
| - tests | |
| - lint | |
| steps: | |
| - name: Mark workflow as failed if lint or test did not pass or were cancelled | |
| if: contains(fromJson('["failure", "cancelled"]'), needs.tests.result) || contains(fromJson('["failure", "cancelled"]'), needs.lint.result) | |
| run: exit 1 | |
| - name: Invoke release workflow | |
| if: github.ref_type == 'tag' | |
| uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc # v1 | |
| with: | |
| workflow: π Continuous Deployment |