-
Notifications
You must be signed in to change notification settings - Fork 61
145 lines (122 loc) · 4.96 KB
/
end-to-end-tests.yaml
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
# The workflow can be triggered manually.
# It will build and deploy Klaw and run E2E tests against it.
# The E2E test is very basic and only makes sure that the app
# including Coral is built successfully.
name: E2E tests
on:
- workflow_dispatch
- workflow_call
jobs:
end-to-end-tests:
permissions:
actions: write
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set Node and pnpm versions
id: versions
working-directory: ./e2e
shell: bash
run: |
NODE_VERSION=$(jq -r '.engines.node' package.json)
PNPM_VERSION=$(jq -r '.engines.pnpm' package.json)
echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_OUTPUT
echo "PNPM_VERSION=$PNPM_VERSION" >> $GITHUB_OUTPUT
- name: Setup node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: ${{ steps.versions.outputs.NODE_VERSION }}
# PNPM needs to be available for coral in the build
- name: Setup pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: ${{ steps.versions.outputs.PNPM_VERSION }}
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Set up JDK
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 20
distribution: 'temurin'
cache: maven
- name: Build Klaw
working-directory: ./e2e
run: pnpm __build-klaw
# @TODO: make sure Klaw always runs on a predictable address
# then this step is unnecessary
- name: Get container network address
id: containerIp
shell: bash
run: |
container_name="klaw-core"
container_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_name")
if [ -n "$container_ip" ]; then
echo "Container is running at IP address: $container_ip"
echo "CONTAINER_IP=$container_ip" >> $GITHUB_OUTPUT
else
echo "Container not found or not running"
exit 1
fi
# This step may be brittle. The service in the container seems not to
# be immediately ready to accept connections, so the retry makes sure
# we're giving it (hopefully) enough time to be ready.
- name: Make sure Klaw is reachable
run: |
retries=5 # Number of retries
interval=5 # Initial retry interval in seconds
max_interval=30 # Max retry interval in seconds
success=false
echo "Check that Klaw is running on ${{ steps.containerIp.outputs.CONTAINER_IP}}:9097"
for ((i = 0; i < retries; i++)); do
if curl --fail --silent "${{ steps.containerIp.outputs.CONTAINER_IP}}:9097"; then
success=true
break
fi
# Sleep before the next retry with exponential backoff
sleep $interval
interval=$((interval * 2))
# Ensure the interval doesn't exceed the maximum
if [ $interval -gt $max_interval ]; then
interval=$max_interval
fi
done
if [ "$success" = false ]; then
echo "Klaw is not reachable 😭"
exit 1
fi
- name: Install dependencies
working-directory: ./e2e
run: pnpm install
- name: Install Playwright browsers
working-directory: ./e2e
run: pnpm playwright install --with-deps chromium
- name: Run Playwright tests
id: playwright-test-run
working-directory: ./e2e
run: BASE_URL=http://${{ steps.containerIp.outputs.CONTAINER_IP }}:9097 pnpm __test
- name: Upload Playwright artifacts
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
# Upload whether steps before where a failure, but only when the playwright tests did run
# This way we make sure we don't attempt to upload files that are not there, bc.
# for example the build has failed.
if: ${{ always() && steps.playwright-test-run.status == 'completed' }}
with:
name: playwright-report
path: playwright-report/
retention-days: 5
- name: Teardown Klaw
if: always()
run: docker-scripts/klaw-docker.sh --destroy