-
Notifications
You must be signed in to change notification settings - Fork 24
212 lines (185 loc) · 5.83 KB
/
Copy pathcommit.yml
File metadata and controls
212 lines (185 loc) · 5.83 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: commit
on:
push:
branches:
- main
pull_request:
permissions:
id-token: write
contents: read
jobs:
linter:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.26.1"
- run: go mod download
- run: go mod verify
- run: go install tool
- uses: golangci/golangci-lint-action@v9
with:
version: v2.11.4
tests:
name: tests-${{ matrix.os }}
runs-on: ${{ matrix.os }}
# Check on all supported GitHub Actions OS
# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
# https://github.com/actions/runner-images
# https://github.com/actions/partner-runner-images
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-24.04
- ubuntu-22.04-arm
- ubuntu-24.04-arm
- windows-2022
- windows-2025
- macos-14
- macos-15
- macos-26
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.26.1"
- run: go mod download
- run: go test -v ./... -coverprofile=./coverage.txt -covermode=atomic -coverpkg=./...
- name: Archive code coverage results
if: matrix.os == 'ubuntu-24.04'
uses: actions/upload-artifact@v6
with:
name: code-coverage
path: coverage.txt
code_coverage:
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
needs: tests
permissions:
contents: read
actions: read
pull-requests: write # write permission needed to comment on PR
steps:
- uses: fgrosse/go-coverage-report@v1.2.0
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Required for goreleaser to get git history
- uses: actions/setup-go@v6
with:
go-version: "1.26.1"
- name: Set up QEMU for cross-compilation of Docker images
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Fix Segmentation fault of QEMU - https://github.com/docker/buildx/issues/1170
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -c yes
- run: go mod download
- run: go install tool
- run: go generate ./...
- name: Check for modified files
run: |
if ! git diff --quiet; then
echo "Error: Running 'go generate' modified files. Please commit these changes:"
git diff
exit 1
fi
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
id: goreleaser
with:
distribution: goreleaser
version: "~> v2"
args: release --skip=publish --clean --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test build Docker image (stage-bin)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: false
platforms: |
linux/arm64
linux/amd64
target: stage-bin
tags: test-build-bin
build-args: |
VERSION=${{ fromJSON(steps.goreleaser.outputs.metadata).version }}
COMMIT=${{ fromJSON(steps.goreleaser.outputs.metadata).commit }}
COMMIT_DATE=${{ fromJSON(steps.goreleaser.outputs.metadata).date }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test build Docker image (stage-release-all-in-one)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: false
platforms: |
linux/arm64
linux/amd64
target: stage-release-all-in-one
tags: test-build-release
build-args: |
VERSION=${{ fromJSON(steps.goreleaser.outputs.metadata).version }}
COMMIT=${{ fromJSON(steps.goreleaser.outputs.metadata).commit }}
COMMIT_DATE=${{ fromJSON(steps.goreleaser.outputs.metadata).date }}
cache-from: type=gha
cache-to: type=gha,mode=max
nix-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
- ubuntu-24.04-arm
- macos-15
- macos-26
steps:
- uses: actions/checkout@v6
- uses: DeterminateSystems/nix-installer-action@main
with:
determinate: false
- uses: DeterminateSystems/magic-nix-cache-action@v13
with:
use-flakehub: false
- name: Check flake
run: nix flake check --print-build-logs
- name: Build package
run: nix build -L .#default
- name: Run binary version check
run: ./result/bin/any-sync-bundle --version
nix-devshell:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: DeterminateSystems/nix-installer-action@main
with:
determinate: false
- uses: DeterminateSystems/magic-nix-cache-action@v13
with:
use-flakehub: false
- name: Check dev shell
run: |
nix develop --command go version
nix develop --command golangci-lint version
nix develop --command goreleaser --version
integration-test:
name: integration-test
runs-on: ubuntu-24.04
needs: build
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.26.1"
- run: go mod download
- name: Run integration tests
run: go test -v -tags=integration -timeout=10m ./integration/...