Skip to content

Commit 2533066

Browse files
authored
Improve efficiency of CI workflow through several small changes (#1042)
Efficiency changes: - Most of the CI jobs don't need the full git history. We can remove `fetch-depth: 0` when calling `actions/checkout` in those jobs. - Remove `find`-`xargs` pipelines when calling linters. It adds complexity and is unlikely to result in performance improvements for small repos like most of ours. - Remove Scorecard data upload for debugging, because we never used it. - Run the pr-labeler workflow on `ubuntu-slim` runners.
1 parent 0c242e7 commit 2533066

3 files changed

Lines changed: 11 additions & 38 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,19 @@ jobs:
102102
steps:
103103
- name: Check out a copy of the git repository
104104
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
105-
with:
106-
fetch-depth: 0
107105

108106
- name: Run hadolint on Dockerfiles
109107
continue-on-error: ${{inputs.soft-linting == 'true'}}
110108
env:
111-
hadolint_version: 'sha256:e9dbf5113239ef2bf696d20c8f28d3019a47c26a38c98b89344d3e2846c4d5f8'
109+
sha: 'sha256:e9dbf5113239ef2bf696d20c8f28d3019a47c26a38c98b89344d3e2846c4d5f8'
112110
run: |
113111
echo '::add-matcher::.github/problem-matchers/hadolint.json'
114-
find . -name Dockerfile -print0 | \
115-
xargs -0 -r docker run --rm -i -v "${PWD}:/app" -w /app \
116-
--entrypoint /bin/hadolint \
117-
ghcr.io/hadolint/hadolint@${{env.hadolint_version}}
112+
shopt -s globstar
113+
files=(**/Dockerfile*)
114+
if [[ ${#files[@]} -gt 0 ]]; then
115+
docker run --rm -v "${PWD}:/app" -w /app \
116+
ghcr.io/hadolint/hadolint@${{env.sha}} /bin/hadolint "${files[@]}"
117+
fi
118118
119119
shell-lint:
120120
name: Shell script lint checks
@@ -124,8 +124,6 @@ jobs:
124124
steps:
125125
- name: Check out a copy of the git repository
126126
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
127-
with:
128-
fetch-depth: 0
129127

130128
- name: Install problem matcher
131129
run: echo '::add-matcher::.github/problem-matchers/shellcheck.json'
@@ -147,8 +145,6 @@ jobs:
147145
steps:
148146
- name: Check out a copy of the git repository
149147
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
150-
with:
151-
fetch-depth: 0
152148

153149
- name: Install yamllint
154150
run: |
@@ -159,10 +155,7 @@ jobs:
159155
continue-on-error: ${{inputs.soft-linting == 'true'}}
160156
run: |
161157
echo "::add-matcher::.github/problem-matchers/yamllint.json"
162-
# shellcheck disable=SC2038
163-
find . -not -path '*.github/workflows/*' \
164-
'(' -name '*.yaml' -o -name '*.yml' ')' | \
165-
xargs yamllint -f github
158+
yamllint -f github . CITATION.cff
166159
167160
bazel-lint:
168161
name: Bazel build lint checks
@@ -172,8 +165,6 @@ jobs:
172165
steps:
173166
- name: Check out a copy of the git repository
174167
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
175-
with:
176-
fetch-depth: 0
177168

178169
- name: Install Buildifier
179170
uses: jbajic/setup-buildifier@c558ee05c6f74ab5753ff794516750b4aadac296 # v1
@@ -184,9 +175,7 @@ jobs:
184175
continue-on-error: ${{inputs.soft-linting == 'true'}}
185176
run: |
186177
echo '::add-matcher::.github/problem-matchers/buildifier.json'
187-
# shellcheck disable=SC2038
188-
find . -name 'BUILD' -o -name '*.bzl' -o -name 'WORKSPACE' | \
189-
xargs buildifier -mode=diff -lint=warn
178+
buildifier -mode=diff -lint=warn -r .
190179
191180
action-lint:
192181
name: GitHub Actions lint checks
@@ -196,8 +185,6 @@ jobs:
196185
steps:
197186
- name: Check out a copy of the git repository
198187
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
199-
with:
200-
fetch-depth: 0
201188

202189
- name: Run actionlint
203190
continue-on-error: ${{inputs.soft-linting == 'true'}}

.github/workflows/pr-labeler.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
label-pr-size:
4949
if: github.repository_owner == 'quantumlib'
5050
name: Update PR size labels
51-
runs-on: ubuntu-24.04
51+
runs-on: ubuntu-slim
5252
timeout-minutes: 5
5353
permissions:
5454
contents: read

.github/workflows/scorecard-scanner.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ on:
3232

3333
# Allow manual invocation.
3434
workflow_dispatch:
35-
inputs:
36-
debug:
37-
description: 'Run with debugging options'
38-
type: boolean
39-
default: true
4035

4136
concurrency:
4237
# Cancel any previously-started but still active runs on the same branch.
@@ -73,19 +68,10 @@ jobs:
7368

7469
- name: Upload results to code-scanning dashboard
7570
# yamllint disable rule:line-length
76-
uses: github/codeql-action/upload-sarif@ba454b8ab46733eb6145342877cd148270bb77ab # codeql-bundle-v2.23.5
71+
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
7772
with:
7873
sarif_file: scorecard-results.sarif
7974

80-
- if: github.event.inputs.debug == true || runner.debug == true
81-
name: Upload results as artifacts to the workflow Summary page
82-
# yamllint disable rule:line-length
83-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
84-
with:
85-
name: Scorecard SARIF file
86-
path: scorecard-results.sarif
87-
retention-days: 5
88-
8975
# Scorecard currently (ver. 2.4.x) doesn't allow submissions from jobs having
9076
# steps that use "run:". To print to the summary, we need to use another job.
9177
write-summary:

0 commit comments

Comments
 (0)