-
Notifications
You must be signed in to change notification settings - Fork 3
233 lines (201 loc) · 6.08 KB
/
ci.yml
File metadata and controls
233 lines (201 loc) · 6.08 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: generate-token
continue-on-error: true
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ steps.generate-token.outputs.token || github.token }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Verify dependencies
run: go mod verify
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: generate-token
continue-on-error: true
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ steps.generate-token.outputs.token || github.token }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Run unit tests
run: go test -short -v -race -coverprofile=coverage.out ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: timvw/wt
files: ./coverage.out
fail_ci_if_error: false
build:
name: Build and Cross-Compile
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Generate GitHub App token
id: generate-token
continue-on-error: true
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ steps.generate-token.outputs.token || github.token }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Build for all platforms
run: |
mkdir -p bin
# Native build
go build -o bin/wt .
# Cross-compile for all supported platforms
GOOS=linux GOARCH=amd64 go build -o bin/wt-linux-amd64 .
GOOS=linux GOARCH=arm64 go build -o bin/wt-linux-arm64 .
GOOS=darwin GOARCH=amd64 go build -o bin/wt-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build -o bin/wt-darwin-arm64 .
GOOS=windows GOARCH=amd64 go build -o bin/wt-windows-amd64.exe .
- name: Verify binaries
run: |
./bin/wt --help
ls -lh bin/
file bin/*
- name: Upload Linux binary
uses: actions/upload-artifact@v7
with:
name: wt-linux-amd64
path: bin/wt-linux-amd64
retention-days: 1
- name: Upload macOS ARM64 binary
uses: actions/upload-artifact@v7
with:
name: wt-darwin-arm64
path: bin/wt-darwin-arm64
retention-days: 1
- name: Upload Windows binary
uses: actions/upload-artifact@v7
with:
name: wt-windows-amd64
path: bin/wt-windows-amd64.exe
retention-days: 1
# Unified E2E tests using YAML scenarios
e2e:
name: E2E (${{ matrix.os }}, ${{ matrix.shell }})
runs-on: ${{ matrix.runner }}
needs: build
strategy:
fail-fast: false
matrix:
include:
# Linux
- os: linux
runner: ubuntu-latest
shell: bash
binary: wt-linux-amd64
- os: linux
runner: ubuntu-latest
shell: zsh
binary: wt-linux-amd64
# macOS
- os: macos
runner: macos-latest
shell: bash
binary: wt-darwin-arm64
- os: macos
runner: macos-latest
shell: zsh
binary: wt-darwin-arm64
# Windows
- os: windows
runner: windows-latest
shell: powershell
binary: wt-windows-amd64
- os: windows
runner: windows-latest
shell: pwsh
binary: wt-windows-amd64
steps:
- name: Generate GitHub App token
id: generate-token
continue-on-error: true
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ steps.generate-token.outputs.token || github.token }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Install zsh (Linux)
if: matrix.os == 'linux' && matrix.shell == 'zsh'
run: |
sudo apt-get update
sudo apt-get install -y zsh
- name: Download binary
uses: actions/download-artifact@v8
with:
name: ${{ matrix.binary }}
path: bin
- name: Prepare binary (Unix)
if: matrix.os != 'windows'
run: |
mv bin/${{ matrix.binary }} bin/wt
chmod +x bin/wt
./bin/wt --help
- name: Prepare binary (Windows)
if: matrix.os == 'windows'
run: |
mv bin/${{ matrix.binary }}.exe bin/wt.exe
./bin/wt.exe --help
- name: Run E2E tests
if: matrix.os != 'windows'
run: |
go run e2e/run.go --wt=bin/wt --shells=${{ matrix.shell }}
- name: Run E2E tests (Windows)
if: matrix.os == 'windows'
shell: pwsh
run: |
go run e2e/run.go --wt=bin/wt.exe --shells=${{ matrix.shell }}