diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8dbb30c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: ci + +# Minimal CI for pgrun-cli: tests, cross-platform build, lint, vulnerability scan. +# Action SHAs and tool versions are pinned (as in pgrundev/pgbot) so a release upstream cannot +# change what CI enforces without a commit here. Go comes from go.mod (go + toolchain lines). +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +jobs: + test: + name: vet + gofmt + unit tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version-file: go.mod + - run: go vet ./... + - name: gofmt + run: | + unformatted=$(gofmt -l cmd internal) + if [ -n "$unformatted" ]; then echo "gofmt needed:"; echo "$unformatted"; exit 1; fi + - run: go test -race ./... + + build: + name: build ${{ matrix.goos }}/${{ matrix.goarch }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + goos: [linux, darwin, windows] + goarch: [amd64, arm64] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version-file: go.mod + - name: build (same flags as the Makefile) + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: "0" + run: go build -trimpath -ldflags "-s -w" -o "bin/pgrun-$GOOS-$GOARCH" ./cmd/pgrun + + lint: + name: golangci-lint + govulncheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version-file: go.mod + - name: "golangci-lint (config: .golangci.yml)" + run: | + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.14.0 + "$(go env GOPATH)/bin/golangci-lint" run ./... + - name: govulncheck + run: | + go install golang.org/x/vuln/cmd/govulncheck@v1.9.0 + "$(go env GOPATH)/bin/govulncheck" ./... diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..8d88de5 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,28 @@ +# Minimal lint baseline for pgrun-cli (golangci-lint v2, default linters: errcheck, govet, +# ineffassign, staticcheck, unused). The exclusions are the accepted patterns of a CLI, not bugs: +# - writes to the user's terminal (fmt/tabwriter/io to stdout/stderr) and best-effort cleanup +# (Close, Remove, RemoveAll, waiting on a launched browser) are intentionally unchecked; +# - tests: unchecked fixture writes, and staticcheck's quick-fix style hints. +version: "2" +linters: + settings: + errcheck: + exclude-functions: + - fmt.Fprint + - fmt.Fprintf + - fmt.Fprintln + - io.WriteString + - (io.Writer).Write + - (io.Closer).Close + - (*os.File).Close + - (*text/tabwriter.Writer).Flush + - (net/http.ResponseWriter).Write + - (*os/exec.Cmd).Wait + - os.Remove + - os.RemoveAll + exclusions: + rules: + - path: _test\.go + linters: [errcheck] + - linters: [staticcheck] + text: "QF1002" diff --git a/internal/pgbot/pgbot.go b/internal/pgbot/pgbot.go index f3a5f78..861ef34 100644 --- a/internal/pgbot/pgbot.go +++ b/internal/pgbot/pgbot.go @@ -34,7 +34,7 @@ const MinVersion = "0.9.0" // PinnedVersion is what `pgrun bot install` downloads by default: the release // this pgrun was tested against. -const PinnedVersion = "0.9.0" +const PinnedVersion = "0.10.0" // SchemaMinVersion is the first pgbot release with `schema snapshot|diff|compare` // (the migration review `pgrun bot verify` needs). Until PinnedVersion reaches it, diff --git a/npm/pgrun/package.json b/npm/pgrun/package.json index 9b73d9c..0ace891 100644 --- a/npm/pgrun/package.json +++ b/npm/pgrun/package.json @@ -25,7 +25,7 @@ "README.md" ], "dependencies": { - "@pgbot/cli": "^0.9.0" + "@pgbot/cli": "^0.10.0" }, "optionalDependencies": { "@pgrun/linux-x64": "0.0.0-dev",