Skip to content

Commit 78cb7c2

Browse files
Merge pull request #1306 from l46kok:ci-improvement
PiperOrigin-RevId: 993854201
2 parents 3c4aa1b + 429d017 commit 78cb7c2

1 file changed

Lines changed: 45 additions & 24 deletions

File tree

‎.github/workflows/workflow.yml‎

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,28 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
1515
cancel-in-progress: true
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
Bazel-Build-Java8:
1922
runs-on: ubuntu-latest
2023
timeout-minutes: 30
2124
steps:
2225
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
2326
- run: echo "🐧 Job is running on a ${{ runner.os }} server!"
24-
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
27+
- run: echo "🔎 The name of your branch is ${GITHUB_REF} and your repository is ${GITHUB_REPOSITORY}."
2528
- name: Check out repository code
26-
uses: actions/checkout@v6
29+
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
30+
with:
31+
persist-credentials: false
32+
- name: Mark job start
33+
run: touch "$RUNNER_TEMP/job-start"
2734
- name: Setup Bazel
28-
uses: bazel-contrib/setup-bazel@0.18.0
35+
uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0
2936
with:
30-
# Avoid downloading Bazel every time.
31-
bazelisk-cache: true
3237
# Store build cache per workflow.
3338
disk-cache: ${{ github.workflow }}-${{ github.job }}
34-
# Share repository cache between workflows.
35-
repository-cache: true
3639
# Prevent PRs from polluting cache
3740
cache-save: ${{ github.event_name != 'pull_request' }}
3841
- name: Bazel Output Version
@@ -43,26 +46,35 @@ jobs:
4346
run: .github/workflows/unwanted_deps.sh
4447
- name: Cross-artifact Duplicate Classes Check
4548
run: .github/workflows/cross_artifact_dependencies_check.sh
46-
- run: echo "🍏 This job's status is ${{ job.status }}."
49+
- name: Prune disk cache entries not used by this job
50+
# Bazel bumps mtimes on use; drop stale entries so the saved cache doesn't grow unbounded.
51+
if: github.event_name != 'pull_request'
52+
run: |
53+
du -sh ~/.cache/bazel-disk
54+
find ~/.cache/bazel-disk -type f ! -newer "$RUNNER_TEMP/job-start" -delete
55+
du -sh ~/.cache/bazel-disk
56+
- run: echo "🍏 This job's status is ${JOB_STATUS}."
57+
env:
58+
JOB_STATUS: ${{ job.status }}
4759

4860
Bazel-Tests:
4961
runs-on: ubuntu-latest
5062
timeout-minutes: 30
5163
steps:
5264
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
5365
- run: echo "🐧 Job is running on a ${{ runner.os }} server!"
54-
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
66+
- run: echo "🔎 The name of your branch is ${GITHUB_REF} and your repository is ${GITHUB_REPOSITORY}."
5567
- name: Check out repository code
56-
uses: actions/checkout@v6
68+
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
69+
with:
70+
persist-credentials: false
71+
- name: Mark job start
72+
run: touch "$RUNNER_TEMP/job-start"
5773
- name: Setup Bazel
58-
uses: bazel-contrib/setup-bazel@0.18.0
74+
uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0
5975
with:
60-
# Avoid downloading Bazel every time.
61-
bazelisk-cache: true
6276
# Store build cache per workflow.
6377
disk-cache: ${{ github.workflow }}-${{ github.job }}
64-
# Share repository cache between workflows.
65-
repository-cache: true
6678
# Prevent PRs from polluting cache
6779
cache-save: ${{ github.event_name != 'pull_request' }}
6880
- name: Bazel Output Version
@@ -71,7 +83,16 @@ jobs:
7183
# Exclude codelab exercises as they are intentionally made to fail
7284
# Exclude maven conformance tests. They are only executed when there's version change.
7385
run: bazelisk test ... --deleted_packages=//codelab/src/test/codelab --test_output=errors --test_tag_filters=-conformance_maven --build_tag_filters=-conformance_maven
74-
- run: echo "🍏 This job's status is ${{ job.status }}."
86+
- name: Prune disk cache entries not used by this job
87+
# Bazel bumps mtimes on use; drop stale entries so the saved cache doesn't grow unbounded.
88+
if: github.event_name != 'pull_request'
89+
run: |
90+
du -sh ~/.cache/bazel-disk
91+
find ~/.cache/bazel-disk -type f ! -newer "$RUNNER_TEMP/job-start" -delete
92+
du -sh ~/.cache/bazel-disk
93+
- run: echo "🍏 This job's status is ${JOB_STATUS}."
94+
env:
95+
JOB_STATUS: ${{ job.status }}
7596

7697
# -- Start of Maven Conformance Tests (Ran only when there's version changes) --
7798
Maven-Conformance:
@@ -80,24 +101,24 @@ jobs:
80101
steps:
81102
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
82103
- run: echo "🐧 Job is running on a ${{ runner.os }} server!"
83-
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
104+
- run: echo "🔎 The name of your branch is ${GITHUB_REF} and your repository is ${GITHUB_REPOSITORY}."
84105
- name: Check out repository code
85-
uses: actions/checkout@v6
106+
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
107+
with:
108+
# Full history so changed-files doesn't need credentials to fetch more.
109+
fetch-depth: 0
110+
persist-credentials: false
86111
- name: Get changed files
87112
id: changed_file
88-
uses: tj-actions/changed-files@v47
113+
uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47.0.0
89114
with:
90115
files: publish/cel_version.bzl
91116
- name: Setup Bazel
92117
if: steps.changed_file.outputs.any_changed == 'true'
93-
uses: bazel-contrib/setup-bazel@0.18.0
118+
uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0
94119
with:
95-
# Avoid downloading Bazel every time.
96-
bazelisk-cache: true
97120
# Store build cache per workflow.
98121
disk-cache: ${{ github.workflow }}-${{ github.job }}
99-
# Share repository cache between workflows.
100-
repository-cache: true
101122
# Never write to the cache, strictly read-only
102123
cache-save: false
103124
- name: Verify Version Consistency

0 commit comments

Comments
 (0)