name: Build on: push: branches: [main] paths-ignore: - 'docs/**' - 'README.md' - 'LICENSE' - '*.md' pull_request: paths-ignore: - 'docs/**' - '*.md' concurrency: group: build-${{ github.ref }} cancel-in-progress: true # Node.js is installed at the start of every job so actions/cache@v4 # (which uses Node) can run. Installing Node costs ~10s; the resulting # Go module + apt cache restore typically saves 30-60s on warm runs. jobs: test: runs-on: go steps: - name: Install Node (required by actions/cache) run: | apt-get update >/dev/null apt-get install -y --no-install-recommends nodejs >/dev/null - name: Checkout env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git clone --no-checkout "https://x-access-token:${GITHUB_TOKEN}@git.okcu.io/${GITHUB_REPOSITORY}.git" /tmp/src git -C /tmp/src checkout "$GITHUB_SHA" cp -a /tmp/src/. . - name: Cache Go modules uses: actions/cache@v4 with: path: | ~/go/pkg/mod ~/.cache/go-build key: go-${{ runner.os }}-${{ hashFiles('**/go.sum') }} restore-keys: go-${{ runner.os }}- - name: Vet run: go vet ./... - name: Test with race run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... - name: Linux smoke build run: | mkdir -p bin go build -trimpath -ldflags="-s -w" -o bin/drover ./cmd/drover ./bin/drover --version build-windows: runs-on: go needs: test steps: - name: Install Node (required by actions/cache) run: | apt-get update >/dev/null apt-get install -y --no-install-recommends nodejs >/dev/null - name: Checkout env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git clone --no-checkout "https://x-access-token:${GITHUB_TOKEN}@git.okcu.io/${GITHUB_REPOSITORY}.git" /tmp/src git -C /tmp/src checkout "$GITHUB_SHA" cp -a /tmp/src/. . - name: Cache Go modules uses: actions/cache@v4 with: path: | ~/go/pkg/mod ~/.cache/go-build key: go-${{ runner.os }}-${{ hashFiles('**/go.sum') }} restore-keys: go-${{ runner.os }}- - name: Cross-compile drover.exe (windows/amd64) env: GOOS: windows GOARCH: amd64 CGO_ENABLED: '0' run: | SHORT_SHA="${GITHUB_SHA:0:7}" BUILD_DATE="$(date -u +%Y-%m-%d)" mkdir -p bin go build -trimpath -ldflags="-s -w \ -X main.Version=dev-${SHORT_SHA} \ -X main.Commit=${SHORT_SHA} \ -X main.BuildDate=${BUILD_DATE}" \ -o bin/drover.exe ./cmd/drover ls -la bin/ sha256sum bin/drover.exe