Skip to content

Commit 43ef519

Browse files
sbryngelsonmre
authored andcommitted
Skip Rust build in pr-check when no tool YAML files are changed
When a PR only touches ci/** files (not data/tools/), the PR Check workflow still triggers but has no tool files to check. Previously this caused the pr-comment workflow to fail with "Artifact not found" because the artifact upload could produce an empty/missing artifact. Fix: emit a has_files output from the changed-files step and short-circuit immediately when it is false — writing pr_number.txt and result.txt directly so the artifact always exists. All Rust build steps are skipped when there is nothing to check.
1 parent 05b3471 commit 43ef519

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

.github/workflows/pr-check.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,23 @@ jobs:
4141
else
4242
FILES=$(git diff --name-only --diff-filter=A origin/master...HEAD -- 'data/tools/*.yml' 'data/tools/*.yaml' | tr '\n' ' ')
4343
fi
44+
FILES=$(echo "$FILES" | xargs) # trim leading/trailing whitespace
4445
echo "files=$FILES" >> "$GITHUB_OUTPUT"
46+
echo "has_files=$( [ -n "$FILES" ] && echo true || echo false )" >> "$GITHUB_OUTPUT"
47+
48+
- name: Skip: no tool files to check
49+
if: steps.changed.outputs.has_files == 'false'
50+
run: |
51+
mkdir -p pr-check-output
52+
echo "${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || github.event.pull_request.number }}" > pr-check-output/pr_number.txt
53+
echo "passed" > pr-check-output/result.txt
4554
4655
- name: Install Rust toolchain
56+
if: steps.changed.outputs.has_files == 'true'
4757
uses: dtolnay/rust-toolchain@stable
4858

4959
- name: Cache cargo registry
60+
if: steps.changed.outputs.has_files == 'true'
5061
uses: actions/cache@v4
5162
with:
5263
path: |
@@ -58,9 +69,11 @@ jobs:
5869
pr-check-${{ runner.os }}-
5970
6071
- name: Build pr-check
72+
if: steps.changed.outputs.has_files == 'true'
6173
run: cargo build --release --manifest-path ci/Cargo.toml -p pr-check
6274

6375
- name: Run pr-check
76+
if: steps.changed.outputs.has_files == 'true'
6477
id: run-check
6578
env:
6679
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)