Skip to content

Commit 60b5832

Browse files
committed
Run E2E tests in CI
1 parent ae26b2f commit 60b5832

File tree

2 files changed

+187
-27
lines changed

2 files changed

+187
-27
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 186 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,222 @@
11
name: E2E Tests
22
run-name: E2E Tests
33
on:
4-
# Only allow manual triggers
5-
workflow_dispatch:
4+
pull_request:
5+
merge_group:
6+
push:
7+
branches:
8+
- master
9+
- branch/**
610

711
jobs:
8-
build:
9-
name: Build binaries
10-
if: ${{ !startsWith(github.head_ref, 'dependabot/') }}
12+
changes:
13+
name: Check for relevant changes
1114
runs-on: ubuntu-latest
1215

16+
permissions:
17+
pull-requests: read
18+
19+
outputs:
20+
changed: ${{ steps.changes.outputs.changed }}
21+
22+
steps:
23+
- name: Checkout
24+
if: ${{ github.event_name == 'merge_group' }}
25+
uses: actions/checkout@v6
26+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
27+
id: changes
28+
with:
29+
base: ${{ github.event.pull_request.base.ref || github.event.merge_group.base_ref }}
30+
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
31+
filters: |
32+
changed:
33+
- '.github/workflows/e2e-tests.yaml'
34+
- '**.go'
35+
- 'go.mod'
36+
- 'go.sum'
37+
- '**.rs'
38+
- 'Cargo.toml'
39+
- 'Cargo.lock'
40+
- 'e2e/**'
41+
- 'web/**'
42+
- 'package.json'
43+
- 'pnpm-lock.yaml'
44+
- 'build.assets/Makefile'
45+
- 'build.assets/Dockerfile*'
46+
- 'Makefile'
47+
48+
build:
49+
name: Build Teleport
50+
needs: changes
51+
if: ${{ needs.changes.outputs.changed == 'true' || github.event_name == 'push' }}
52+
runs-on: ubuntu-22.04-32core
53+
1354
permissions:
1455
contents: read
1556

1657
container:
17-
image: ghcr.io/gravitational/teleport-buildbox-centos7:teleport19-amd64
18-
env:
19-
GOCACHE: /tmp/gocache
58+
image: ghcr.io/gravitational/teleport-buildbox:teleport19
2059

2160
steps:
22-
- name: Checkout Teleport
23-
uses: actions/checkout@v6 # Cannot upgrade to v4 while this runs in centos:7 due to nodejs GLIBC incompatibility
61+
- name: Checkout
62+
uses: actions/checkout@v6
2463

2564
- name: Prepare workspace
2665
uses: ./.github/actions/prepare-workspace
2766

28-
- name: Run make
67+
- name: Get cache paths
68+
id: cache-paths
2969
run: |
30-
make binaries
70+
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
71+
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
72+
73+
- name: Restore Go cache
74+
uses: actions/cache/restore@v4
75+
with:
76+
path: |
77+
${{ steps.cache-paths.outputs.go-build }}
78+
${{ steps.cache-paths.outputs.go-mod }}
79+
key: go-build-${{ runner.os }}-${{ hashFiles('go.sum') }}
80+
restore-keys: go-build-${{ runner.os }}-
81+
82+
- name: Restore Cargo cache
83+
uses: actions/cache/restore@v4
84+
with:
85+
path: |
86+
~/.cargo/registry/cache
87+
~/.cargo/registry/index
88+
~/.cargo/git/db
89+
target
90+
tool/fdpass-teleport/target
91+
key: cargo-build-${{ runner.os }}-${{ hashFiles('Cargo.lock', 'tool/fdpass-teleport/Cargo.lock') }}
92+
restore-keys: cargo-build-${{ runner.os }}-
93+
94+
- name: Restore pnpm cache
95+
uses: actions/cache/restore@v4
96+
with:
97+
path: node_modules
98+
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
99+
restore-keys: pnpm-${{ runner.os }}-
100+
101+
- name: Build Teleport and tctl
102+
run: |
103+
make build/teleport & pid1=$!
104+
make build/tctl & pid2=$!
105+
wait $pid1 && wait $pid2
106+
107+
- name: Build e2e runner
108+
run: cd e2e/runner && go build -o e2e .
31109

32110
- name: Upload binaries
33-
uses: actions/upload-artifact@v3
111+
uses: actions/upload-artifact@v4
34112
with:
35-
name: build
36-
path: ${{ github.workspace }}/build/
113+
name: teleport-binaries
114+
path: |
115+
build/teleport
116+
build/tctl
117+
e2e/runner/e2e
37118
retention-days: 1
38119

120+
- name: Save Go cache
121+
if: github.event_name == 'push'
122+
uses: actions/cache/save@v4
123+
with:
124+
path: |
125+
${{ steps.cache-paths.outputs.go-build }}
126+
${{ steps.cache-paths.outputs.go-mod }}
127+
key: go-build-${{ runner.os }}-${{ hashFiles('go.sum') }}
128+
129+
- name: Save Cargo cache
130+
if: github.event_name == 'push'
131+
uses: actions/cache/save@v4
132+
with:
133+
path: |
134+
~/.cargo/registry/cache
135+
~/.cargo/registry/index
136+
~/.cargo/git/db
137+
target
138+
tool/fdpass-teleport/target
139+
key: cargo-build-${{ runner.os }}-${{ hashFiles('Cargo.lock', 'tool/fdpass-teleport/Cargo.lock') }}
140+
141+
- name: Save pnpm cache
142+
if: github.event_name == 'push'
143+
uses: actions/cache/save@v4
144+
with:
145+
path: node_modules
146+
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
147+
39148
test:
40149
name: E2E Tests
41-
needs: build
150+
needs: [changes, build]
151+
if: ${{ needs.changes.outputs.changed == 'true' || github.event_name == 'push' }}
42152
runs-on: ubuntu-latest
153+
154+
container:
155+
image: mcr.microsoft.com/playwright:v1.55.1-noble
156+
env:
157+
DOCKER_HOST: tcp://docker:2375
158+
159+
services:
160+
docker:
161+
image: docker:dind
162+
options: --privileged
163+
env:
164+
DOCKER_TLS_CERTDIR: ""
165+
ports:
166+
- 2375:2375
167+
43168
steps:
44169
- uses: actions/checkout@v6
45170

46-
- uses: actions/download-artifact@v6
171+
- name: Install Docker CLI
172+
run: |
173+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker.gpg
174+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu noble stable" > /etc/apt/sources.list.d/docker.list
175+
apt-get update && apt-get install -y docker-ce-cli
176+
177+
- name: Install pnpm
178+
run: corepack enable
179+
180+
- name: Install e2e dependencies
181+
working-directory: e2e
182+
run: pnpm install --frozen-lockfile
183+
184+
- uses: actions/download-artifact@v4
47185
with:
48-
name: build
49-
path: ${{ github.workspace }}/build/
186+
name: teleport-binaries
187+
path: ${{ github.workspace }}
50188

51189
- name: Chmod binaries
52190
run: |
53191
chmod +x build/teleport
54192
chmod +x build/tctl
55-
chmod +x build/tsh
193+
chmod +x e2e/runner/e2e
56194
57-
- name: Build Images
58-
run: |
59-
make -C e2e build
60-
- name: Run Tests
61-
run: |
62-
make test-e2e
195+
- name: Run tests
196+
run: e2e/runner/e2e --no-build --full
197+
env:
198+
E2E_CALLER_DIR: ${{ github.workspace }}
199+
200+
- name: Upload Playwright report
201+
uses: actions/upload-artifact@v4
202+
if: ${{ !cancelled() }}
203+
with:
204+
name: playwright-report
205+
path: e2e/playwright-report/
206+
retention-days: 7
207+
208+
- name: Upload test results
209+
uses: actions/upload-artifact@v4
210+
if: ${{ !cancelled() }}
211+
with:
212+
name: test-results
213+
path: e2e/test-results/
214+
retention-days: 7
215+
216+
- name: Upload Teleport logs
217+
uses: actions/upload-artifact@v4
218+
if: ${{ !cancelled() }}
219+
with:
220+
name: teleport-logs
221+
path: e2e/teleport.log
222+
retention-days: 7

e2e/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22
export E2E_CALLER_DIR="$PWD"
3-
cd "$(dirname "$0")/runner" && go build -o e2e . && exec ./e2e "$@"
3+
cd "$(dirname "$0")/runner" && go build -buildvcs=false -o e2e . && exec ./e2e "$@"

0 commit comments

Comments
 (0)