fix: the generated ruff config runs the rules it selects (#8) #11
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: CI | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| jobs: | |
| # The only thing that can be wrong with a template is what it generates, so the | |
| # check is the generated project's own gate: render with the defaults, then run | |
| # exactly what a new library's CI would run. | |
| render: | |
| name: Render the template and run the generated gate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: astral-sh/setup-uv@v7 | |
| - name: Render with copier | |
| run: | | |
| uvx --with jinja2-time copier copy --defaults --trust --vcs-ref HEAD \ | |
| --data project_name=demo-lib \ | |
| --data project_slug=demo-lib \ | |
| --data package_name=demo_lib \ | |
| --data project_description="Demo library rendered from the template" \ | |
| --data author_name="Bedrock Python" \ | |
| --data author_email="maintainers@example.com" \ | |
| . "${RUNNER_TEMP}/demo-lib" | |
| - name: The generated project passes its own gate | |
| working-directory: ${{ runner.temp }}/demo-lib | |
| run: | | |
| uv sync --group dev --all-extras | |
| make check | |
| make test-unit | |
| uv build | |
| # A rule that is selected and then ignored looks exactly like a rule that | |
| # works: the gate above stays green either way. Hand the generated project | |
| # the mistakes the selected rules exist to catch and make it say so, and an | |
| # assert in tests/ that has to stay accepted. | |
| - name: The generated config runs the rules it selects | |
| working-directory: ${{ runner.temp }}/demo-lib | |
| run: | | |
| cat > demo_lib/probe.py <<'PY' | |
| import datetime | |
| def stamp(offset): | |
| return datetime.datetime.now() + offset | |
| PY | |
| cat > tests/unit/test_probe.py <<'PY' | |
| def test__assert__still_reads_as_a_test() -> None: | |
| assert True | |
| PY | |
| report=$(uv run ruff check --output-format concise demo_lib/probe.py || true) | |
| echo "$report" | |
| for rule in DTZ005 ANN201 ANN001; do | |
| case "$report" in | |
| *"$rule"*) ;; | |
| *) echo "::error::$rule never fired -- the config selects the rule and then ignores it"; exit 1 ;; | |
| esac | |
| done | |
| uv run ruff check tests/unit/test_probe.py | |
| rm demo_lib/probe.py tests/unit/test_probe.py | |
| all-checks-passed: | |
| name: All checks passed | |
| if: always() | |
| needs: [render] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Every job above succeeded | |
| run: echo '${{ toJSON(needs) }}' | jq -e 'all(.[]; .result == "success")' |