π· ci(build): always post build gate on pull requests #1167
Workflow file for this run
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: π§ͺ pyproject-fmt | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| changes: | |
| name: π changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| run: ${{ github.event_name != 'pull_request' || steps.filter.outputs.run == 'true' }} | |
| steps: | |
| - name: π₯ Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: π Check for changes | |
| uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1 | |
| id: filter | |
| with: | |
| filters: | | |
| run: | |
| - 'common/**' | |
| - 'toml-fmt-common/**' | |
| - 'pyproject-fmt/**' | |
| - '.github/workflows/pyproject_fmt_test.yaml' | |
| clippy: | |
| name: π clippy | |
| needs: changes | |
| if: needs.changes.outputs.run == 'true' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: π₯ Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: π¦ Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| components: clippy | |
| - name: π Run Clippy | |
| run: cargo clippy -p pyproject-fmt --locked --all-targets -- -D warnings | |
| fmt: | |
| name: π¨ fmt | |
| needs: changes | |
| if: needs.changes.outputs.run == 'true' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: π₯ Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: π¦ Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| components: rustfmt | |
| - name: π¨ Check formatting | |
| run: cargo fmt -p pyproject-fmt --check | |
| build: | |
| name: π¨ build | |
| needs: changes | |
| if: needs.changes.outputs.run == 'true' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: π₯ Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: π¦ Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| - name: π¨ Build | |
| run: cargo build -p pyproject-fmt --locked | |
| test: | |
| name: β test | |
| needs: changes | |
| if: needs.changes.outputs.run == 'true' | |
| runs-on: ubuntu-24.04 | |
| environment: test | |
| steps: | |
| - name: π₯ Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: π¦ Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| with: | |
| components: llvm-tools-preview | |
| - name: π¦ Install cargo-llvm-cov | |
| uses: taiki-e/install-action@9bcaee1dcae34154180f412e2fa69355a7cda9f6 # v2.82.6 | |
| with: | |
| tool: cargo-llvm-cov | |
| - name: β Run tests with coverage | |
| run: cargo llvm-cov -p pyproject-fmt --no-default-features --locked --codecov --output-path coverage.json --ignore-filename-regex 'main\.rs' | |
| - name: π€ Upload coverage | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.json | |
| flags: rust | |
| py: | |
| name: π ${{ matrix.py }} @ ${{ matrix.os }} | |
| needs: changes | |
| if: needs.changes.outputs.run == 'true' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| py: ["3.15", "3.15t", "3.14", "3.14t", "3.13", "3.12", "3.11", "3.10"] | |
| os: [ubuntu-24.04, windows-2025, macos-15] | |
| defaults: | |
| run: | |
| working-directory: pyproject-fmt | |
| steps: | |
| - name: π₯ Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: π¦ Setup uv | |
| uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "pyproject.toml" | |
| - name: π§ Install tox | |
| run: uv tool install --python-preference only-managed --python 3.14 tox --with tox-uv | |
| - name: π Install Python ${{ matrix.py }} | |
| if: matrix.py != '3.14' | |
| run: uv python install --python-preference only-managed ${{ matrix.py }} | |
| - name: π¦ Setup Rust | |
| uses: moonrepo/setup-rust@abb2d32350334249b178c401e5ec5836e0cd88d3 # v1 | |
| with: | |
| cache-base: main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: π Generate README.rst | |
| run: tox run -e readme | |
| working-directory: pyproject-fmt | |
| - name: π Generate tox-toml-fmt README.rst | |
| run: tox run -e readme | |
| working-directory: tox-toml-fmt | |
| - name: π§ Setup test suite | |
| run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }} | |
| - name: β Run tests | |
| run: tox run --skip-pkg-install -e ${{ matrix.py }} | |
| env: | |
| PYTEST_ADDOPTS: "-vv --durations=20" | |
| check: | |
| name: π ${{ matrix.env }} | |
| needs: changes | |
| if: needs.changes.outputs.run == 'true' | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| env: [type, dev, pkg_meta] | |
| defaults: | |
| run: | |
| working-directory: pyproject-fmt | |
| steps: | |
| - name: π₯ Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: π¦ Setup uv | |
| uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "pyproject.toml" | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: π§ Install tox | |
| run: uv tool install --python-preference only-managed --python 3.14 tox --with tox-uv | |
| - name: π¦ Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 | |
| - name: π Generate README.rst | |
| run: tox run -e readme | |
| working-directory: pyproject-fmt | |
| - name: π Generate tox-toml-fmt README.rst | |
| run: tox run -e readme | |
| working-directory: tox-toml-fmt | |
| - name: π§ Setup test suite | |
| run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.env }} | |
| - name: β Run tests | |
| run: tox run --skip-pkg-install -e ${{ matrix.env }} | |
| env: | |
| PYTEST_ADDOPTS: "-vv --durations=20" | |
| all-pass: | |
| name: β pyproject-fmt | |
| if: always() | |
| needs: [changes, clippy, fmt, build, test, py, check] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Decide whether all jobs passed or were skipped | |
| run: | | |
| if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then | |
| echo "Some jobs failed or were canceled" | |
| exit 1 | |
| fi | |
| echo "All jobs passed or were skipped" |