Skip to content

Commit 615bae8

Browse files
authored
[CI] Fix dependency checks (#4793)
This PR enhances dependency checks with the following changes: - Checks if all dependency files exist; if not, the GitHub action will fail. - Calculates a hash to determine if any NVIDIA dependencies have changed. - Extracts only the hash when using `sha256sum` (by default, its output is `<hash> <filename>`).
1 parent 4d711bd commit 615bae8

File tree

2 files changed

+60
-14
lines changed

2 files changed

+60
-14
lines changed

.github/workflows/integration-tests.yml

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
with:
5353
files: |
5454
cmake/*.txt
55+
cmake/*.json
5556
- name: Detect if enough time has passed since last post-submit run
5657
id: detect-time
5758
if: github.event_name == 'push'
@@ -127,7 +128,7 @@ jobs:
127128
- name: Compute hash of pre-commit config
128129
id: cache-key
129130
run: |
130-
echo "pre_commit_hash=$(sha256sum .pre-commit-config.yaml)" >> $GITHUB_OUTPUT
131+
echo "pre_commit_hash=$(sha256sum .pre-commit-config.yaml | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
131132
shell: bash
132133
- name: Cache pre-commit's cache dir
133134
uses: actions/cache@v4
@@ -165,9 +166,20 @@ jobs:
165166
- name: Compute cache keys
166167
id: cache-key
167168
run: |
168-
echo "llvm=$(cat cmake/llvm-hash.txt | cut -c 1-8)" >> $GITHUB_OUTPUT
169-
echo "nvidia=$(cat cmake/nvidia-toolchain-version.txt)" >> $GITHUB_OUTPUT
170-
echo "json=$(cat cmake/json-version.txt)" >> $GITHUB_OUTPUT
169+
llvm_file="cmake/llvm-hash.txt"
170+
nvidia_file="cmake/nvidia-toolchain-version.json"
171+
json_file="cmake/json-version.txt"
172+
173+
# Check if files exist before proceeding
174+
if [[ ! -f "$llvm_file" || ! -f "$nvidia_file" || ! -f "$json_file" ]]; then
175+
echo "Error: Required dependency files are missing."
176+
exit 1
177+
fi
178+
179+
# Process the files if they exist
180+
echo "llvm=$(cat $llvm_file | cut -c 1-8)" >> $GITHUB_OUTPUT
181+
echo "nvidia=$(sha256sum $nvidia_file | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
182+
echo "json=$(cat $json_file)" >> $GITHUB_OUTPUT
171183
echo "datetime=$(date -u -Iseconds)" >> $GITHUB_OUTPUT
172184
shell: bash
173185
- name: Cache build dependencies
@@ -306,9 +318,20 @@ jobs:
306318
- name: Compute cache keys
307319
id: cache-key
308320
run: |
309-
echo "llvm=$(cat cmake/llvm-hash.txt | cut -c 1-8)" >> $GITHUB_OUTPUT
310-
echo "nvidia=$(cat cmake/nvidia-toolchain-version.txt)" >> $GITHUB_OUTPUT
311-
echo "json=$(cat cmake/json-version.txt)" >> $GITHUB_OUTPUT
321+
llvm_file="cmake/llvm-hash.txt"
322+
nvidia_file="cmake/nvidia-toolchain-version.json"
323+
json_file="cmake/json-version.txt"
324+
325+
# Check if files exist before proceeding
326+
if [[ ! -f "$llvm_file" || ! -f "$nvidia_file" || ! -f "$json_file" ]]; then
327+
echo "Error: Required dependency files are missing."
328+
exit 1
329+
fi
330+
331+
# Process the files if they exist
332+
echo "llvm=$(cat $llvm_file | cut -c 1-8)" >> $GITHUB_OUTPUT
333+
echo "nvidia=$(sha256sum $nvidia_file | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
334+
echo "json=$(cat $json_file)" >> $GITHUB_OUTPUT
312335
echo "datetime=$(date -u -Iseconds)" >> $GITHUB_OUTPUT
313336
shell: bash
314337
- name: Cache build dependencies
@@ -441,9 +464,20 @@ jobs:
441464
- name: Compute cache keys
442465
id: cache-key
443466
run: |
444-
echo "llvm=$(cat cmake/llvm-hash.txt | cut -c 1-8)" >> $GITHUB_OUTPUT
445-
echo "nvidia=$(cat cmake/nvidia-toolchain-version.txt)" >> $GITHUB_OUTPUT
446-
echo "json=$(cat cmake/json-version.txt)" >> $GITHUB_OUTPUT
467+
llvm_file="cmake/llvm-hash.txt"
468+
nvidia_file="cmake/nvidia-toolchain-version.json"
469+
json_file="cmake/json-version.txt"
470+
471+
# Check if files exist before proceeding
472+
if [[ ! -f "$llvm_file" || ! -f "$nvidia_file" || ! -f "$json_file" ]]; then
473+
echo "Error: Required dependency files are missing."
474+
exit 1
475+
fi
476+
477+
# Process the files if they exist
478+
echo "llvm=$(cat $llvm_file | cut -c 1-8)" >> $GITHUB_OUTPUT
479+
echo "nvidia=$(sha256sum $nvidia_file | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
480+
echo "json=$(cat $json_file)" >> $GITHUB_OUTPUT
447481
echo "datetime=$(date -u -Iseconds)" >> $GITHUB_OUTPUT
448482
shell: bash
449483
- name: Cache build dependencies

.github/workflows/integration-tests.yml.in

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
with:
5959
files: |
6060
cmake/*.txt
61+
cmake/*.json
6162

6263
- name: Detect if enough time has passed since last post-submit run
6364
id: detect-time
@@ -140,7 +141,7 @@ jobs:
140141
- name: Compute hash of pre-commit config
141142
id: cache-key
142143
run: |
143-
echo "pre_commit_hash=$(sha256sum .pre-commit-config.yaml)" >> $GITHUB_OUTPUT
144+
echo "pre_commit_hash=$(sha256sum .pre-commit-config.yaml | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
144145
shell: bash
145146

146147
- name: Cache pre-commit's cache dir
@@ -188,9 +189,20 @@ jobs:
188189
name: Compute cache keys
189190
id: cache-key
190191
run: |
191-
echo "llvm=$(cat cmake/llvm-hash.txt | cut -c 1-8)" >> $GITHUB_OUTPUT
192-
echo "nvidia=$(cat cmake/nvidia-toolchain-version.txt)" >> $GITHUB_OUTPUT
193-
echo "json=$(cat cmake/json-version.txt)" >> $GITHUB_OUTPUT
192+
llvm_file="cmake/llvm-hash.txt"
193+
nvidia_file="cmake/nvidia-toolchain-version.json"
194+
json_file="cmake/json-version.txt"
195+
196+
# Check if files exist before proceeding
197+
if [[ ! -f "$llvm_file" || ! -f "$nvidia_file" || ! -f "$json_file" ]]; then
198+
echo "Error: Required dependency files are missing."
199+
exit 1
200+
fi
201+
202+
# Process the files if they exist
203+
echo "llvm=$(cat $llvm_file | cut -c 1-8)" >> $GITHUB_OUTPUT
204+
echo "nvidia=$(sha256sum $nvidia_file | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
205+
echo "json=$(cat $json_file)" >> $GITHUB_OUTPUT
194206
echo "datetime=$(date -u -Iseconds)" >> $GITHUB_OUTPUT
195207
shell: bash
196208

0 commit comments

Comments
 (0)