diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7535313..65354d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,26 @@ jobs: - run: go vet ./imessage/... ./ipc/... ./pkg/bbctl/... ./pkg/dbowner/... - run: go test ./imessage/... ./ipc/... ./pkg/bbctl/... ./pkg/dbowner/... + lint: + name: Lint (code since v0.1.0) + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v5 + with: + # --new-from-rev needs the v0.1.0 tag and the history after it. + fetch-depth: 0 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + # Headers only: type-checking the cgo packages needs olm.h and heif.h + # (rustpushgo.h is in the tree), not the built Rust library. + - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libolm-dev libheif-dev + - run: go mod tidy -diff + - uses: golangci/golangci-lint-action@v9 + with: + version: v2.15.0 + args: --new-from-rev=v0.1.0 + relay: name: Relay and extract-key build (macOS) runs-on: macos-15 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..d9c627b --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,17 @@ +version: "2" + +# CI passes --new-from-rev=v0.1.0, so only code written after the first +# release is checked. The code inherited from the corten-matrix snapshot is +# left as it was, which keeps the diff against the snapshot readable. +linters: + default: standard + settings: + staticcheck: + # golangci-lint's default set, plus QF1008 off: the connector spells + # out embedded fields (attMsg.WrappedMessage.ReplyGuid) on purpose. + checks: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-QF1008"] + +formatters: + enable: + - gofmt + - goimports diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9dc82ab..fcc9713 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,6 +30,9 @@ Security problems go through [SECURITY.md](SECURITY.md), not the issue tracker. - `scripts/macoun-build-linux.sh test` (inside the build image, see [docs/setup.md](docs/setup.md)) runs the macoun tests. CI runs the same script. +- CI also runs `golangci-lint` ([.golangci.yml](.golangci.yml)) and + `go mod tidy -diff`. Lint only reports code changed since v0.1.0, so a + corten-matrix file you touch is checked on your lines, not as a whole. Nothing in the test suite talks to Apple. If your change affects what is sent to Apple, say in the pull request how you checked it against a real account.