Skip to content

Commit 6cfee3c

Browse files
committed
Enable read-only for sccache for non-repo builds.
This should provide some sort of build acceleration for PRs that don't have access to read_write. Bug: 432823450 Change-Id: I2af70dcfa2e9609bf5dba10d13aa07047cda2d94
1 parent 18cbe74 commit 6cfee3c

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.github/actions/sccache/action.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,29 @@ runs:
1010
- name: Install sccache
1111
shell: bash
1212
run: brew install sccache
13+
# - name: 'Set up Cloud SDK'
14+
# if: inputs.sccache_gcs_key == ''
15+
# uses: 'google-github-actions/setup-gcloud@v3'
16+
# with:
17+
# version: '>= 363.0.0'
1318
- name: Configure sccache
1419
shell: bash
1520
env:
1621
SCCACHE_GCS_KEY: ${{ inputs.sccache_gcs_key }}
1722
run: |
18-
printf "%s" "$SCCACHE_GCS_KEY" > "${HOME}/gcloud.json"
19-
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> $GITHUB_ENV
20-
echo "SCCACHE_GCS_KEY_PATH=${HOME}/gcloud.json" >> $GITHUB_ENV
21-
echo "SCCACHE_GCS_BUCKET=cobalt-sccache-tvos-bucket" >> $GITHUB_ENV
23+
if [[ -n "$SCCACHE_GCS_KEY" ]]; then
24+
# If we have a GCS key we use READ_WRITE
25+
printf "%s" "$SCCACHE_GCS_KEY" > "${HOME}/gcloud.json"
26+
echo "SCCACHE_GCS_KEY_PATH=${HOME}/gcloud.json" >> $GITHUB_ENV
27+
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> $GITHUB_ENV
28+
echo "SCCACHE_GCS_BUCKET=cobalt-sccache-tvos-bucket" >> $GITHUB_ENV
29+
else
30+
# Read only
31+
echo "SCCACHE_BUCKET=cobalt-sccache-tvos-bucket" >> $GITHUB_ENV
32+
echo "SCCACHE_ENDPOINT=https://storage.googleapis.com" >> $GITHUB_ENV
33+
echo "SCCACHE_S3_NO_CREDENTIALS=true" >> $GITHUB_ENV
34+
echo "SCCACHE_REGION=auto" >> $GITHUB_ENV
35+
fi
2236
echo "SCCACHE=1" >> $GITHUB_ENV
2337
echo "SCCACHE_IDLE_TIMEOUT=0" >> $GITHUB_ENV
2438
- name: Start sccache server

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ jobs:
438438
targets: ${{ needs.initialize.outputs.targets }}
439439
test_root_target: ${{ needs.initialize.outputs.test_root_target }}
440440
test_targets_json_file: out/${{ matrix.platform }}_${{ matrix.config }}/test_targets.json
441-
enable_sccache: ${{ needs.initialize.outputs.enable_sccache == 'true' && secrets.sccache_gcs_key != '' }}
441+
enable_sccache: ${{ needs.initialize.outputs.enable_sccache == 'true' }}
442442
sccache_gcs_key: ${{ secrets.sccache_gcs_key }}
443443

444444
- name: Release Package

0 commit comments

Comments
 (0)