feat(tests): run axe-core tests #38528
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"\nTesting http.*\n 0 violations found!\n", | |
"", | |
"".join(sys.stdin.readlines()), | |
re.S | re.DOTALL, | |
) | |
) | |
EOF | |
chmod +x axe.py | |
cat > axe.txt << EOF | |
"${{steps.axe.outputs.stdout}}" | |
"${{steps.axe.outputs.stderr}}" | |
EOF | |
cat axe.txt | 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 |