|
7 | 7 | - uses: actions/setup-python@v4
|
8 | 8 | with:
|
9 | 9 | python-version-file: 'swift/.python-version'
|
10 |
| - - name: Mount bazel cache |
11 |
| - uses: ./.github/actions/incremental-cache |
| 10 | + # FIXME: this is copy-pasted from .github/actions/cache-query-compilation, but we cannot factor it out to a common |
| 11 | + # composite action because of https://github.com/actions/runner/issues/2009 (cache fails to save in the post action |
| 12 | + # phase because its inputs were lost in the meantime) |
| 13 | + # calculate the merge-base with main, in a way that works both on PRs and pushes to main. |
| 14 | + - name: Calculate merge-base |
| 15 | + shell: bash |
| 16 | + if: ${{ github.event_name == 'pull_request' }} |
| 17 | + env: |
| 18 | + BASE_BRANCH: ${{ github.base_ref }} |
| 19 | + run: | |
| 20 | + MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ") |
| 21 | + echo "merge_base=$MERGE_BASE" >> $GITHUB_ENV |
| 22 | + - name: Restore read-only cache (PR) |
| 23 | + if: ${{ github.event_name == 'pull_request' }} |
| 24 | + uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6 |
12 | 25 | with:
|
13 |
| - path: bazel-repository-cache |
14 |
| - key: bazel-cache-${{ runner.os }}-${{ runner.arch }} |
15 |
| - - name: Mount bazel disk cache |
16 |
| - uses: ./.github/actions/incremental-cache |
| 26 | + path: 'bazel-cache' |
| 27 | + read-only: true |
| 28 | + key: bazel-pr-${{ github.sha }} |
| 29 | + restore-keys: | |
| 30 | + bazel-${{ github.base_ref }}-${{ env.merge_base }} |
| 31 | + bazel-${{ github.base_ref }}- |
| 32 | + bazel-main- |
| 33 | + - name: Fill cache (push) |
| 34 | + if: ${{ github.event_name != 'pull_request' }} |
| 35 | + uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6 |
17 | 36 | with:
|
18 |
| - path: bazel-disk-cache |
19 |
| - key: bazel-disk-cache-${{ runner.os }}-${{ runner.arch }} |
20 |
| - - name: Configure bazel cache |
| 37 | + path: 'bazel-cache' |
| 38 | + key: bazel-${{ github.ref_name }}-${{ github.sha }} # just fill on main |
| 39 | + restore-keys: | # restore the latest cache if the exact cache is unavailable, to speed up compilation. |
| 40 | + bazel-${{ github.ref_name }}- |
| 41 | + bazel-main- |
| 42 | + - name: Configure bazel |
21 | 43 | shell: bash
|
22 | 44 | run: |
|
23 |
| - mkdir bazel-repository-cache bazel-disk-cache |
24 |
| - echo build --repository_cache=bazel-repository-cache --disk_cache=bazel-disk-cache > local.bazelrc |
| 45 | + mkdir -p bazel-cache/{repository,disk} |
| 46 | + echo build --repository_cache=bazel-cache/repository --disk_cache=bazel-cache/disk > local.bazelrc |
25 | 47 | echo test --test_output=errors >> local.bazelrc
|
26 | 48 | - name: Print unextracted entities
|
27 | 49 | shell: bash
|
|
51 | 73 | if: ${{ github.event_name != 'pull_request' }}
|
52 | 74 | shell: bash
|
53 | 75 | run: |
|
54 |
| - find bazel-repository-cache bazel-disk-cache -atime +0 -type f -delete |
55 |
| - du -sh bazel-repository-cache bazel-disk-cache |
| 76 | + du -sh bazel-cache/* |
| 77 | + find bazel-cache -atime +0 -type f -delete |
| 78 | + du -sh bazel-cache/* |
0 commit comments