From cc6469a5027a5f923a9a8d731c2ed5c8ba1d28df Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 17:39:38 +0100 Subject: [PATCH 01/11] :green_heart: Update worklow to test accessibility Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 30 ++++++++++++++++++++++++++++++ pa11yci.json | 9 +++++++++ 2 files changed, 39 insertions(+) create mode 100644 pa11yci.json diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c8fbe49..898179f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -38,3 +38,33 @@ jobs: sass src/themes/chimera-nightsky.scss build/chimera-nightsky.css shell: bash working-directory: ./chimera-css + + accessibility-testing: + runs-on: ubuntu-latest + name: Testing accessibility + steps: + - name: Checkout source + uses: actions/checkout@v3 + + - name: Intall npm dependencies + run: | + npm ci + npm install -g sass + shell: bash + working-directory: ./apps/demo + + - name: Install GitHub CLI + run: sudo apt-get install -y gh + + - name: Run Pa11y accessibility tests and capture output + id: pa11y + run: | + pa11y-ci --config ./pa11yci.json > pa11y-output.txt + cat pa11y-output.txt + + - name: Post Pa11y results to PR + if: success() || failure() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr comment ${{ github.event.pull_request.number }} --body "$(cat pa11y-output.txt)" \ No newline at end of file diff --git a/pa11yci.json b/pa11yci.json new file mode 100644 index 0000000..edf1be2 --- /dev/null +++ b/pa11yci.json @@ -0,0 +1,9 @@ +{ + "defaults": { + "standard": "WCAG2AA", + "timeout": 30000 + }, + "urls": [ + "file://./apps/demo/index.html" + ] +} \ No newline at end of file From e35445ac606f8802542daae0ec0fa7be839d2d46 Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 17:43:52 +0100 Subject: [PATCH 02/11] :green_heart: Fix npm ci error Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 898179f..3949b83 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -48,7 +48,6 @@ jobs: - name: Intall npm dependencies run: | - npm ci npm install -g sass shell: bash working-directory: ./apps/demo From ffddf7f1180560347cde2349f384aa1629f04dbb Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 17:46:52 +0100 Subject: [PATCH 03/11] :green_heart: Forgot to install Pa11y hehe Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3949b83..e7d3637 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -46,9 +46,9 @@ jobs: - name: Checkout source uses: actions/checkout@v3 - - name: Intall npm dependencies + - name: Intall Pa11y-CI run: | - npm install -g sass + npm install -g pa11y-ci shell: bash working-directory: ./apps/demo From 348345fdf71a6d05ed7e5935db7f2913cfed2628 Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 17:53:23 +0100 Subject: [PATCH 04/11] :green_heart: Add permissions to workflow Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e7d3637..cef2b2f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,6 +10,10 @@ on: - "CONTRIBUTING.md" - "CODE_OF_CONDUCT.md" +permissions: + pull-requests: write + contents: read + jobs: compile-themes: runs-on: ubuntu-latest From f8dcb1883854aac62be69d15d769fbbdf5958e6e Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 18:01:57 +0100 Subject: [PATCH 05/11] :green_heart: Remove file creation & post straight into pr-comment Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index cef2b2f..931bba3 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -59,15 +59,11 @@ jobs: - name: Install GitHub CLI run: sudo apt-get install -y gh - - name: Run Pa11y accessibility tests and capture output - id: pa11y - run: | - pa11y-ci --config ./pa11yci.json > pa11y-output.txt - cat pa11y-output.txt - - - name: Post Pa11y results to PR + - name: Run Pa11y accessibility tests and post results to PR if: success() || failure() env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh pr comment ${{ github.event.pull_request.number }} --body "$(cat pa11y-output.txt)" \ No newline at end of file + pa11y-ci --config ./pa11yci.json | gh pr comment ${{ github.event.pull_request.number }} --body - + shell: bash + working-directory: ./apps/demo \ No newline at end of file From f38fcc1844a5ad66b496054b3c3c4614377c7a3e Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 18:04:14 +0100 Subject: [PATCH 06/11] :green_heart: Fixed wrong working directory Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 931bba3..babec5c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -65,5 +65,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | pa11y-ci --config ./pa11yci.json | gh pr comment ${{ github.event.pull_request.number }} --body - - shell: bash - working-directory: ./apps/demo \ No newline at end of file + shell: bash \ No newline at end of file From 0117697b4383511df36098ed63f5cae27617a5ec Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 18:06:23 +0100 Subject: [PATCH 07/11] :green_heart: Redo working directory again Starting to wonder if me no understand Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index babec5c..9f9d942 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -64,5 +64,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - pa11y-ci --config ./pa11yci.json | gh pr comment ${{ github.event.pull_request.number }} --body - - shell: bash \ No newline at end of file + pa11y-ci --config ../../pa11yci.json | gh pr comment ${{ github.event.pull_request.number }} --body - + shell: bash + working-directory: ./apps/demo \ No newline at end of file From da543cac71491d9f69978eb4e5aeaf34072b0a39 Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 18:17:31 +0100 Subject: [PATCH 08/11] :green_heart: Testing with HTTP Server instead Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 14 +++++++++----- pa11yci.json | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9f9d942..b3195f7 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -50,20 +50,24 @@ jobs: - name: Checkout source uses: actions/checkout@v3 - - name: Intall Pa11y-CI + - name: Install Pa11y-CI and HTTP Server run: | - npm install -g pa11y-ci + npm install -g pa11y-ci http-server shell: bash working-directory: ./apps/demo - name: Install GitHub CLI run: sudo apt-get install -y gh + - name: Start HTTP Server + run: | + http-server ./apps/demo -p 8080 & + shell: bash + - name: Run Pa11y accessibility tests and post results to PR if: success() || failure() env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - pa11y-ci --config ../../pa11yci.json | gh pr comment ${{ github.event.pull_request.number }} --body - - shell: bash - working-directory: ./apps/demo \ No newline at end of file + pa11y-ci --config ./pa11yci.json | gh pr comment ${{ github.event.pull_request.number }} --body - + shell: bash \ No newline at end of file diff --git a/pa11yci.json b/pa11yci.json index edf1be2..4168b5b 100644 --- a/pa11yci.json +++ b/pa11yci.json @@ -4,6 +4,6 @@ "timeout": 30000 }, "urls": [ - "file://./apps/demo/index.html" + "http://localhost:8080/index.html" ] } \ No newline at end of file From d3227ab24c6d88ae4d997f68b9fbb39aec365543 Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 18:22:18 +0100 Subject: [PATCH 09/11] :green_heart: Testing out Daniel Mundra's example :link: https://accessibility.civicactions.com/posts/automated-accessibility-testing-leveraging-github-actions-and-pa11y-ci-with-axe Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 47 ++++++++++++++++++------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b3195f7..c4ededc 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -45,29 +45,38 @@ jobs: accessibility-testing: runs-on: ubuntu-latest - name: Testing accessibility + name: Running pa11y-ci tests on HTML file + runs-on: ubuntu-latest + steps: - name: Checkout source - uses: actions/checkout@v3 - - - name: Install Pa11y-CI and HTTP Server - run: | - npm install -g pa11y-ci http-server - shell: bash - working-directory: ./apps/demo + uses: actions/checkout@v2 - - name: Install GitHub CLI - run: sudo apt-get install -y gh + - name: Install pa11y-ci dependencies + run: npm install -g pa11y-ci - - name: Start HTTP Server - run: | - http-server ./apps/demo -p 8080 & - shell: bash + - name: Run pa11y-ci on static HTML file + run: pa11y-ci file://$GITHUB_WORKSPACE/apps/demo/index.html 2>&1 | tee pa11y_output.txt - - name: Run Pa11y accessibility tests and post results to PR - if: success() || failure() - env: + - name: Read pa11y_output file + id: pa11y_output + uses: juliangruber/read-file-action@v1 + with: + path: ./pa11y_output.txt + + - name: Comment on pull request + uses: thollander/actions-comment-pull-request@master + with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + message: '
Pa11y testing results + + +```${{ steps.pa11y_output.outputs.content }}``` + +
' + + - name: Check for pa11y failures + if: contains(steps.pa11y_output.outputs.content, 'errno 2') run: | - pa11y-ci --config ./pa11yci.json | gh pr comment ${{ github.event.pull_request.number }} --body - - shell: bash \ No newline at end of file + echo "::error::The site is failing accessibility tests. Please review the comment in the pull request or the pa11y-ci step in the workflow for details." + exit 1 \ No newline at end of file From 08c7e3ccb6ad920cfe9f6181ca0b4c2c824b8f05 Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 18:24:13 +0100 Subject: [PATCH 10/11] :green_heart: Remove duplicate runs-on Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c4ededc..98e14a7 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -46,7 +46,6 @@ jobs: accessibility-testing: runs-on: ubuntu-latest name: Running pa11y-ci tests on HTML file - runs-on: ubuntu-latest steps: - name: Checkout source From c47bc669d95569816b16e38f83b1af3700ff73db Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Mon, 4 Nov 2024 18:27:59 +0100 Subject: [PATCH 11/11] :green_heart: Fix version of thollander comment-action Signed-off-by: SindreKjelsrud --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 98e14a7..dc39c96 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -64,7 +64,7 @@ jobs: path: ./pa11y_output.txt - name: Comment on pull request - uses: thollander/actions-comment-pull-request@master + uses: thollander/actions-comment-pull-request@v3 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} message: '
Pa11y testing results