|
| 1 | +name: "gha: macOS & Windows" |
| 2 | + |
| 3 | +# Build on pull requests and pushes to `main`. The PR builds will be |
| 4 | +# non-blocking for now, but that is configured elsewhere. |
| 5 | +on: |
| 6 | + # Start these builds on pushes (think "after the merge") too. Normally there |
| 7 | + # are no `ci-gha**` branches in our repository. The contributors to the repo |
| 8 | + # can create such branches when testing or troubleshooting builds. In such |
| 9 | + # branches we can disable builds (to speed up the testing) or add new ones, |
| 10 | + # without impacting the rest of the team. |
| 11 | + push: |
| 12 | + branches: [ 'ci-gha**', 'prepare-for-v3.0.0' ] |
| 13 | + # Start the build in the context of the target branch. This is considered |
| 14 | + # "safe", as the workflow files are already committed. These types of builds |
| 15 | + # have access to the secrets in the build, which we need to use the remote |
| 16 | + # caches (Bazel and sccache). |
| 17 | + pull_request_target: |
| 18 | + types: |
| 19 | + - opened |
| 20 | + - synchronize |
| 21 | + - reopened |
| 22 | + schedule: |
| 23 | + - cron: '0 5 * * 1,2,3,4,5' |
| 24 | + |
| 25 | +# Cancel in-progress runs of the workflow if somebody adds a new commit to the |
| 26 | +# PR or branch. That reduces billing, but it creates more noise about cancelled |
| 27 | +# jobs |
| 28 | +concurrency: |
| 29 | + group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }} |
| 30 | + cancel-in-progress: true |
| 31 | + |
| 32 | +jobs: |
| 33 | + debug: |
| 34 | + name: debug_job |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - name: debug_steps |
| 38 | + id: debug-steps |
| 39 | + run: | |
| 40 | + echo "event=${{ github.event_name }}" |
| 41 | + echo "assoc=${{ github.event.pull_request.author_association }}" |
| 42 | + echo "org=${{ github.organization }}" || true |
| 43 | + echo "user=${{ github.event.pull_request.user }}" || true |
| 44 | + echo "user_orgs=${{ github.event.pull_request.user.organizations_url }}" || true |
| 45 | +
|
| 46 | + pre-flight: |
| 47 | + # Save the `ref` of the pull request, so downstream jobs know what to checkout. |
| 48 | + environment: >- |
| 49 | + ${{ |
| 50 | + (github.event_name != 'pull_request_target' && 'internal') || |
| 51 | + (github.event.pull_request.head.repo.full_name == github.repository && 'internal') |
| 52 | + }} |
| 53 | + name: Save PR ref |
| 54 | + needs: [debug] |
| 55 | + if: >- |
| 56 | + ${{ |
| 57 | + ((github.event.pull_request.author_association == 'OWNER' || |
| 58 | + github.event.pull_request.author_association == 'MEMBER' || |
| 59 | + github.event.pull_request.author_association == 'COLLABORATOR') && |
| 60 | + github.event_name == 'pull_request_target') || |
| 61 | + github.event_name == 'push' || |
| 62 | + github.event_name == 'schedule' |
| 63 | +
|
| 64 | + }} |
| 65 | + runs-on: ubuntu-latest |
| 66 | + outputs: |
| 67 | + checkout-sha: ${{ steps.save-pull-request.outputs.sha }} |
| 68 | + steps: |
| 69 | + - name: Save Pull Request |
| 70 | + id: save-pull-request |
| 71 | + run: > |
| 72 | + echo "sha=${{ github.event.pull_request.head.sha || github.ref }}" >> $GITHUB_OUTPUT |
| 73 | +
|
| 74 | + # Run other jobs once the `pre-flight` job passes. When the `pre-flight` |
| 75 | + # job requires approval, these blocks all the other jobs. The jobs are defined |
| 76 | + # in separate files to keep the size of this file under control. Note how |
| 77 | + # the additional jobs inherit any secrets needed to use the remote caches and |
| 78 | + # receive what version to checkout as an input. |
| 79 | + macos-bazel: |
| 80 | + # Disabled |
| 81 | + if: false |
| 82 | + name: macOS-Bazel |
| 83 | + needs: [pre-flight] |
| 84 | + uses: ./.github/workflows/macos-bazel.yml |
| 85 | + with: |
| 86 | + checkout-ref: ${{ needs.pre-flight.outputs.checkout-sha }} |
| 87 | + bazel-cache-mode: 'READ_WRITE' |
| 88 | + execute-integration-tests: true |
| 89 | + secrets: inherit |
| 90 | + windows-bazel: |
| 91 | + # Disabled |
| 92 | + if: false |
| 93 | + name: Windows-Bazel |
| 94 | + needs: [pre-flight] |
| 95 | + uses: ./.github/workflows/windows-bazel.yml |
| 96 | + with: |
| 97 | + checkout-ref: ${{ needs.pre-flight.outputs.checkout-sha }} |
| 98 | + bazel-cache-mode: 'READ_WRITE' |
| 99 | + execute-integration-tests: true |
| 100 | + secrets: inherit |
| 101 | + macos-cmake: |
| 102 | + # Disabled |
| 103 | + if: false |
| 104 | + name: macOS-CMake |
| 105 | + needs: [pre-flight] |
| 106 | + uses: ./.github/workflows/macos-cmake.yml |
| 107 | + with: |
| 108 | + checkout-ref: ${{ needs.pre-flight.outputs.checkout-sha }} |
| 109 | + # Build the full matrix only on push events to the default branch, or |
| 110 | + # when PR gets the has a `gha:full-build` label, or when it had the |
| 111 | + # label already and it gets a new commit. |
| 112 | + full-matrix: |- |
| 113 | + ${{ |
| 114 | + github.event_name == 'schedule' || |
| 115 | + github.event_name == 'push' || |
| 116 | + contains(github.event.pull_request.labels.*.name, 'gha:full-build') |
| 117 | + }} |
| 118 | + sccache-mode: 'READ_WRITE' |
| 119 | + vcpkg-cache-mode: 'readwrite' |
| 120 | + execute-integration-tests: true |
| 121 | + secrets: inherit |
| 122 | + windows-cmake: |
| 123 | + name: Windows-CMake |
| 124 | + needs: [pre-flight] |
| 125 | + uses: ./.github/workflows/windows-cmake.yml |
| 126 | + with: |
| 127 | + checkout-ref: ${{ needs.pre-flight.outputs.checkout-sha }} |
| 128 | + # Build the full matrix only on push events to the default branch, or |
| 129 | + # when PR gets the has a `gha:full-build` label, or when it had the |
| 130 | + # label already and it gets a new commit. |
| 131 | + full-matrix: |- |
| 132 | + ${{ |
| 133 | + github.event_name == 'schedule' || |
| 134 | + github.event_name == 'push' || |
| 135 | + contains(github.event.pull_request.labels.*.name, 'gha:full-build') |
| 136 | + }} |
| 137 | + sccache-mode: 'READ_WRITE' |
| 138 | + vcpkg-cache-mode: 'readwrite' |
| 139 | + execute-integration-tests: true |
| 140 | + secrets: inherit |
0 commit comments