Skip to content

Commit

Permalink
ci: Change format warning to notice, and succeed the job if step fails
Browse files Browse the repository at this point in the history
Github only has 2 states for the result of a job, either success or
error. A warning state would be nice but isn't available.

We still add a notice to changed files to suggest contributors to
format.

Signed-off-by: Pieter De Gendt <[email protected]>
  • Loading branch information
pdgendt committed Dec 3, 2024
1 parent 47637ad commit 361004d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ jobs:
needs: find-changed-files
if: ${{ needs.find-changed-files.outputs.files != '[]' }}
runs-on: ubuntu-latest
# Allow the workflow run to pass when this job fails
continue-on-error: true
strategy:
fail-fast: false
matrix:
Expand All @@ -55,13 +53,17 @@ jobs:
- uses: actions/checkout@v4

- name: Run ruff format check for ${{ matrix.files.path }}
id: format-check
uses: astral-sh/ruff-action@v1
# Allow the job run to pass when this step fails
continue-on-error: true
with:
args: "format --check --diff"
src: "${{ matrix.files.path }}"
version: 0.8.1

- name: Annotate unformatted file
if: ${{ failure() }}
if: ${{ steps.format-check.outcome }} == 'failure'
run: |
echo "::warning file=${{ matrix.files.path }},title=File format check failed::Run 'ruff format ${{ matrix.files.path }}'"
JOB_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
echo "::notice file=${{ matrix.files.path }},title=Unformatted file::Consider running 'ruff format ${{ matrix.files.path }}'%0ASee $JOB_URL for more details"

0 comments on commit 361004d

Please sign in to comment.