|
1 | 1 | name: Build Swift CodeQL pack
|
2 | 2 | description: Builds the Swift CodeQL pack
|
| 3 | +inputs: |
| 4 | + upload: |
| 5 | + description: Whether to upload the extractor pack |
| 6 | + default: true |
3 | 7 | runs:
|
4 | 8 | using: composite
|
5 | 9 | steps:
|
6 | 10 | - uses: bazelbuild/setup-bazelisk@v2
|
7 | 11 | - uses: actions/setup-python@v4
|
8 | 12 | with:
|
9 | 13 | python-version-file: 'swift/.python-version'
|
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: actions/cache/restore@v3 |
25 |
| - with: |
26 |
| - path: 'bazel-cache' |
27 |
| - key: bazel-pr-${{ github.sha }} |
28 |
| - restore-keys: | |
29 |
| - bazel-${{ github.base_ref }}-${{ env.merge_base }} |
30 |
| - bazel-${{ github.base_ref }}- |
31 |
| - bazel-main- |
32 |
| - - name: Fill cache (push) |
33 |
| - if: ${{ github.event_name != 'pull_request' }} |
34 |
| - uses: actions/cache@v3 |
35 |
| - with: |
36 |
| - path: 'bazel-cache' |
37 |
| - key: bazel-${{ github.ref_name }}-${{ github.sha }} # just fill on main |
38 |
| - restore-keys: | # restore the latest cache if the exact cache is unavailable, to speed up compilation. |
39 |
| - bazel-${{ github.ref_name }}- |
40 |
| - bazel-main- |
41 | 14 | - name: Configure bazel
|
42 | 15 | shell: bash
|
43 | 16 | run: |
|
44 |
| - mkdir -p bazel-cache/{repository,disk} |
45 |
| - echo build --repository_cache=bazel-cache/repository --disk_cache=bazel-cache/disk > local.bazelrc |
| 17 | + echo > local.bazelrc |
46 | 18 | echo test --test_output=errors >> local.bazelrc
|
47 |
| - # - name: Print unextracted entities |
48 |
| - # shell: bash |
49 |
| - # run: | |
50 |
| - # bazel run //swift/extractor/print_unextracted |
51 |
| - - uses: ./swift/actions/share-extractor-pack |
52 | 19 | - name: Build Swift extractor
|
53 | 20 | shell: bash
|
54 | 21 | run: |
|
|
63 | 30 | shell: bash
|
64 | 31 | run: |
|
65 | 32 | bazel test //swift/...
|
66 |
| - - name: Evict bazel cache |
67 |
| - if: ${{ github.event_name != 'pull_request' }} |
68 |
| - shell: bash |
69 |
| - run: | |
70 |
| - du -sh bazel-cache/* |
71 |
| - find bazel-cache -atime +0 -type f -delete |
72 |
| - du -sh bazel-cache/* |
| 33 | + - name: Upload |
| 34 | + if: inputs.upload == 'true' |
| 35 | + uses: ./swift/actions/upload-extractor-pack |
0 commit comments