Debian Codegraph @

.github/workflows/ci.yaml

raw
1 name: ci
2 on:
3 push:
4 branches:
5 - main
6 pull_request:
7 release:
8 types: [published]
9
10 permissions:
11 contents: read
12
13 jobs:
14 lint:
15 runs-on: ubuntu-latest-8-cores
16 steps:
17 - name: Checkout code
18 uses: actions/checkout@v6
19
20 - name: Setup Go
21 uses: actions/setup-go@v6
22 with:
23 go-version: 'stable'
24
25 - name: Install deps
26 shell: bash --noprofile --norc -x -eo pipefail {0}
27 run: |
28 go mod download -modfile=go_test.mod
29 go install honnef.co/go/tools/cmd/staticcheck@latest
30 go install github.com/client9/misspell/cmd/misspell@latest
31 go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
32
33 - name: Run linters
34 shell: bash --noprofile --norc -x -eo pipefail {0}
35 run: |
36 $(exit $(go fmt -modfile=go_test.mod ./... | wc -l))
37 go vet -modfile=go_test.mod ./...
38 GOFLAGS="-mod=mod -modfile=go_test.mod" staticcheck ./...
39 find . -type f -name "*.go" | xargs misspell -error -locale US
40 GOFLAGS="-mod=mod -modfile=go_test.mod" golangci-lint run --timeout 5m0s ./jetstream/...
41
42 test:
43 runs-on: ubuntu-latest-8-cores
44 # Run inside an alpine container on the same docker network as the
45 # tester service so the spawned NATS servers are reachable by service
46 # name (no host port publishing needed).
47 strategy:
48 matrix:
49 go: [ "1.26", "1.27" ]
50 include:
51 - go: "1.27"
52 coverage: true
53 container: golang:${{ matrix.go }}-alpine
54 services:
55 nats:
56 # Single source of truth for the tester image; the Makefile parses
57 # the tag from this line.
58 image: synadia/ntf-server:v0.0.7-nats-2.15.0
59 command: serve --advertise nats
60 options: >-
61 --name nats
62 --health-cmd "nc -z localhost 4222"
63 --health-interval 1s
64 --health-retries 30
65 env:
66 TESTER_NATS_URL: nats://nats:4222
67 CGO_ENABLED: "1"
68 steps:
69 # git must exist before checkout, otherwise actions/checkout falls
70 # back to the REST API and leaves no .git in the workspace.
71 - name: Install build deps
72 run: |
73 apk add --no-cache gcc libc-dev git make bash curl ca-certificates
74 go install github.com/mattn/goveralls@latest
75 go install github.com/wadey/gocovmerge@latest
76
77 - name: Checkout code
78 uses: actions/checkout@v6
79
80 - name: NoRace tests
81 shell: bash --noprofile --norc -x -eo pipefail {0}
82 run: |
83 go test -modfile=go_test.mod -v -run=TestNoRace -p=1 ./... --failfast -vet=off
84
85 - name: Test and coverage
86 shell: bash --noprofile --norc -x -eo pipefail {0}
87 run: |
88 if [ "${{ matrix.coverage }}" = "true" ]; then
89 ./scripts/cov.sh CI
90 else
91 go test -modfile=go_test.mod -race -v -p=1 ./... --failfast -vet=off -tags=internal_testing
92 fi
93
94 - name: Coveralls
95 if: matrix.coverage
96 uses: coverallsapp/github-action@v2
97 with:
98 file: acc.out