Increase timeout to 5 min #182
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: '[Documentation] Accessibility Check' | |
# Adapted from https://docusaurus.io/docs/deployment | |
on: | |
workflow_dispatch: | |
# Run on Weekdays at 9:00 AM UTC, 4AM ET, 1:00 AM PT | |
schedule: | |
- cron: '0 9 * * 1,2,3,4,5' | |
push: | |
branches: | |
[chanel-8524-automation-accessibility-checks-number-issues] | |
jobs: | |
axe-scan: | |
name: Acessibility Check | |
runs-on: ubuntu-latest | |
outputs: | |
num_issues: ${{ steps.accessibility_check.outputs.num_issues }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Clean npm cache | |
run: npm cache clean --force | |
- name: Install Axe CLI globally | |
run: npm install -g @axe-core/cli@latest | |
- name: Update npm | |
run: npm install -g npm@latest | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: 'VAMobile/.nvmrc' | |
cache: yarn | |
cache-dependency-path: VAMobile/yarn.lock | |
- name: Install ChromeDriver | |
run: npm install -g [email protected] | |
- name: Test build | |
working-directory: VAMobile | |
run: | | |
yarn install --frozen-lockfile | |
cd documentation | |
yarn install --frozen-lockfile | |
yarn build | |
- name: Start web server | |
working-directory: VAMobile/documentation | |
run: | | |
yarn build | |
yarn serve & | |
npx wait-on http://localhost:3000 & | |
sleep 10 | |
- name: Check accessibility issues | |
id: accessibility_check | |
run: | | |
# Path to the downloaded sitemap file | |
sitemap_path="VAMobile/documentation/build/sitemap.xml" | |
# Counter for the number of accessibility issues detected | |
num_issues=0 | |
# Extract URLs from sitemap and iterate | |
for url in $(grep -o '<loc>[^<]*' "$sitemap_path" | sed 's/<loc>//'); do | |
if axe "$url" --chromedriver-path $(npm root -g)/chromedriver/bin/chromedriver --timeout=300000 --exit; then | |
echo "No accessibility issues found in $url" | |
else | |
echo "Accessibility issues found in $url" | |
echo "$url" >> accessibility_issues.txt | |
# Extract number of issues from axe output | |
issues=$(axe "$url" --chromedriver-path $(npm root -g)/chromedriver/bin/chromedriver --timeout=300000 | grep -oP '\d+ Accessibility issues detected' | grep -oP '\d+') | |
if [ -n "$issues" ]; then | |
num_issues=$((num_issues + issues)) | |
fi | |
fi | |
done | |
echo "Total Accessibility issues detected: $num_issues" | |
# Set output for number of issues | |
echo "num_issues=$num_issues" >> $GITHUB_OUTPUT | |
# Fail the workflow if accessibility issues are detected | |
if [ "$num_issues" -gt 0 ]; then | |
echo "Accessibility issues were detected." | |
exit 1 | |
else | |
echo "No accessibility issues were found." | |
fi | |
start_slack_thread: | |
name: Start Slack thread | |
if: ${{ failure() }} | |
needs: axe-scan | |
uses: ./.github/workflows/start_slack_thread.yml | |
secrets: inherit | |
with: | |
channel_name: va-mobile-build-alerts | |
message: 'Accessibility issues detected. Please review and fix. Build started by ${{ github.actor }}: (:git: `${{ github.ref_name }}`). See :thread: or <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|workflow run> for results. Number of accessibility issues detected: ${{ needs.axe-scan.outputs.num_issues }}' |