name: Dev Pipeline on: workflow_dispatch: workflow_call: env: GO_VERSION: '1.25' jobs: quick-checks: name: Formatting & Static Checks runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} - name: Cache Go modules uses: actions/cache@v3 with: path: | ~/go/pkg/mod ~/.cache/go-build key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-${{ env.GO_VERSION }}- - name: Check gofmt formatting run: | fmt_out=$(gofmt -l $(find . -name '*.go')) if [[ -n "$fmt_out" ]]; then echo "Following files need gofmt:" && echo "$fmt_out" exit 1 fi - name: Run go mod tidy check run: | go mod tidy git diff --exit-code go.mod go.sum - name: Run static vet run: go vet ./... unit-tests: name: Unit Tests runs-on: ubuntu-latest needs: quick-checks steps: - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} - name: Restore Go cache uses: actions/cache@v3 with: path: | ~/go/pkg/mod ~/.cache/go-build key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-${{ env.GO_VERSION }}- - name: Run targeted package tests run: | GOCACHE=$(pwd)/.gocache go test ./pkg/... ./internal/... -count=1 - name: Upload test cache (optional diagnostics) if: always() uses: actions/upload-artifact@v3 with: name: dev-unit-cache path: .gocache