-
Notifications
You must be signed in to change notification settings - Fork 1k
210 lines (186 loc) · 5.76 KB
/
tests.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
204
205
206
207
208
209
210
name: Tests
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Lint markdown data
run: yarn --cwd=ci && node ci/tests-fiches.mjs
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.4.1
bundler-cache: true
- name: Lint Ruby with Rubocop
run: bundle exec rubocop
- name: Install npm dependencies
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- run: npm ci
- name: Check Javascript/JSON linting
run: npm run lint
- name: Unit tests
run: bundle exec rspec
#- name: Check data structure
# run: make validate
- name: Unit tests
run: bundle exec rspec
- name: "Check authors file name structure (first_name.last_name.md)"
run: |
if ls content/_authors | grep --line-regexp --invert-match '[a-z_.-]\+\.[a-z_.-]\+\.md'
then cat <<EOF
One or more authors do not have the expected structure.
Contact a website administrator if your generated author file breaks the validator.
Notes:
A dot (.) can only appear as a separator between the first and the last names.
Dashes in names are kept as-is.
Spaces are replaced by underscores (_).
File extension must be '.md'
EOF
exit 1
fi
- name: Check Jekyll configuration
run: bundle exec jekyll doctor
- name: Jekyll build
run: bundle exec jekyll build --trace
- name: Check HTML common mistakes
run: make html-proofer
- name: HTML5 Validator
uses: Cyb3r-Jak3/html5validator-action@master
with:
root: _site
skip_git_check: true
- name: Lint JSON API pages
run: bundle exec jsonlint _site/api/v*/*.json
- name: "Upload Artifact"
uses: actions/upload-artifact@v4
with:
name: _site
path: _site
retention-days: 1
- name: Wait for server to start
run: |
(bundle exec jekyll serve --no-watch --skip-initial-build)&
while ! curl --silent http://localhost:4000
do sleep 1
done
axe:
needs: [test]
runs-on: ubuntu-22.04
steps:
- name: Install
run: |
npm install -g @axe-core/cli
npm install -g chromedriver@132
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: _site
path: _site
- name: Run Axe CLI
id: axe
uses: mathiasvr/command-output@v1
continue-on-error: true
timeout-minutes: 10
with:
run: |
npx -s http-server _site -s &
sleep 10
axe $URL, \
$URL/approche/index.html, \
$URL/devenir-intrapreneur.html, \
$URL/manifeste.html, \
$URL/incubateurs/index.html, \
$URL/incubateurs/dinum.html, \
$URL/contact/index.html, \
$URL/stats/index.html, \
$URL/apropos/index.html, \
$URL/suivi/index.html, \
$URL/startups/index.html, \
$URL/startups/domifa.html, \
$URL/accessibilite/index.html \
--chromedriver-path="$(npm root -g)/chromedriver/bin/chromedriver"
echo "end"
killall -9 http-server
env:
URL: "http://127.0.0.1:8080"
- name: Test output 1
run: |
cat > axe.py << EOF
import sys
import re
print(
re.sub(
r"Testing http.*?[\n\s]*0 violations found!\s*",
"",
"".join(sys.stdin.readlines()),
count=re.S | re.DOTALL,
)
)
EOF
chmod +x axe.py
cat > axe.txt << EOF
${{steps.axe.outputs.stdout}}
${{steps.axe.outputs.stderr}}
EOF
echo "---"
cat axe.py
echo "---"
cat axe.txt | python axe.py
# - name: Test output 2
# run: |
# echo "AXE_LOG:"
# echo "$AXE_LOG"
# - name: Test output 3
# run: |
# # Process and save filtered output
# {
# echo 'AXE_DETAILS<<EOF'
# echo "$AXE_LOG" | sed -E 's/Testing http[^ ]*\n 0 violations found\!//'
# echo 'EOF'
# } >> "$GITHUB_ENV"
# - name: Test output 4
# run: |
# echo "AXE_DETAILS:"
# echo "$AXE_DETAILS"
# - name: Test output 5
# run: |
# # Check for violations and set error flag
# {
# echo 'AXE_ERROR<<EOF'
# if echo "$AXE_DETAILS" | grep -q "violations found"; then
# echo "1"
# else
# echo "0"
# fi
# echo 'EOF'
# } >> "$GITHUB_ENV"
# - name: Test output 6
# run: |
# # Debug output
# echo "AXE_ERROR:"
# echo "$AXE_ERROR"
- name: Comment pull request
if: ${{ env.AXE_ERROR }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: axe-core-comment
recreate: true
message: |
## ♿️ Axe report
Audited website : ${{ env.WEBSITE_TO_AUDIT }}
```
${{ env.AXE_DETAILS }}
```
*This report has been generated using [@axe-core/cli](https://github.com/dequelabs/axe-core-npm/blob/develop/packages/cli).*
- name: Exit pull request
if: ${{ env.AXE_ERROR }}
run: |
exit 1