Reduce repetition in CI configuration #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| jobs: | |
| # Run unit tests and go vet in parallel using matrix | |
| test-unit-vet: | |
| name: ${{ matrix.job-name }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - job-name: "Unit" | |
| make-target: "test-unit" | |
| artifact-name: "unit-test-results" | |
| - job-name: "Go Vet" | |
| make-target: "vet" | |
| artifact-name: "vet-results" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| check-latest: true | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run ${{ matrix.job-name }} | |
| run: | | |
| if [ "${{ matrix.make-target }}" = "vet" ]; then | |
| go vet ./... | |
| else | |
| make ${{ matrix.make-target }} | |
| fi | |
| - name: Upload test results | |
| if: always() && matrix.make-target != 'vet' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact-name }} | |
| path: | | |
| cover.out | |
| bin/ | |
| retention-days: 7 | |
| # Integration tests need special setup, keep separate | |
| test-integration: | |
| name: Integration | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| check-latest: true | |
| cache: true | |
| - name: Install dependencies | |
| run: | | |
| # Download Go dependencies | |
| go mod download | |
| # Install Temporal CLI | |
| curl -sSf https://temporal.download/cli.sh | sh | |
| echo "$HOME/.temporalio/bin" >> "$GITHUB_PATH" | |
| # Install Go tools | |
| go install sigs.k8s.io/controller-tools/cmd/[email protected] | |
| go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | |
| - name: Install kubectl | |
| uses: azure/setup-kubectl@v3 | |
| with: | |
| version: 'latest' | |
| - name: Install Helm | |
| uses: azure/setup-helm@v3 | |
| with: | |
| version: 'v3.14.3' | |
| - name: Integration tests | |
| run: make test-integration | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: integration-test-results | |
| path: | | |
| cover.out | |
| bin/ | |
| retention-days: 7 |