-
Notifications
You must be signed in to change notification settings - Fork 600
105 lines (91 loc) · 3.37 KB
/
e2e.yml
File metadata and controls
105 lines (91 loc) · 3.37 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
name: Frontend e2e test
on:
push:
branches:
- "**"
pull_request:
types: [labeled, synchronize]
branches:
- "**"
schedule:
# Run at 2:00 AM UTC every day
# This should be later than the update time of `apache/apisix:dev`
# Ref: https://github.com/apache/apisix-docker/blob/master/.github/workflows/apisix_dev_push_docker_hub.yaml#L7C15-L7C16
- cron: '0 2 * * *'
repository_dispatch:
types: [e2e-test]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
# only run when e2e-test label is added, scheduled, workflow_dispatch, repository_dispatch
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'e2e-test')) || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' }}
timeout-minutes: 40
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get PR Labels
if: ${{ github.event_name == 'pull_request' }}
id: get-labels
uses: actions/github-script@v6
with:
script: |
const labels = context.payload.pull_request.labels.map(label => label.name);
core.setOutput("labels", labels.join(","));
- name: Set image label as environment variable
if: ${{ github.event_name == 'pull_request' }}
run: |
export LABELS=${{ steps.get-labels.outputs.labels }}
echo "LABELS=${LABELS}" >> $GITHUB_ENV
shell: bash
# ensure this in https://github.com/apache/infrastructure-actions/blob/main/actions.yml
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
- name: Install dependencies
run: |
pnpm install --frozen-lockfile
- name: Install Playwright Browsers
run: |
pnpm exec playwright install --with-deps
- name: Run e2e server
working-directory: ./e2e/server
run: |
docker compose up -d
- name: Waiting dashboard service to be healthy
working-directory: ./e2e/server
run: |
E2E_SERVER="dashboard-e2e"
TIMEOUT=30
timeout $TIMEOUT bash -c '
until [ "$(docker inspect --format="{{.State.Health.Status}}" $(docker compose ps -q '$E2E_SERVER'))" = "healthy" ]; do
echo "'$E2E_SERVER' is starting..."
sleep 5
done
' || (echo "$E2E_SERVER not healthy after $TIMEOUT seconds" && exit 1)
- name: Run e2e tests
run: |
pnpm e2e
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: test-results
path: apps/site-e2e/test-results/
retention-days: 7
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 7
- name: Print Components Logs
if: failure()
run: |
docker ps --format '{{.Names}}' | xargs -I{} bash -c "echo ================= {} ==================== && docker logs {} && echo ================= {} ===================="