-
Notifications
You must be signed in to change notification settings - Fork 57
203 lines (176 loc) · 7.27 KB
/
e2e.yml
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
name: E2E Testing
on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
env:
COMPOSE_PROJECT_NAME: "${{ github.run_id }}_playwright_1"
# Control testing parallelism
PARALLELISM: 10
jobs:
build-mattermost-plugin-calls:
runs-on: ubuntu-22.04
steps:
- name: e2e/checkout-mattermost-plugin-calls-repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: e2e/setup-go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: e2e/setup-node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: webapp/package-lock.json
- name: e2e/build-mattermost-plugin-calls
env:
MM_SERVICESETTINGS_ENABLEDEVELOPER: 1
run: make dist
- name: e2e/persist-mattermost-plugin-calls-package
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: mattermost-plugin-calls-package
path: ${{ github.workspace }}/dist/*.tar.gz
if-no-files-found: error
compression-level: 0
retention-days: 1
generate-matrix:
runs-on: ubuntu-22.04
outputs:
parallelism-matrix: ${{ steps.calculation.outputs.PARALLELISM }}
parallelism: ${{ env.PARALLELISM }}
steps:
- name: e2e/generate-e2e-matrix
id: calculation
run: |
RANGE=$(( ${{ env.PARALLELISM }}+1 ))
echo PARALLELISM=$(jq -n "{ run_id: [range(1;${RANGE})]}") > ${GITHUB_OUTPUT}
e2e-playwright-test:
runs-on: ubuntu-22.04
needs:
- build-mattermost-plugin-calls
- generate-matrix
env:
COMPOSE_PROJECT_NAME: playwright_tests
DOCKER_NETWORK: playwright_tests
CONTAINER_SERVER: playwright_tests_server
IMAGE_CALLS_OFFLOADER: mattermost/calls-offloader:v0.8.0
IMAGE_CALLS_RECORDER: mattermost/calls-recorder:v0.7.6
IMAGE_CALLS_TRANSCRIBER: mattermost/calls-transcriber:v0.5.0
IMAGE_SERVER: mattermostdevelopment/mattermost-enterprise-edition:master
IMAGE_CURL: curlimages/curl:8.7.1
CI_NODE_INDEX: ${{ matrix.run_id }}
CI_NODE_TOTAL: ${{ needs.generate-matrix.outputs.parallelism }}
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.parallelism-matrix) }}
steps:
- name: e2e/checkout-mattermost-plugin-calls-repo
uses: actions/checkout@v4
- name: e2e/checkout-mattermost-repo
uses: actions/checkout@v4
with:
repository: mattermost/mattermost
path: mattermost
- name: e2e/setup-docker-buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: e2e/setup-go
uses: actions/setup-go@v5
with:
go-version-file: mattermost/server/go.mod
- name: e2e/generate-configuration
working-directory: ./mattermost/server/scripts/config_generator
env:
OUTPUT_CONFIG: ${{ github.workspace }}/config/config.json
run: |
mkdir -p ${{ github.workspace }}/config
go run main.go
- name: e2e/patch-generated-configuration
env:
OUTPUT_CONFIG: ${{ github.workspace }}/config/config.json
run: |
cp ${OUTPUT_CONFIG} ${OUTPUT_CONFIG}.orig
jq -f ${{ github.workspace }}/e2e/overlay-config.jq ${OUTPUT_CONFIG}.orig > ${OUTPUT_CONFIG}
diff ${OUTPUT_CONFIG}.orig ${OUTPUT_CONFIG} || true
- name: e2e/download-mattermost-plugin-calls-package
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: mattermost-plugin-calls-package
path: dist
- name: e2e/docker-login
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
# Do not authenticate on Forks
if: "! github.event.pull_request.head.repo.fork"
with:
username: ${{ secrets.DOCKERHUB_DEV_USERNAME }}
password: ${{ secrets.DOCKERHUB_DEV_TOKEN }}
- name: e2e/prepare-server
env:
DOCKER_CLIENT_TIMEOUT: 120
COMPOSE_HTTP_TIMEOUT: 120
DOCKER_COMPOSE_FILE: ${{ github.workspace }}/e2e/docker/docker-compose.yaml
run: |
mkdir -p ${{ github.workspace }}/logs
mkdir -p ${{ github.workspace }}/config
mkdir -p ${{ github.workspace }}/dotenv
## Navigate to mattermost server build folder to spawn the environment
cd mattermost/server/build/
${{ github.workspace }}/e2e/scripts/prepare-server.sh
cd -
## Add extra environment variables for mattermost server
echo "MM_LICENSE=${{ secrets.MM_PLUGIN_CALLS_TEST_LICENSE }}" >> dotenv/app.private.env
echo "MM_FEATUREFLAGS_BoardsProduct=true" >> dotenv/app.private.env
echo "MM_SERVICEENVIRONMENT=test" >> dotenv/app.private.env
echo "MM_CALLS_JOB_SERVICE_URL=http://calls-offloader:4545" >> dotenv/app.private.env
sudo chown -R 2000:2000 ${{ github.workspace }}/logs
sudo chown -R 2000:2000 ${{ github.workspace }}/config
# Spawn mattermost server
echo "Spawning mattermost server ... "
docker run -d --quiet --name ${CONTAINER_SERVER} \
--net ${DOCKER_NETWORK} \
--net-alias mm-server \
--user mattermost:mattermost \
--env-file="${{ github.workspace }}/dotenv/app.private.env" \
-v ${{ github.workspace }}/config:/mattermost/config:rw \
-v ${{ github.workspace }}/logs:/mattermost/logs:rw \
${IMAGE_SERVER} \
sh -c "/mattermost/bin/mattermost server"
- name: e2e/build-e2e-image
working-directory: e2e
run: |
echo "Building playwright test image ... "
cp ${{ github.workspace }}/plugin.json plugin.json
docker build --quiet -t mm-playwright -f Playwright.Dockerfile .
- name: e2e/test
id: test
run: |
mkdir -p ${{ github.workspace }}/results
${{ github.workspace }}/e2e/scripts/run.sh
## Check if we have an early failures in order to upload logs
NUM_FAILURES=0
NUM_FAILURES=$((NUM_FAILURES + $(jq '.suites[].suites[].specs[].tests[] | last(.results[]) | select(.status != "passed").status' < ${{ github.workspace }}/results/pw-results-${{ matrix.run_id }}.json | wc -l)))
echo "FAILURES=${NUM_FAILURES}" >> ${GITHUB_OUTPUT}
sudo chown -R 1001:1001 ${{ github.workspace }}/logs
- name: e2e/persist-report-results
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: e2e-playwright-results-${{ matrix.run_id }}
path: ${{ github.workspace }}/results
compression-level: 0
retention-days: 1
- name: e2e/persist-report-logs
if: ${{ fromJson(steps.test.outputs.FAILURES) > 0 }}
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: e2e-playwright-logs-${{ matrix.run_id }}
path: ${{ github.workspace }}/logs
compression-level: 0
retention-days: 5