Fix CI: use workspace with cloned deps, upgrade to golangci-lint-acti… #19
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Checkout dependencies | |
| run: | | |
| git clone --depth=1 https://github.com/GrayCodeAI/eyrie.git ../eyrie | |
| git clone --depth=1 https://github.com/GrayCodeAI/tok.git ../tok | |
| git clone --depth=1 https://github.com/GrayCodeAI/yaad.git ../yaad | |
| git clone --depth=1 https://github.com/GrayCodeAI/inspect.git ../inspect | |
| git clone --depth=1 https://github.com/GrayCodeAI/sight.git ../sight | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.26.1' | |
| - name: Download dependencies | |
| run: | | |
| cp go.work.ci go.work 2>/dev/null || cat > go.work << 'EOF' | |
| go 1.26.1 | |
| use . | |
| replace ( | |
| github.com/hawk/eyrie => ../eyrie | |
| github.com/GrayCodeAI/eyrie => ../eyrie | |
| github.com/GrayCodeAI/tok => ../tok | |
| github.com/GrayCodeAI/yaad => ../yaad | |
| github.com/GrayCodeAI/inspect => ../inspect | |
| github.com/GrayCodeAI/sight => ../sight | |
| ) | |
| EOF | |
| go mod download | |
| - name: Run tests | |
| run: go test -v -race -coverprofile=coverage.out ./... | |
| - name: Check coverage | |
| run: | | |
| go tool cover -func=coverage.out | tail -1 | |
| go tool cover -html=coverage.out -o coverage.html | |
| - name: Upload coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage | |
| path: coverage.html | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.26.1' | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v7 | |
| with: | |
| version: v2.1.0 | |
| args: --timeout 5m | |
| - name: govulncheck | |
| run: | | |
| go install golang.org/x/vuln/cmd/govulncheck@latest | |
| govulncheck ./... | |
| - name: Check formatting | |
| run: | | |
| if [ "$(gofmt -d . | wc -l)" -gt 0 ]; then | |
| echo "Code is not formatted. Run 'gofmt -w .'" | |
| gofmt -d . | |
| exit 1 | |
| fi | |
| - name: Check module tidiness | |
| run: | | |
| go mod tidy | |
| if [ -n "$(git diff --name-only go.mod go.sum)" ]; then | |
| echo "go.mod or go.sum is not tidy. Run 'go mod tidy'" | |
| exit 1 | |
| fi | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| strategy: | |
| matrix: | |
| goos: [linux, darwin, windows] | |
| goarch: [amd64, arm64] | |
| exclude: | |
| - goos: windows | |
| goarch: arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.26.1' | |
| - name: Build | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: 0 | |
| run: | | |
| go build -ldflags "-s -w -X main.Version=ci-test" -o hawk-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} . | |
| - name: Upload binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hawk-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: hawk-${{ matrix.goos }}-${{ matrix.goarch }}* |