-
Notifications
You must be signed in to change notification settings - Fork 4
146 lines (138 loc) · 4.7 KB
/
test.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
name: "⚔ test"
on:
## Note that 'pull_request' workflows can't have permission to write
## to PRs from forked repositry. So we use a separate workflow to
## comment on the PR. Documentation for that:
## https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
pull_request:
types: [opened, synchronize]
jobs:
get-pr-number:
runs-on: ubuntu-latest
steps:
- name: Get PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
mkdir -p .reports
echo "$PR_NUMBER" > .reports/pr
- name: ⬆ Store PR number
uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-report
path: .reports
cypress-e2e:
strategy:
matrix:
resolution:
- 375x667 ## iphone-8
- 1024x768
runs-on: ubuntu-latest
env:
REPORT_PATH: .reports/mocha
steps:
- name: 🚚 Get code
uses: actions/checkout@v2
- name: 🚚 Get node
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: 🚚 Install dependencies
run: |
## Need to unshallow to allow making the version number from
## git history.
git fetch --unshallow --tags &&
npm install
- name: 🔨 Config
run: |
rm "public/config.sample.json"
export GITHUB_REF_NAME="dev3" ## Not ideal for test stability
echo "{
\"appName\": \"Monujo-CI-${GITHUB_REF_NAME}\",
\"lokapiDb\": \"odoo\",
\"lokapiHost\": \"${GITHUB_REF_NAME}.lokavaluto.fr\",
\"mapUrl\": \"https://carte.${GITHUB_REF_NAME}.lokavaluto.fr\",
\"logoUrl\": \"https://monujo.${GITHUB_REF_NAME}.lokavaluto.fr/img/logo.png\",
\"loginLogoUrl\": \"https://monujo.${GITHUB_REF_NAME}.lokavaluto.fr/img/logo.png\",
\"locales\": {
\"availableLanguages\": {
\"en-US\": {
\"label\": \"English (US)\"
},
\"fr-FR\": {
\"label\": \"Français (France)\",
\"url\": \"https://docker.0k.io/downloads/monujo.fr-FR.json\"
}
},
\"appStringsLanguage\": \"en-US\",
\"defaultLanguage\": \"en-US\",
\"preferNavigatorLanguage\": true
}
}" > public/config.json
cat public/config.json
- name: 🚚 Build
run: |
npm run build
- name: ⚔ Run Cypress tests
env:
M_RESOLUTION: ${{ matrix.resolution }}
## Unfortunately, neither secrets nor vars can hold these
## information for jobs run by forked repository (aka
## pull_requests). Let's note that this is not sensitive
## information.
CYPRESS_email: [email protected]
CYPRESS_password: dev
run: |
npx cypress run \
--config defaultCommandTimeout=15000,viewportWidth=${M_RESOLUTION/x/,viewportHeight=}
- name: ⚔ Collect mocha reports
if: always()
env:
M_RESOLUTION: ${{ matrix.resolution }}
run: |
mkdir -p "$REPORT_PATH/${M_RESOLUTION}"
mv .cypress/reports/*.json "$REPORT_PATH/${M_RESOLUTION}/"
- name: ⬆ Store mocha reports
uses: actions/upload-artifact@v3
if: always()
with:
name: mocha-report
path: .reports/mocha
cypress-report:
needs: cypress-e2e
if: always()
runs-on: ubuntu-latest
env:
MOCHA_REPORT_PATH: .reports/mocha
MERGE_REPORT_PATH: .reports/cypress-report
steps:
- name: 🚚 Get node
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: 🚚 Install dependencies
run: |
npm i mochawesome-merge mochawesome-report-generator
- name: ⬇ Retrieve mocha reports
uses: actions/download-artifact@v3
with:
name: mocha-report
path: .reports/mocha
- name: 📃 Prepare reports
run: |
mkdir -p "$MERGE_REPORT_PATH"
echo "=== Merging ==="
ls -l "$MOCHA_REPORT_PATH"/*/*.json
echo "==============="
npx mochawesome-merge "$MOCHA_REPORT_PATH"/*/*.json \
-o "$MOCHA_REPORT_PATH"/index.json &&
npx marge --charts=true --showPassed=false \
--saveJson --reportFilename=report-merge \
-o "$MERGE_REPORT_PATH" "$MOCHA_REPORT_PATH"/index.json
- name: ⬆ Store cypress reports
uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-report
path: .reports/cypress-report