-
Notifications
You must be signed in to change notification settings - Fork 31
128 lines (116 loc) · 4.22 KB
/
test.yml
File metadata and controls
128 lines (116 loc) · 4.22 KB
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
name: Test
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch:
permissions:
contents: write
issues: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false # Allow previous workflows’ clean-up steps to complete
jobs:
test:
name: Test
runs-on: ubuntu-latest
# Run if triggered manually, or for a non-draft PR
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
strategy:
matrix:
site: ["sites/site-with-errors"]
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Ruby
uses: ruby/setup-ruby@0481980f17b760ef6bca5e8c55809102a0af1e5a
with:
ruby-version: "3.4"
bundler-cache: true
working-directory: ${{ matrix.site }}
- name: Build Jekyll site (${{ matrix.site }})
shell: bash
working-directory: ${{ matrix.site }}
env:
JEKYLL_ENV: production
run: bundle exec jekyll build
- name: Start Puma (${{ matrix.site }})
shell: bash
working-directory: ${{ matrix.site }}
env:
TEST_USERNAME: ${{ secrets.TEST_USERNAME }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
run: |
set -euo pipefail
bundle exec puma -b tcp://127.0.0.1:4000 &
echo "Starting Puma on port 4000"
curl -fsS --retry 25 --retry-delay 1 --retry-all-errors -u "${TEST_USERNAME}:${TEST_PASSWORD}" "http://127.0.0.1:4000/" > /dev/null
echo "Puma has started"
- name: Generate cache key
id: cache_key
shell: bash
run: |
echo "cache_key=$(printf 'cached_results-%s-%s.json' "${{ matrix.site }}" "${{ github.ref_name }}" | tr -cs 'A-Za-z0-9._-' '_')" >> $GITHUB_OUTPUT
- name: Scan site (${{ matrix.site }})
uses: ./
with:
urls: |
http://127.0.0.1:4000/
http://127.0.0.1:4000/jekyll/update/2025/07/30/welcome-to-jekyll.html
http://127.0.0.1:4000/about/
http://127.0.0.1:4000/404.html
login_url: http://127.0.0.1:4000/
username: ${{ secrets.TEST_USERNAME }}
password: ${{ secrets.TEST_PASSWORD }}
repository: github/accessibility-scanner-testing
token: ${{ secrets.GH_TOKEN }}
cache_key: ${{ steps.cache_key.outputs.cache_key }}
- name: Retrieve cached results
uses: ./.github/actions/gh-cache/restore
with:
path: ${{ steps.cache_key.outputs.cache_key }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate scan results (${{ matrix.site }})
run: |
npm ci
npm run test
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
CACHE_PATH: ${{ steps.cache_key.outputs.cache_key }}
- name: Clean up issues and pull requests
if: ${{ always() }}
shell: bash
run: |
set -euo pipefail
if [[ ! -f "${{ steps.cache_key.outputs.cache_key }}" ]]; then
echo "Skipping 'Clean up issues and pull requests' (no cached results)."
exit 0
fi
jq -r '
(if type=="string" then fromjson else . end)
| .[] | .issue.url, .pullRequest.url
| select(. != null)
' "${{ steps.cache_key.outputs.cache_key }}" \
| while read -r URL; do
if [[ "$URL" == *"/pull/"* ]]; then
echo "Closing pull request: $URL"
gh pr close "$URL" || echo "Failed to close pull request: $URL"
elif [[ "$URL" == *"/issues/"* ]]; then
echo "Closing issue: $URL"
gh issue close "$URL" || echo "Failed to close issue: $URL"
else
echo "Skipping unrecognized url: $URL"
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Clean up cached results
if: ${{ always() }}
uses: ./.github/actions/gh-cache/delete
with:
path: ${{ steps.cache_key.outputs.cache_key }}
token: ${{ secrets.GITHUB_TOKEN }}