|
| 1 | +name: build-and-test-darwin |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main] |
| 5 | + tags: |
| 6 | + - "v[0-9]+.[0-9]+.[0-9]+*" |
| 7 | + merge_group: |
| 8 | + pull_request: |
| 9 | + types: [opened, synchronize, reopened, labeled, unlabeled] |
| 10 | + branches: |
| 11 | + - main |
| 12 | +env: |
| 13 | + TEST_RESULTS: testbed/tests/results/junit/results.xml |
| 14 | + # Make sure to exit early if cache segment download times out after 2 minutes. |
| 15 | + # We limit cache download as a whole to 5 minutes. |
| 16 | + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 |
| 17 | + GOPROXY: https://goproxy1.cncf.selfactuated.dev,direct |
| 18 | + |
| 19 | +# Do not cancel this workflow on main. See https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/16616 |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + darwin-build-unittest-binary: |
| 26 | + if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Darwin') || github.event_name == 'push' || github.event_name == 'merge_group') }} |
| 27 | + runs-on: macos-14 |
| 28 | + timeout-minutes: 120 |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + - uses: actions/setup-go@v5 |
| 32 | + with: |
| 33 | + go-version: "~1.22.5" |
| 34 | + cache: false |
| 35 | + - name: Cache Go |
| 36 | + id: go-cache |
| 37 | + timeout-minutes: 5 |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: | |
| 41 | + ~/go/bin |
| 42 | + ~/go/pkg/mod |
| 43 | + key: go-build-cache-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 44 | + - name: Install dependencies |
| 45 | + if: steps.go-cache.outputs.cache-hit != 'true' |
| 46 | + run: make -j2 gomoddownload |
| 47 | + - name: Install Tools |
| 48 | + if: steps.go-cache.outputs.cache-hit != 'true' |
| 49 | + run: make install-tools |
| 50 | + - name: Build test binaries |
| 51 | + env: |
| 52 | + GOTESTARCH: amd64 |
| 53 | + run: make gobuildtest GROUP=cgo |
| 54 | + - name: Zip test binaries |
| 55 | + run: zip -r testbinaries.zip . --include \*builtunitetest.test |
| 56 | + - uses: actions/upload-artifact@v4 |
| 57 | + with: |
| 58 | + name: testbinaries |
| 59 | + path: ./testbinaries.zip |
| 60 | + retention-days: 1 |
| 61 | + darwin-unittest-matrix: |
| 62 | + if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Darwin') || github.event_name == 'push' || github.event_name == 'merge_group') }} |
| 63 | + needs: [darwin-build-unittest-binary] |
| 64 | + strategy: |
| 65 | + fail-fast: false |
| 66 | + matrix: |
| 67 | + os: [macos-12, macos-13] |
| 68 | + timeout-minutes: 30 |
| 69 | + runs-on: ${{ matrix.os }} |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + - uses: actions/setup-go@v5 |
| 73 | + with: |
| 74 | + go-version: "~1.22.5" |
| 75 | + cache: false |
| 76 | + - name: Install Tools |
| 77 | + if: steps.go-cache.outputs.cache-hit != 'true' |
| 78 | + run: make install-tools |
| 79 | + - uses: actions/download-artifact@v4 |
| 80 | + with: |
| 81 | + name: testbinaries |
| 82 | + - name: Unzip binaries to each module |
| 83 | + run: unzip testbinaries.zip |
| 84 | + - name: Run Unit Tests |
| 85 | + run: make -j2 gorunbuilttest GROUP=cgo |
| 86 | + darwin-unittest: |
| 87 | + if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Darwin') || github.event_name == 'push' || github.event_name == 'merge_group') }} |
| 88 | + runs-on: macos-latest |
| 89 | + needs: [darwin-unittest-matrix] |
| 90 | + steps: |
| 91 | + - name: Print result |
| 92 | + run: echo ${{ needs.darwin-unittest-matrix.result }} |
| 93 | + - name: Interpret result |
| 94 | + run: | |
| 95 | + if [[ success == ${{ needs.darwin-unittest-matrix.result }} ]] |
| 96 | + then |
| 97 | + echo "All matrix jobs passed!" |
| 98 | + else |
| 99 | + echo "One or more matrix jobs failed." |
| 100 | + false |
| 101 | + fi |
0 commit comments