-
-
Notifications
You must be signed in to change notification settings - Fork 186
223 lines (183 loc) · 6.32 KB
/
Copy pathtest.yml
File metadata and controls
223 lines (183 loc) · 6.32 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
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Test
on:
push:
paths-ignore:
- "docs/**"
- "*.md"
pull_request:
paths-ignore:
- "docs/**"
- "*.md"
workflow_dispatch:
jobs:
test-nix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.24"
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Create Fake WebUI Sources
run: |
mkdir -p webui/dist
# Create an empty gzip file for testing
gzip -c /dev/null > webui/dist/index.html.gz
- name: Build
run: go build ./...
- name: Test
run: PATH=$(pwd):$PATH gotestsum ./... -- --race
test-webui:
runs-on: ubuntu-latest
env:
TZ: UTC
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: pnpm
cache-dependency-path: webui/pnpm-lock.yaml
- name: Install dependencies
run: cd webui && pnpm install --frozen-lockfile
# Runs compile-i18n (paraglide) first, then vitest.
- name: Test
run: cd webui && pnpm test
- name: Typecheck
run: cd webui && pnpm run check
test-e2e-web:
runs-on: ubuntu-latest
env:
# Not RCLONE_*: rclone reads RCLONE_VERSION as its --version flag.
E2E_RCLONE_VERSION: v1.69.1
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.24"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: pnpm
cache-dependency-path: webui/pnpm-lock.yaml
- name: Install dependencies
run: cd webui && pnpm install --frozen-lockfile
- name: Build WebUI
run: cd webui && pnpm run build
- name: Build backrest binary (embeds the real WebUI)
run: |
mkdir -p webui/e2e/.cache
go build -o webui/e2e/.cache/backrest ./cmd/backrest
# Keyed on the file that pins RequiredResticVersion; global-setup
# provisions restic into this directory on a cache miss.
- name: Cache restic
uses: actions/cache@v4
with:
path: webui/e2e/.cache/restic-data
key: restic-e2e-${{ hashFiles('internal/resticinstaller/resticinstaller.go') }}
- name: Cache playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ hashFiles('webui/pnpm-lock.yaml') }}
- name: Install playwright chromium
run: cd webui && pnpm exec playwright install --with-deps chromium
# restic's rclone backend spawns the `rclone` binary; the rclone-repo
# e2e spec skips itself if rclone is absent, so provision it for coverage.
- name: Cache rclone
id: cache-rclone
uses: actions/cache@v4
with:
path: webui/e2e/.cache/rclone-bin
key: rclone-${{ env.E2E_RCLONE_VERSION }}
- name: Install rclone
run: |
dest="$PWD/webui/e2e/.cache/rclone-bin"
if [ ! -x "$dest/rclone" ]; then
mkdir -p "$dest"
zip="rclone-${E2E_RCLONE_VERSION}-linux-amd64"
curl -fsSL "https://downloads.rclone.org/${E2E_RCLONE_VERSION}/${zip}.zip" -o /tmp/rclone.zip
unzip -j -o /tmp/rclone.zip "${zip}/rclone" -d "$dest"
chmod +x "$dest/rclone"
fi
echo "$dest" >> "$GITHUB_PATH"
- name: Run e2e tests
run: |
cd webui
E2E_SKIP_WEBUI_BUILD=1 E2E_BACKREST_BIN=$PWD/e2e/.cache/backrest pnpm run e2e
- name: Upload playwright report
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: |
webui/playwright-report/
webui/test-results/
test-win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.24"
- name: Create Fake WebUI Sources
run: |
New-Item -Path .\webui\dist-windows\index.html -ItemType File -Force
- name: Resolve latest restic version
shell: powershell
id: restic-version
run: |
$latest = Invoke-RestMethod -Uri "https://api.github.com/repos/restic/restic/releases/latest"
$tag = $latest.tag_name
if ($tag.StartsWith("v")) {
$tag = $tag.Substring(1)
}
echo "RESTIC_VERSION=$tag" >> $env:GITHUB_ENV
- name: Cache restic
id: cache-restic
uses: actions/cache@v3
with:
path: restic-bin
key: restic-windows-${{ env.RESTIC_VERSION }}
- name: Download restic
if: steps.cache-restic.outputs.cache-hit != 'true'
shell: powershell
run: |
$tag = $env:RESTIC_VERSION
$url = "https://github.com/restic/restic/releases/download/v$tag/restic_${tag}_windows_amd64.zip"
$output = "restic.zip"
$dest = "restic-bin"
New-Item -ItemType Directory -Force -Path $dest
Write-Host "Downloading $url..."
Invoke-WebRequest -Uri $url -OutFile $output
Expand-Archive $output -DestinationPath temp_extract -Force
$extracted = Get-ChildItem -Recurse -Path temp_extract -Filter "restic*.exe" | Select-Object -First 1
if ($extracted) {
Move-Item $extracted.FullName -Destination "$dest\restic.exe" -Force
} else {
Write-Error "Could not find restic.exe"
}
Remove-Item -Recurse -Force temp_extract
Remove-Item -Force $output
- name: Add restic to PATH
run: echo "$PWD\restic-bin" >> $env:GITHUB_PATH
- name: Build
run: go build ./...
- name: Test
run: go test ./...