Skip to content

Commit d3992b2

Browse files
committed
workaround for issue actions/runner#2417
1 parent 3694c1b commit d3992b2

File tree

3 files changed

+97
-60
lines changed

3 files changed

+97
-60
lines changed

.github/workflows/run-build.yml

+57-28
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ name: Build
1616
on:
1717
workflow_call:
1818
inputs:
19+
version:
20+
description: Use actions of this version as workaround for https://github.com/actions/runner/issues/2417 (optional, defaults to latest release).
21+
type: string
1922
source-dir:
2023
description: The CMake source directory (optional, defaults to working directory).
2124
type: string
@@ -44,7 +47,7 @@ on:
4447
permissions: {}
4548

4649
concurrency:
47-
group: run-build-${{github.workflow}}-${{github.event_name}}-${{github.ref}}
50+
group: cmu-build-${{github.workflow}}-${{github.event_name}}-${{github.ref}}
4851
cancel-in-progress: true
4952

5053
jobs:
@@ -61,18 +64,37 @@ jobs:
6164

6265
steps:
6366
# Actions: Load
67+
- name: 'Actions: Get SHA'
68+
# Workaround for https://github.com/actions/runner/issues/2417
69+
id: actions-latest
70+
shell: bash
71+
env:
72+
VERSION: ${{inputs.version}}
73+
GITHUB_TOKEN: ${{github.token}}
74+
run: |
75+
if [[ -z $VERSION ]]; then
76+
VERSION=$(curl --no-progress-meter \
77+
-H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" \
78+
"$GITHUB_API_URL/repos/mbeckh/cmake-utils/releases/latest" \
79+
| jq -r '.tag_name')
80+
echo "Using latest release: $VERSION"
81+
fi
82+
(echo -n "sha=" && curl --no-progress-meter \
83+
-H "Accept: application/vnd.github.sha" -H "Authorization: Bearer $GITHUB_TOKEN" \
84+
"$GITHUB_API_URL/repos/mbeckh/cmake-utils/commits/$VERSION) >> $GITHUB_OUTPUT
85+
6486
- name: 'Actions: Restore'
6587
id: actions-restore
6688
uses: actions/cache/restore@v3
6789
with:
6890
path: cmake-utils
69-
key: cmu-cmake-utils-${{github.job_workflow_sha}}
91+
key: cmu-cmake-utils-${{steps.actions-latest.outputs.sha}} # should be: cmu-cmake-utils-${{github.job_workflow_sha}}
7092

7193
- name: 'Actions: Load'
7294
if: steps.actions-restore.outputs.cache-hit != 'true'
7395
shell: bash
7496
env:
75-
JOB_WORKFLOW_SHA: ${{github.job_workflow_sha}}
97+
JOB_WORKFLOW_SHA: ${{steps.actions-latest.outputs.sha}} # should be: ${{github.job_workflow_sha}}
7698
GITHUB_TOKEN: ${{github.token}}
7799
run: |
78100
curl -L --no-progress-meter -o "cmake-utils-$JOB_WORKFLOW_SHA.tar.gz" \
@@ -119,7 +141,7 @@ jobs:
119141
shell: bash
120142
working-directory: source${{inputs.source-dir != '.' && inputs.source-dir && '/' || ''}}${{inputs.source-dir != '.' && inputs.source-dir || ''}}
121143
run: |
122-
((echo "image-os=$ImageOS") & (echo "image-version=$ImageVersion")) >> $GITHUB_OUTPUT
144+
(echo "image-os=$ImageOS" && echo "image-version=$ImageVersion") >> $GITHUB_OUTPUT
123145
if [[ -f vcpkg.json ]]; then
124146
registries=$(jq --sort-keys $([[ -f vcpkg-configuration.json ]] && echo '--slurp') '.' \
125147
vcpkg.json $([[ -f vcpkg-configuration.json ]] && echo 'vcpkg-configuration.json') \
@@ -131,10 +153,8 @@ jobs:
131153
| { repository, reference, baseline }
132154
| del(.. | nulls)
133155
] | sort')
134-
[[ $RUNNER_DEBUG -eq 1 ]] && echo "$registries" || true
135-
if [[ $registries != '[]' ]]; then
136-
(echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
137-
fi
156+
[[ $RUNNER_DEBUG != 1 ]] || echo "$registries"
157+
[[ $registries == '[]' ]] || (echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
138158
fi
139159
140160
- name: 'Tools: Restore'
@@ -327,18 +347,37 @@ jobs:
327347

328348
steps:
329349
# Actions: Load
350+
- name: 'Actions: Get SHA'
351+
# Workaround for https://github.com/actions/runner/issues/2417
352+
id: actions-latest
353+
shell: bash
354+
env:
355+
VERSION: ${{inputs.version}}
356+
GITHUB_TOKEN: ${{github.token}}
357+
run: |
358+
if [[ -z $VERSION ]]; then
359+
VERSION=$(curl --no-progress-meter \
360+
-H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" \
361+
"$GITHUB_API_URL/repos/mbeckh/cmake-utils/releases/latest" \
362+
| jq -r '.tag_name')
363+
echo "Using latest release: $VERSION"
364+
fi
365+
(echo -n "sha=" && curl --no-progress-meter \
366+
-H "Accept: application/vnd.github.sha" -H "Authorization: Bearer $GITHUB_TOKEN" \
367+
"$GITHUB_API_URL/repos/mbeckh/cmake-utils/commits/$VERSION) >> $GITHUB_OUTPUT
368+
330369
- name: 'Actions: Restore'
331370
id: actions-restore
332371
uses: actions/cache/restore@v3
333372
with:
334373
path: cmake-utils
335-
key: cmu-cmake-utils-${{github.job_workflow_sha}}
374+
key: cmu-cmake-utils-${{steps.actions-latest.outputs.sha}} # should be: cmu-cmake-utils-${{github.job_workflow_sha}}
336375

337376
- name: 'Actions: Load'
338377
if: steps.actions-restore.outputs.cache-hit != 'true'
339378
shell: bash
340379
env:
341-
JOB_WORKFLOW_SHA: ${{github.job_workflow_sha}}
380+
JOB_WORKFLOW_SHA: ${{steps.actions-latest.outputs.sha}} # should be: ${{github.job_workflow_sha}}
342381
GITHUB_TOKEN: ${{github.token}}
343382
run: |
344383
curl -L --no-progress-meter -o "cmake-utils-$JOB_WORKFLOW_SHA.tar.gz" \
@@ -385,7 +424,7 @@ jobs:
385424
shell: bash
386425
working-directory: source${{inputs.source-dir != '.' && inputs.source-dir && '/' || ''}}${{inputs.source-dir != '.' && inputs.source-dir || ''}}
387426
run: |
388-
((echo "image-os=$ImageOS") & (echo "image-version=$ImageVersion")) >> $GITHUB_OUTPUT
427+
(echo "image-os=$ImageOS" && echo "image-version=$ImageVersion") >> $GITHUB_OUTPUT
389428
if [[ -f vcpkg.json ]]; then
390429
registries=$(jq --sort-keys $([[ -f vcpkg-configuration.json ]] && echo '--slurp') '.' \
391430
vcpkg.json $([[ -f vcpkg-configuration.json ]] && echo 'vcpkg-configuration.json') \
@@ -397,10 +436,8 @@ jobs:
397436
| { repository, reference, baseline }
398437
| del(.. | nulls)
399438
] | sort')
400-
[[ $RUNNER_DEBUG -eq 1 ]] && echo "$registries" || true
401-
if [[ $registries != '[]' ]]; then
402-
(echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
403-
fi
439+
[[ $RUNNER_DEBUG != 1 ]] || echo "$registries"
440+
[[ $registries == '[]' ]] || (echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
404441
fi
405442
406443
- name: 'Tools: Restore'
@@ -594,11 +631,7 @@ jobs:
594631
"$next" >> "$2"
595632
next=$(egrep -i '^link: ' "$2.headers" | grep -P -i -o '(?<=<)([\S]*)(?=>; rel="next")') || [[ $? == 1 ]]
596633
done
597-
if [[ $RUNNER_DEBUG -eq 1 ]]; then
598-
echo "::group::$1"
599-
cat "$2"
600-
echo "::endgroup::"
601-
fi
634+
[[ $RUNNER_DEBUG != 1 ]] || echo "::group::$1" && cat "$2" echo "::endgroup::"
602635
}
603636
604637
stamp=$(jq -n -r 'now')
@@ -610,11 +643,7 @@ jobs:
610643
load_paged "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls?state=open" pulls.json
611644
jq -r '.[] | .number | "refs/pull/" + (. | tostring) + "/merge" | @json' pulls.json >> branch-names.json
612645
613-
if [[ $RUNNER_DEBUG -eq 1 ]]; then
614-
echo "::group::Active Branches"
615-
cat branch-names.json
616-
echo "::endgroup::"
617-
fi
646+
[[ $RUNNER_DEBUG != 1 ]] || echo "::group::Active Branches" && cat branch-names.json && echo "::endgroup::"
618647
619648
jq -r --slurpfile branches branch-names.json --argjson stamp "$stamp" '
620649
.actions_caches
@@ -632,7 +661,7 @@ jobs:
632661
' caches.json \
633662
| while IFS=$'\t' read sequence cache_id cache_key cache_ref cache_created cache_last_accessed; do
634663
if [[ -n $sequence ]]; then
635-
if [[ $sequence -eq 0 ]]; then
664+
if [[ $sequence == 0 ]]; then
636665
echo "## Clean Caches: Deleted Branches" >> $GITHUB_STEP_SUMMARY
637666
echo "| Branch | Key | Created | Last Accessed |" >> $GITHUB_STEP_SUMMARY
638667
echo "| --- | --- | --- | --- |" >> $GITHUB_STEP_SUMMARY
@@ -676,7 +705,7 @@ jobs:
676705
next=$(egrep -i '^link: ' caches.json.headers | grep -P -i -o '(?<=<)([\S]*)(?=>; rel="next")') || [[ $? == 1 ]]
677706
done
678707
679-
if [[ 1 == 1 || $RUNNER_DEBUG -eq 1 ]]; then
708+
if [[ $RUNNER_DEBUG == 1 ]]; then
680709
echo "::debug::stamp=$(jq -n -r --argjson stamp "$stamp" '$stamp | gmtime | strftime("%Y-%m-%d %H:%M:%S")')"
681710
echo "::group::$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/caches?ref=$ref"
682711
cat caches.json
@@ -712,7 +741,7 @@ jobs:
712741
' caches.json \
713742
| while IFS=$'\t' read sequence cache_id cache_key cache_ref cache_created cache_last_accessed; do
714743
if [[ -n $sequence ]]; then
715-
if [[ $sequence -eq 0 ]]; then
744+
if [[ $sequence == 0 ]]; then
716745
echo "## Clean Caches: Stale Caches" >> $GITHUB_STEP_SUMMARY
717746
echo "| Branch | Key | Created | Last Accessed |" >> $GITHUB_STEP_SUMMARY
718747
echo "| --- | --- | --- | --- |" >> $GITHUB_STEP_SUMMARY

.github/workflows/run-codeql.yml

+33-25
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ name: CodeQL
1616
on:
1717
workflow_call:
1818
inputs:
19+
version:
20+
description: Use actions of this version as workaround for https://github.com/actions/runner/issues/2417 (optional, defaults to latest release).
21+
type: string
1922
source-dir:
2023
description: The CMake source directory (optional, defaults to current directory).
2124
type: string
@@ -37,7 +40,7 @@ on:
3740
permissions: {}
3841

3942
concurrency:
40-
group: run-codeql-${{github.workflow}}-${{github.event_name}}-${{github.ref}}
43+
group: cmu-codeql-${{github.workflow}}-${{github.event_name}}-${{github.ref}}
4144
cancel-in-progress: true
4245

4346
jobs:
@@ -52,18 +55,37 @@ jobs:
5255

5356
steps:
5457
# Actions: Load
58+
- name: 'Actions: Get SHA'
59+
# Workaround for https://github.com/actions/runner/issues/2417
60+
id: actions-latest
61+
shell: bash
62+
env:
63+
VERSION: ${{inputs.version}}
64+
GITHUB_TOKEN: ${{github.token}}
65+
run: |
66+
if [[ -z $VERSION ]]; then
67+
VERSION=$(curl --no-progress-meter \
68+
-H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" \
69+
"$GITHUB_API_URL/repos/mbeckh/cmake-utils/releases/latest" \
70+
| jq -r '.tag_name')
71+
echo "Using latest release: $VERSION"
72+
fi
73+
(echo -n "sha=" && curl --no-progress-meter \
74+
-H "Accept: application/vnd.github.sha" -H "Authorization: Bearer $GITHUB_TOKEN" \
75+
"$GITHUB_API_URL/repos/mbeckh/cmake-utils/commits/$VERSION) >> $GITHUB_OUTPUT
76+
5577
- name: 'Actions: Restore'
5678
id: actions-restore
5779
uses: actions/cache/restore@v3
5880
with:
5981
path: cmake-utils
60-
key: cmu-cmake-utils-${{github.job_workflow_sha}}
82+
key: cmu-cmake-utils-${{steps.actions-latest.outputs.sha}} # should be: cmu-cmake-utils-${{github.job_workflow_sha}}
6183

6284
- name: 'Actions: Load'
6385
if: steps.actions-restore.outputs.cache-hit != 'true'
6486
shell: bash
6587
env:
66-
JOB_WORKFLOW_SHA: ${{github.job_workflow_sha}}
88+
JOB_WORKFLOW_SHA: ${{steps.actions-latest.outputs.sha}} # should be: ${{github.job_workflow_sha}}
6789
GITHUB_TOKEN: ${{github.token}}
6890
run: |
6991
curl -L --no-progress-meter -o "cmake-utils-$JOB_WORKFLOW_SHA.tar.gz" \
@@ -110,7 +132,7 @@ jobs:
110132
shell: bash
111133
working-directory: source${{inputs.source-dir != '.' && inputs.source-dir && '/' || ''}}${{inputs.source-dir != '.' && inputs.source-dir || ''}}
112134
run: |
113-
((echo "image-os=$ImageOS") & (echo "image-version=$ImageVersion")) >> $GITHUB_OUTPUT
135+
(echo "image-os=$ImageOS" && echo "image-version=$ImageVersion") >> $GITHUB_OUTPUT
114136
if [[ -f vcpkg.json ]]; then
115137
registries=$(jq --sort-keys $([[ -f vcpkg-configuration.json ]] && echo '--slurp') '.' \
116138
vcpkg.json $([[ -f vcpkg-configuration.json ]] && echo 'vcpkg-configuration.json') \
@@ -122,10 +144,8 @@ jobs:
122144
| { repository, reference, baseline }
123145
| del(.. | nulls)
124146
] | sort')
125-
[[ $RUNNER_DEBUG -eq 1 ]] && echo "$registries" || true
126-
if [[ $registries != '[]' ]]; then
127-
(echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
128-
fi
147+
[[ $RUNNER_DEBUG != 1 ]] || echo "$registries"
148+
[[ $registries == '[]' ]] || (echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
129149
fi
130150
131151
- name: 'Tools: Restore'
@@ -326,6 +346,7 @@ jobs:
326346
"$next" >> "$2"
327347
next=$(egrep -i '^link: ' "$2.headers" | grep -P -i -o '(?<=<)([\S]*)(?=>; rel="next")') || [[ $? == 1 ]]
328348
done
349+
[[ $RUNNER_DEBUG != 1 ]] || echo "::group::$1" && cat "$2" echo "::endgroup::"
329350
}
330351
331352
stamp=$(jq -n -r 'now')
@@ -337,20 +358,7 @@ jobs:
337358
load_paged "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls?state=open" pulls.json
338359
jq -r '.[] | .number | "refs/pull/" + (. | tostring) + "/merge" | @json' pulls.json >> branch-names.json
339360
340-
if [[ $RUNNER_DEBUG -eq 1 ]]; then
341-
echo "::group::$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/git/matching-refs/heads"
342-
cat branches.json
343-
echo "::endgroup::"
344-
echo "::group::$GITHUB_API_URL/repos/$GITHUB_REPOSITORY//pulls?state=open"
345-
cat pulls.json
346-
echo "::endgroup::"
347-
echo "::group::$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/caches"
348-
cat caches.json
349-
echo "::endgroup::"
350-
echo "::group::Active Branches"
351-
cat branch-names.json
352-
echo "::endgroup::"
353-
fi
361+
[[ $RUNNER_DEBUG != 1 ]] || echo "::group::Active Branches" && cat branch-names.json && echo "::endgroup::"
354362
355363
jq -r --slurpfile branches branch-names.json --argjson stamp "$stamp" '
356364
.actions_caches
@@ -368,7 +376,7 @@ jobs:
368376
' caches.json \
369377
| while IFS=$'\t' read sequence cache_id cache_key cache_ref cache_created cache_last_accessed; do
370378
if [[ -n $sequence ]]; then
371-
if [[ $sequence -eq 0 ]]; then
379+
if [[ $sequence == 0 ]]; then
372380
echo "## Clean Caches: Deleted Branches" >> $GITHUB_STEP_SUMMARY
373381
echo "| Branch | Key | Created | Last Accessed |" >> $GITHUB_STEP_SUMMARY
374382
echo "| --- | --- | --- | --- |" >> $GITHUB_STEP_SUMMARY
@@ -412,7 +420,7 @@ jobs:
412420
next=$(egrep -i '^link: ' caches.json.headers | grep -P -i -o '(?<=<)([\S]*)(?=>; rel="next")') || [[ $? == 1 ]]
413421
done
414422
415-
if [[ 1 == 1 || $RUNNER_DEBUG -eq 1 ]]; then
423+
if [[ $RUNNER_DEBUG == 1 ]]; then
416424
echo "::debug::stamp=$(jq -n -r --argjson stamp "$stamp" '$stamp | gmtime | strftime("%Y-%m-%d %H:%M:%S")')"
417425
echo "::group::$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/caches?ref=$ref"
418426
cat caches.json
@@ -448,7 +456,7 @@ jobs:
448456
' caches.json \
449457
| while IFS=$'\t' read sequence cache_id cache_key cache_ref cache_created cache_last_accessed; do
450458
if [[ -n $sequence ]]; then
451-
if [[ $sequence -eq 0 ]]; then
459+
if [[ $sequence == 0 ]]; then
452460
echo "## Clean Caches: Stale Caches" >> $GITHUB_STEP_SUMMARY
453461
echo "| Branch | Key | Created | Last Accessed |" >> $GITHUB_STEP_SUMMARY
454462
echo "| --- | --- | --- | --- |" >> $GITHUB_STEP_SUMMARY

.github/workflows/test.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
shell: bash
101101
working-directory: source/test
102102
run: |
103-
((echo "image-os=$ImageOS") & (echo "image-version=$ImageVersion")) >> $GITHUB_OUTPUT
103+
(echo "image-os=$ImageOS" && echo "image-version=$ImageVersion") >> $GITHUB_OUTPUT
104104
if [[ -f vcpkg.json ]]; then
105105
registries=$(jq --sort-keys $([[ -f vcpkg-configuration.json ]] && echo '--slurp') '.' \
106106
vcpkg.json $([[ -f vcpkg-configuration.json ]] && echo 'vcpkg-configuration.json') \
@@ -112,10 +112,8 @@ jobs:
112112
| { repository, reference, baseline }
113113
| del(.. | nulls)
114114
] | sort')
115-
[[ $RUNNER_DEBUG -eq 1 ]] && echo "$registries" || true
116-
if [[ $registries != '[]' ]]; then
117-
(echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
118-
fi
115+
[[ $RUNNER_DEBUG != 1 ]] || echo "$registries"
116+
[[ $registries == '[]' ]] || (echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
119117
fi
120118
121119
- name: 'Tools: Restore'
@@ -205,6 +203,7 @@ jobs:
205203
name: Build Workflow
206204
uses: ./.github/workflows/run-build.yml
207205
with:
206+
version: ${{github.sha}}
208207
source-dir: test
209208
pch: false
210209
test-args: --label-regex "^Run$"
@@ -218,6 +217,7 @@ jobs:
218217
name: CodeQL Workflow
219218
uses: ./.github/workflows/run-codeql.yml
220219
with:
220+
version: ${{github.sha}}
221221
source-dir: test
222222
secrets: inherit
223223
permissions:
@@ -257,7 +257,7 @@ jobs:
257257
next=$(egrep -i '^link: ' caches.json.headers | grep -P -i -o '(?<=<)([\S]*)(?=>; rel="next")') || [[ $? == 1 ]]
258258
done
259259
260-
if [[ 1 == 1 || $RUNNER_DEBUG -eq 1 ]]; then
260+
if [[ $RUNNER_DEBUG == 1 ]]; then
261261
echo "::debug::stamp=$(jq -n -r --argjson stamp "$stamp" '$stamp | gmtime | strftime("%Y-%m-%d %H:%M:%S")')"
262262
echo "::group::$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/caches?ref=$ref"
263263
cat caches.json
@@ -293,7 +293,7 @@ jobs:
293293
' caches.json \
294294
| while IFS=$'\t' read sequence cache_id cache_key cache_ref cache_created cache_last_accessed; do
295295
if [[ -n $sequence ]]; then
296-
if [[ $sequence -eq 0 ]]; then
296+
if [[ $sequence == 0 ]]; then
297297
echo "## Clean Caches: Stale Caches" >> $GITHUB_STEP_SUMMARY
298298
echo "| Branch | Key | Created | Last Accessed |" >> $GITHUB_STEP_SUMMARY
299299
echo "| --- | --- | --- | --- |" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)