Skip to content

Commit 361004d

Browse files
committed
ci: Change format warning to notice, and succeed the job if step fails
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]>
1 parent 47637ad commit 361004d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

.github/workflows/format.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ jobs:
4343
needs: find-changed-files
4444
if: ${{ needs.find-changed-files.outputs.files != '[]' }}
4545
runs-on: ubuntu-latest
46-
# Allow the workflow run to pass when this job fails
47-
continue-on-error: true
4846
strategy:
4947
fail-fast: false
5048
matrix:
@@ -55,13 +53,17 @@ jobs:
5553
- uses: actions/checkout@v4
5654

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

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

0 commit comments

Comments
 (0)