-
Notifications
You must be signed in to change notification settings - Fork 57
145 lines (121 loc) · 4.36 KB
/
ci.yml
File metadata and controls
145 lines (121 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: '1.24'
- name: Build
run: go build ./...
- name: Test with race detection (Linux/macOS)
if: matrix.os != 'windows-latest'
run: go test -race -tags integration ./...
- name: Test (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
# go test on Windows can exit 1 due to temp .exe cleanup
# ("go: remove ...\.exe: Access is denied") even when all
# tests pass. Only suppress that specific pattern.
go test -tags integration ./... 2>&1 | Tee-Object -Variable testOut
$exitCode = $LASTEXITCODE
if ($exitCode -ne 0) {
$failed = $testOut | Select-String "^FAIL\s"
if ($failed) {
Write-Host "Tests failed:"
Write-Host ($failed -join "`n")
exit 1
}
$cleanup = $testOut | Select-String "go: remove .+\.exe: Access is denied"
if (-not $cleanup) {
Write-Host "go test failed with unknown error"
exit $exitCode
}
Write-Host "All tests passed (ignoring temp .exe cleanup error)"
exit 0
}
- name: Build with CGO disabled
run: go build ./...
env:
CGO_ENABLED: 0
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: '1.24'
- name: Test with coverage
# -p 1 serializes package execution to avoid ROBOREV_DATA_DIR race conditions
# between tests in different packages that modify this environment variable
run: go test -race -tags integration -p 1 -coverprofile=coverage.out ./...
- name: Upload coverage
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
file: coverage.out
continue-on-error: true
integration:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: roborev_test
POSTGRES_PASSWORD: roborev_test_password
POSTGRES_DB: roborev_test
ports:
- 5433:5432
options: >-
--health-cmd "pg_isready -U roborev_test -d roborev_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: '1.24'
- name: Run integration tests
run: go test -tags=postgres -v ./internal/storage/... -run Integration
env:
TEST_POSTGRES_URL: postgres://roborev_test:roborev_test_password@localhost:5433/roborev_test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: '1.24'
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.10.1
nix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: cachix/install-nix-action@2126ae7fc54c9df00dd18f7f18754393182c73cd # v31.9.1
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Check flake
run: nix flake check
- name: Build package
run: nix build
- name: Verify binaries
run: ./result/bin/roborev version
- name: Verify nix apps
run: nix run .#roborev -- version