-
Notifications
You must be signed in to change notification settings - Fork 1
211 lines (174 loc) · 6.08 KB
/
e2e.yml
File metadata and controls
211 lines (174 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
name: E2E (Web + CLI, shared image)
on:
push:
branches: [main]
pull_request:
jobs:
build-image:
runs-on: ubuntu-latest
env:
GATEWAY_IMAGE: rack-gateway-api:e2e-${{ github.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build gateway image (with web UI) and export
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: ${{ env.GATEWAY_IMAGE }}
build-args: |
COMMIT_SHA=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
load: false
outputs: type=docker,dest=${{ runner.temp }}/gateway-api.tar
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: gateway-image
path: ${{ runner.temp }}/gateway-api.tar
retention-days: 1
web-e2e:
runs-on: ubuntu-latest
needs: build-image
env:
WEB_PORT: 9447
GATEWAY_PORT: 9447
MOCK_OAUTH_PORT: 9345
MOCK_CONVOX_PORT: 6443
GATEWAY_DEBUG_OAUTH: "false"
CHECK_VITE_PROXY: "false"
GATEWAY_IMAGE: rack-gateway-api:e2e-${{ github.sha }}
E2E_DATABASE_URL: postgres://postgres:postgres@localhost:55432/gateway_test?sslmode=disable
WEB_E2E_SHARDS: 1
PLAYWRIGHT_WORKERS: 1
CGO_ENABLED: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Task
run: |
curl -sL https://taskfile.dev/install.sh | sh -s -- -b /usr/local/bin
task --version
- name: Install libfido2 dependencies
run: |
sudo apt-get update
sudo apt-get install -y libfido2-dev libudev-dev pkg-config
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.1"
- name: Download gateway image
uses: actions/download-artifact@v4
with:
name: gateway-image
path: ${{ runner.temp }}
- name: Load gateway image
run: |
docker load --input ${{ runner.temp }}/gateway-api.tar
docker image ls -a | grep rack-gateway-api || true
- name: Build mock services
run: task docker:build:mocks
- name: Pull dependent images
run: docker compose pull postgres || docker pull postgres:16-alpine
- name: Ensure database exists
run: task db:ensure
- name: Start stack (gateway serves UI)
run: task docker:test:up
- name: Wait for services
run: |
chmod +x scripts/wait-for-services.sh
WEB_UI_PATH='/app/' WEB_PORT=${GATEWAY_PORT} CHECK_VITE_PROXY=false bash scripts/wait-for-services.sh
- name: Diagnose endpoints
run: |
set -x
docker compose ps
curl -sv http://127.0.0.1:${GATEWAY_PORT}/api/v1/health || true
curl -sv http://127.0.0.1:${GATEWAY_PORT}/app/login -o /dev/null || true
- name: Install Playwright and deps
working-directory: web
run: |
bun install --frozen-lockfile
bunx playwright install --with-deps || bunx playwright install
- name: Run Web E2E
working-directory: web
run: bun run e2e
- name: Docker logs (on failure)
if: failure()
run: docker compose --profile test logs --no-color --timestamps
- name: Teardown
if: always()
run: task docker:down
cli-e2e:
runs-on: ubuntu-latest
needs: build-image
env:
TEST_GATEWAY_PORT: 9447
TEST_MOCK_OAUTH_PORT: 9345
TEST_MOCK_CONVOX_PORT: 6443
GATEWAY_TEST_IMAGE: rack-gateway-api:e2e-${{ github.sha }}
WEB_UI_PATH: "/app/"
CHECK_VITE_PROXY: false
CGO_ENABLED: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Task
run: |
curl -sL https://taskfile.dev/install.sh | sh -s -- -b /usr/local/bin
task --version
- name: Install libfido2 dependencies
run: |
sudo apt-get update
sudo apt-get install -y libfido2-dev libudev-dev pkg-config
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.25.7"
- name: Download gateway image
uses: actions/download-artifact@v4
with:
name: gateway-image
path: ${{ runner.temp }}
- name: Load gateway image
run: |
docker load --input ${{ runner.temp }}/gateway-api.tar
docker image ls -a | grep rack-gateway-api || true
- name: Build mock services
run: task docker:build:mocks
- name: Pull dependent images
run: docker compose pull postgres || docker pull postgres:16-alpine
- name: Ensure database exists
run: task db:ensure
- name: Start stack (gateway serves UI)
run: task docker:test:up
- name: Wait for services
run: |
GATEWAY_PORT=9447 WEB_PORT=9447 MOCK_OAUTH_PORT=9345 CHECK_VITE_PROXY=false ./scripts/wait-for-services.sh
- name: Install Convox CLI
run: |
set -euo pipefail
ARCH=$(uname -m)
URL="https://github.com/convox/convox/releases/latest/download/convox-linux"
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
URL="https://github.com/convox/convox/releases/latest/download/convox-linux-arm64"
fi
curl -fsSL "$URL" -o /tmp/convox
sudo mv /tmp/convox /usr/local/bin/convox
sudo chmod 755 /usr/local/bin/convox
convox version || true
- name: Run CLI E2E
run: GATEWAY_PORT=9447 MOCK_OAUTH_PORT=9345 MOCK_CONVOX_PORT=6443 E2E_DATABASE_NAME=gateway_test E2E_GATEWAY_SERVICE=gateway-api-test ./scripts/cli-e2e.sh
- name: Docker logs (on failure)
if: failure()
run: docker compose --profile test logs --no-color --timestamps
- name: Teardown
if: always()
run: task docker:down