|
| 1 | +name: Base Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +jobs: |
| 7 | + test: |
| 8 | + name: Test (${{ matrix.os }}) |
| 9 | + runs-on: ${{ matrix.os }}-latest |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + os: [ubuntu, macos] |
| 14 | + env: |
| 15 | + MISE_PROFILE: cicd |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v6 |
| 20 | + |
| 21 | + - name: Use mise to install dependencies |
| 22 | + uses: jdx/mise-action@v3 |
| 23 | + with: |
| 24 | + version: 2025.12.13 |
| 25 | + experimental: true |
| 26 | + env: |
| 27 | + # Adding token here to reduce the likelihood of hitting rate limit issues. |
| 28 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + |
| 30 | + - id: go-cache-paths |
| 31 | + run: | |
| 32 | + echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" |
| 33 | + echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" |
| 34 | +
|
| 35 | + - name: Go Build Cache |
| 36 | + uses: actions/cache@v5 |
| 37 | + with: |
| 38 | + path: ${{ steps.go-cache-paths.outputs.go-build }} |
| 39 | + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}-${{ matrix.os }}-amd64 |
| 40 | + |
| 41 | + - name: Go Mod Cache |
| 42 | + uses: actions/cache@v5 |
| 43 | + with: |
| 44 | + path: ${{ steps.go-cache-paths.outputs.go-mod }} |
| 45 | + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}-${{ matrix.os }}-amd64 |
| 46 | + |
| 47 | + - name: Install go-junit-report |
| 48 | + run: | |
| 49 | + go install github.com/jstemmer/go-junit-report@latest |
| 50 | +
|
| 51 | + - name: Run Tests |
| 52 | + id: run-tests |
| 53 | + run: | |
| 54 | + set -o pipefail |
| 55 | + go test -v ./... -timeout 45m | tee >(go-junit-report -set-exit-code > result.xml) |
| 56 | + shell: bash |
| 57 | + env: |
| 58 | + # Adding token here to reduce the likelihood of hitting rate limit issues. |
| 59 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + # Use shorter temp path on macOS to avoid path length issues with Git worktrees. |
| 61 | + # Default /var/folders/.../T/ paths are too long for Git's path resolution. |
| 62 | + TMPDIR: ${{ matrix.os == 'macos' && '/tmp' || '' }} |
| 63 | + |
| 64 | + - name: Upload Report (${{ matrix.os }}) |
| 65 | + uses: actions/upload-artifact@v6 |
| 66 | + with: |
| 67 | + name: test-report-${{ matrix.os }} |
| 68 | + path: result.xml |
| 69 | + |
| 70 | + - name: Display Test Results (${{ matrix.os }}) |
| 71 | + uses: mikepenz/action-junit-report@v6 |
| 72 | + if: always() |
| 73 | + with: |
| 74 | + report_paths: result.xml |
| 75 | + detailed_summary: 'true' |
| 76 | + include_time_in_summary: 'true' |
| 77 | + group_suite: 'true' |
| 78 | + |
0 commit comments