V2 #9
Workflow file for this run
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: Go Tests | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'rigour/**' | |
| - '.github/workflows/go-tests.yml' | |
| pull_request: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'rigour/**' | |
| jobs: | |
| test: | |
| name: Test Go Services | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| go-version: ['1.21', '1.22'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache-dependency-path: rigour/go.sum | |
| - name: Verify dependencies | |
| working-directory: ./rigour | |
| run: | | |
| go mod verify | |
| go mod download | |
| - name: Run go vet | |
| working-directory: ./rigour | |
| run: go vet ./... | |
| - name: Run go fmt check | |
| working-directory: ./rigour | |
| run: | | |
| fmt_output=$(gofmt -l .) | |
| if [ -n "$fmt_output" ]; then | |
| echo "The following files are not formatted:" | |
| echo "$fmt_output" | |
| exit 1 | |
| fi | |
| - name: Install staticcheck | |
| run: go install honnef.co/go/tools/cmd/staticcheck@latest | |
| - name: Run staticcheck | |
| working-directory: ./rigour | |
| run: staticcheck ./... | |
| - name: Run tests | |
| working-directory: ./rigour | |
| run: | | |
| go test -v -race -coverprofile=coverage.out -covermode=atomic ./... | |
| - name: Generate coverage report | |
| working-directory: ./rigour | |
| run: go tool cover -html=coverage.out -o coverage.html | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./rigour/coverage.out | |
| flags: unittests | |
| name: codecov-rigour | |
| fail_ci_if_error: false | |
| - name: Upload coverage artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report-go${{ matrix.go-version }} | |
| path: rigour/coverage.html | |
| lint: | |
| name: Lint Go Code | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| cache-dependency-path: rigour/go.sum | |
| - name: Run golangci-lint | |
| uses: golangci/golangci-lint-action@v4 | |
| with: | |
| version: latest | |
| working-directory: rigour | |
| args: --timeout=5m | |
| build: | |
| name: Build Docker Images | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 |