From dc8d2b13f81040c45c49303dba8d7adf831d18e4 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 14:21:23 -0600 Subject: [PATCH 01/32] Accessibility audit test --- .github/workflows/accessibility-audit.yml | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/accessibility-audit.yml diff --git a/.github/workflows/accessibility-audit.yml b/.github/workflows/accessibility-audit.yml new file mode 100644 index 00000000000000..66797cd687cead --- /dev/null +++ b/.github/workflows/accessibility-audit.yml @@ -0,0 +1,39 @@ +name: Accessibility audit + +# **What it does**: Regularly audits API links in our documentation. +# **Why we have it**: It's too burdensome to check on every commit like we do for internal links. +# **Who does it impact**: PCX team + +on: + schedule: + - cron: "0 0 * * 0" # Run at 00:00 UTC every Sunday + workflow_dispatch: + pull_request: + types: + - opened + +jobs: + build: + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v3 + - name: Install required Linux packages + run: | + sudo apt-get update + sudo apt-get install libgbm-dev + sudo apt-get install xvfb + - name: Use Node.js 12.x + uses: actions/setup-node@v3 + with: + node-version: 18.1 + - name: Install npm packages + run: | + npm ci + - name: Build + run: | + npm run build + - name: Accessibility Audits + run: | + npm install -g @jakepartusch/lumberjack + xvfb-run --auto-servernum lumberjack --url https://developers.cloudflare.com \ No newline at end of file From b7740b47cb087337646c717b7fe963bd4a679aac Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:11:20 -0600 Subject: [PATCH 02/32] rework check --- .github/workflows/accessibility-audit.yml | 35 +++++++++-------------- bin/accessibility-check.js | 32 +++++++++++++++++++++ package.json | 1 + 3 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 bin/accessibility-check.js diff --git a/.github/workflows/accessibility-audit.yml b/.github/workflows/accessibility-audit.yml index 66797cd687cead..6169442ee70130 100644 --- a/.github/workflows/accessibility-audit.yml +++ b/.github/workflows/accessibility-audit.yml @@ -1,4 +1,4 @@ -name: Accessibility audit +name: Accessibility # **What it does**: Regularly audits API links in our documentation. # **Why we have it**: It's too burdensome to check on every commit like we do for internal links. @@ -13,27 +13,20 @@ on: - opened jobs: - build: - runs-on: ubuntu-18.04 - + test: + name: Test + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Install required Linux packages - run: | - sudo apt-get update - sudo apt-get install libgbm-dev - sudo apt-get install xvfb - - name: Use Node.js 12.x - uses: actions/setup-node@v3 + with: + fetch-depth: 1 + - uses: actions/setup-node@v3 with: node-version: 18.1 - - name: Install npm packages - run: | - npm ci - - name: Build - run: | - npm run build - - name: Accessibility Audits - run: | - npm install -g @jakepartusch/lumberjack - xvfb-run --auto-servernum lumberjack --url https://developers.cloudflare.com \ No newline at end of file + + - name: Install dependencies + run: npm install @actions/core pa11y axios xml2js + + - name: Run accessibility test + id: test-accessibility + run: npm run test-accessibility \ No newline at end of file diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js new file mode 100644 index 00000000000000..53bf967205edb0 --- /dev/null +++ b/bin/accessibility-check.js @@ -0,0 +1,32 @@ +import pa11y from "pa11y" +import core from "@actions/core"; +import axios from "axios" +import { parseString } from 'xml2js'; + +const sitemapUrl = 'https://developers.cloudflare.com/sitemap.xml'; + +function processUrl(url) { + pa11y(url).then((results) => { + console.log(results) +}); +} + +axios.get(sitemapUrl) + .then(response => { + if (response.status === 200) { + parseString(response.data, (err, result) => { + if (err) { + console.error('Error parsing XML:', err); + return; + } + + const urls = result.urlset.url.map(urlObj => urlObj.loc[0]); + urls.forEach(processUrl); + }); + } else { + console.error('Failed to fetch sitemap. Status code:', response.status); + } + }) + .catch(error => { + console.error('An error occurred:', error); + }); diff --git a/package.json b/package.json index d538284a46679b..3a07275c1b60ce 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "scripts": { "algolia-crawl": "node bin/algolia-crawl.js", "crawl-api-links": "node bin/crawl-api-links.js", + "test-accessibility": "node bin/accessibility-check.js", "dev:hugo": "hugo --environment development -D -w", "dev:wrangler": "wrangler pages dev -- vite", "dev:vite": "vite", From 1494f0c6f54479035216a90d76822199b25e24e1 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:12:49 -0600 Subject: [PATCH 03/32] Update --- .github/workflows/accessibility-audit.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/accessibility-audit.yml b/.github/workflows/accessibility-audit.yml index 6169442ee70130..1e02a310de7734 100644 --- a/.github/workflows/accessibility-audit.yml +++ b/.github/workflows/accessibility-audit.yml @@ -5,9 +5,6 @@ name: Accessibility # **Who does it impact**: PCX team on: - schedule: - - cron: "0 0 * * 0" # Run at 00:00 UTC every Sunday - workflow_dispatch: pull_request: types: - opened From 4251a8ab2c989688fce663b9b724464cd316fdab Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:14:36 -0600 Subject: [PATCH 04/32] extra line at end --- .github/workflows/accessibility-audit.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/accessibility-audit.yml b/.github/workflows/accessibility-audit.yml index 1e02a310de7734..3d90d017000f9f 100644 --- a/.github/workflows/accessibility-audit.yml +++ b/.github/workflows/accessibility-audit.yml @@ -26,4 +26,5 @@ jobs: - name: Run accessibility test id: test-accessibility - run: npm run test-accessibility \ No newline at end of file + run: npm run test-accessibility + \ No newline at end of file From 45745b6858dc681fcd60aa0d8ec80fc98991dcda Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:15:51 -0600 Subject: [PATCH 05/32] change trigger? --- .github/workflows/accessibility-audit.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/accessibility-audit.yml b/.github/workflows/accessibility-audit.yml index 3d90d017000f9f..3b2184888135bc 100644 --- a/.github/workflows/accessibility-audit.yml +++ b/.github/workflows/accessibility-audit.yml @@ -6,8 +6,8 @@ name: Accessibility on: pull_request: - types: - - opened + branches: + - production jobs: test: @@ -27,4 +27,3 @@ jobs: - name: Run accessibility test id: test-accessibility run: npm run test-accessibility - \ No newline at end of file From 6113cbd5e6b1514204efadae1f2055aa7714c049 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:24:09 -0600 Subject: [PATCH 06/32] Test both implementations simultaneously --- .github/workflows/accessibility-audit.yml | 2 -- .github/workflows/accessilibity-audit-2.yml | 36 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/accessilibity-audit-2.yml diff --git a/.github/workflows/accessibility-audit.yml b/.github/workflows/accessibility-audit.yml index 3b2184888135bc..921c3d69c004c7 100644 --- a/.github/workflows/accessibility-audit.yml +++ b/.github/workflows/accessibility-audit.yml @@ -15,8 +15,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - fetch-depth: 1 - uses: actions/setup-node@v3 with: node-version: 18.1 diff --git a/.github/workflows/accessilibity-audit-2.yml b/.github/workflows/accessilibity-audit-2.yml new file mode 100644 index 00000000000000..f2b4b9e2312bb7 --- /dev/null +++ b/.github/workflows/accessilibity-audit-2.yml @@ -0,0 +1,36 @@ +name: Accessibility 2 + +# **What it does**: Regularly audits API links in our documentation. +# **Why we have it**: It's too burdensome to check on every commit like we do for internal links. +# **Who does it impact**: PCX team + +on: + pull_request: + branches: + - production + +jobs: + test2: + name: Test 2 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install required Linux packages + run: | + sudo apt-get update + sudo apt-get install libgbm-dev + sudo apt-get install xvfb + - uses: actions/setup-node@v3 + with: + node-version: 18.1 + + - name: Install npm packages + run: | + npm ci + - name: Build + run: | + npm run build + - name: Accessibility Audits + run: | + npm install -g @jakepartusch/lumberjack + xvfb-run --auto-servernum lumberjack --url https://developers.cloduflare.com From 49afc8e1f5fb8091b189a3148c774fab25b16716 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:24:42 -0600 Subject: [PATCH 07/32] fix error --- bin/accessibility-check.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 53bf967205edb0..472b7df8d41cfe 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -2,6 +2,10 @@ import pa11y from "pa11y" import core from "@actions/core"; import axios from "axios" import { parseString } from 'xml2js'; +import { EventEmitter } from 'events'; + +const myEmitter = new EventEmitter(); +myEmitter.setMaxListeners(20); // Increase const sitemapUrl = 'https://developers.cloudflare.com/sitemap.xml'; From cda6bc9ceeef26c0034f8268bd8e8aba47f21cf2 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:26:59 -0600 Subject: [PATCH 08/32] test again --- .github/workflows/accessilibity-audit-2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/accessilibity-audit-2.yml b/.github/workflows/accessilibity-audit-2.yml index f2b4b9e2312bb7..ba6596b0742db5 100644 --- a/.github/workflows/accessilibity-audit-2.yml +++ b/.github/workflows/accessilibity-audit-2.yml @@ -26,7 +26,7 @@ jobs: - name: Install npm packages run: | - npm ci + npm install - name: Build run: | npm run build From e07860bb2d6c2e5e3a1a0f7986c74a5f37c6a051 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:29:58 -0600 Subject: [PATCH 09/32] replace with async --- bin/accessibility-check.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 472b7df8d41cfe..5a2e9947575181 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -9,10 +9,13 @@ myEmitter.setMaxListeners(20); // Increase const sitemapUrl = 'https://developers.cloudflare.com/sitemap.xml'; -function processUrl(url) { - pa11y(url).then((results) => { - console.log(results) -}); +async function processUrl(url) { + try { + const results = await pa11y(url); + console.log(results) + } catch (error) { + console.log("error") + } } axios.get(sitemapUrl) From fc3b9d5eac51f3da6f0e751c8d358b446f3b3e43 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:35:32 -0600 Subject: [PATCH 10/32] Use pre-built action --- .github/workflows/accessilibity-audit-2.yml | 28 +++++++-------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/.github/workflows/accessilibity-audit-2.yml b/.github/workflows/accessilibity-audit-2.yml index ba6596b0742db5..61bdcb85f83191 100644 --- a/.github/workflows/accessilibity-audit-2.yml +++ b/.github/workflows/accessilibity-audit-2.yml @@ -14,23 +14,13 @@ jobs: name: Test 2 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Install required Linux packages - run: | - sudo apt-get update - sudo apt-get install libgbm-dev - sudo apt-get install xvfb - - uses: actions/setup-node@v3 + - uses: a11ywatch/github-action@v2 with: - node-version: 18.1 - - - name: Install npm packages - run: | - npm install - - name: Build - run: | - npm run build - - name: Accessibility Audits - run: | - npm install -g @jakepartusch/lumberjack - xvfb-run --auto-servernum lumberjack --url https://developers.cloduflare.com + WEBSITE_URL: https://developers.cloudflare.com + SUBDOMAINS: false + TLD: false + SITEMAP: true + FAIL_ERRORS_COUNT: 15 + LIST: true + FIX: false + UPGRADE: false From 4b4ca0784ee5a0b0d785aad448e0a4dc6b3a10d0 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:36:16 -0600 Subject: [PATCH 11/32] fix version --- .github/workflows/accessilibity-audit-2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/accessilibity-audit-2.yml b/.github/workflows/accessilibity-audit-2.yml index 61bdcb85f83191..301b1578776eee 100644 --- a/.github/workflows/accessilibity-audit-2.yml +++ b/.github/workflows/accessilibity-audit-2.yml @@ -14,7 +14,7 @@ jobs: name: Test 2 runs-on: ubuntu-latest steps: - - uses: a11ywatch/github-action@v2 + - uses: a11ywatch/github-actions@v2.0.2 with: WEBSITE_URL: https://developers.cloudflare.com SUBDOMAINS: false From 2e898edbee1b46526b5c3880fc7b0ed0c7dcd51d Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:37:30 -0600 Subject: [PATCH 12/32] test fix for script --- bin/accessibility-check.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 5a2e9947575181..865dbeda6a54b5 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -1,21 +1,24 @@ -import pa11y from "pa11y" -import core from "@actions/core"; -import axios from "axios" +import pa11y from "pa11y"; +import axios from "axios"; import { parseString } from 'xml2js'; import { EventEmitter } from 'events'; const myEmitter = new EventEmitter(); -myEmitter.setMaxListeners(20); // Increase +myEmitter.setMaxListeners(20); const sitemapUrl = 'https://developers.cloudflare.com/sitemap.xml'; -async function processUrl(url) { - try { - const results = await pa11y(url); - console.log(results) - } catch (error) { - console.log("error") - } +async function processUrlBatch(urls) { + const promises = urls.map(async (url) => { + try { + const results = await pa11y(url); + console.log(results); + } catch (error) { + console.log("error"); + } + }); + + await Promise.all(promises); } axios.get(sitemapUrl) @@ -28,7 +31,7 @@ axios.get(sitemapUrl) } const urls = result.urlset.url.map(urlObj => urlObj.loc[0]); - urls.forEach(processUrl); + processUrlBatch(urls); }); } else { console.error('Failed to fetch sitemap. Status code:', response.status); From 8f8dae0981abf593ab1c25469f7d68fc5bf6a337 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:46:54 -0600 Subject: [PATCH 13/32] Test another implementation --- bin/accessibility-check.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 865dbeda6a54b5..cb5bd565d08a7e 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -1,12 +1,11 @@ import pa11y from "pa11y"; import axios from "axios"; import { parseString } from 'xml2js'; -import { EventEmitter } from 'events'; -const myEmitter = new EventEmitter(); -myEmitter.setMaxListeners(20); +process.on('warning', e => console.warn(e.stack)); const sitemapUrl = 'https://developers.cloudflare.com/sitemap.xml'; +const urlsToProcess = []; // Array to store URLs for processing async function processUrlBatch(urls) { const promises = urls.map(async (url) => { @@ -31,7 +30,7 @@ axios.get(sitemapUrl) } const urls = result.urlset.url.map(urlObj => urlObj.loc[0]); - processUrlBatch(urls); + urlsToProcess.push(...urls); // Add individual URLs to the array }); } else { console.error('Failed to fetch sitemap. Status code:', response.status); @@ -40,3 +39,5 @@ axios.get(sitemapUrl) .catch(error => { console.error('An error occurred:', error); }); + +urlsToProcess.forEach(processUrl); From bc46a066cda529dda41784a472c146b16a9f3e70 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:48:55 -0600 Subject: [PATCH 14/32] Test --- bin/accessibility-check.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index cb5bd565d08a7e..d8c03264bd23ca 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -7,17 +7,13 @@ process.on('warning', e => console.warn(e.stack)); const sitemapUrl = 'https://developers.cloudflare.com/sitemap.xml'; const urlsToProcess = []; // Array to store URLs for processing -async function processUrlBatch(urls) { - const promises = urls.map(async (url) => { - try { - const results = await pa11y(url); - console.log(results); - } catch (error) { - console.log("error"); - } - }); - - await Promise.all(promises); +async function processUrl(url) { + try { + const results = await pa11y(url); + console.log(results); + } catch (error) { + console.log("error"); + } } axios.get(sitemapUrl) From 1a7f1147577bc247f7492ef87b891cbbac6e2ca5 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 16:52:08 -0600 Subject: [PATCH 15/32] another test --- bin/accessibility-check.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index d8c03264bd23ca..aaacf17f5a529e 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -34,6 +34,8 @@ axios.get(sitemapUrl) }) .catch(error => { console.error('An error occurred:', error); + }) + .finally(() => { + // Process the URLs after the response has been handled + urlsToProcess.forEach(processUrl); }); - -urlsToProcess.forEach(processUrl); From b0f9bdbd942a0e054c186874495f25d358cafd00 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Wed, 30 Aug 2023 17:02:08 -0600 Subject: [PATCH 16/32] One more test --- .github/workflows/accessibility-audit.yml | 2 +- .github/workflows/accessilibity-audit-2.yml | 26 -------- bin/accessibility-check.js | 71 +++++++++++---------- 3 files changed, 37 insertions(+), 62 deletions(-) delete mode 100644 .github/workflows/accessilibity-audit-2.yml diff --git a/.github/workflows/accessibility-audit.yml b/.github/workflows/accessibility-audit.yml index 921c3d69c004c7..0dd2285e1ffa98 100644 --- a/.github/workflows/accessibility-audit.yml +++ b/.github/workflows/accessibility-audit.yml @@ -20,7 +20,7 @@ jobs: node-version: 18.1 - name: Install dependencies - run: npm install @actions/core pa11y axios xml2js + run: npm install @actions/core pa11y puppeteer - name: Run accessibility test id: test-accessibility diff --git a/.github/workflows/accessilibity-audit-2.yml b/.github/workflows/accessilibity-audit-2.yml deleted file mode 100644 index 301b1578776eee..00000000000000 --- a/.github/workflows/accessilibity-audit-2.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Accessibility 2 - -# **What it does**: Regularly audits API links in our documentation. -# **Why we have it**: It's too burdensome to check on every commit like we do for internal links. -# **Who does it impact**: PCX team - -on: - pull_request: - branches: - - production - -jobs: - test2: - name: Test 2 - runs-on: ubuntu-latest - steps: - - uses: a11ywatch/github-actions@v2.0.2 - with: - WEBSITE_URL: https://developers.cloudflare.com - SUBDOMAINS: false - TLD: false - SITEMAP: true - FAIL_ERRORS_COUNT: 15 - LIST: true - FIX: false - UPGRADE: false diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index aaacf17f5a529e..4b4f76584af63a 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -1,41 +1,42 @@ import pa11y from "pa11y"; -import axios from "axios"; -import { parseString } from 'xml2js'; +import puppeteer from "puppeteer"; +import core from "@actions/core"; -process.on('warning', e => console.warn(e.stack)); +const navigationTimeout = 120000; // Set the navigation timeout to 120 seconds (120,000 milliseconds) -const sitemapUrl = 'https://developers.cloudflare.com/sitemap.xml'; -const urlsToProcess = []; // Array to store URLs for processing +async function checkLinks() { + const browser = await puppeteer.launch({ + headless: "new", + }); + const page = await browser.newPage(); -async function processUrl(url) { - try { - const results = await pa11y(url); - console.log(results); - } catch (error) { - console.log("error"); + const sitemapUrl = "https://developers.cloudflare.com/sitemap.xml"; + await page.goto(sitemapUrl, { timeout: navigationTimeout }); + + const sitemapLinks = await page.$$eval("url loc", (elements) => + elements.map((el) => el.textContent) + ); + + const visitedLinks = []; + const brokenLinks = []; + + for (const link of sitemapLinks) { + if (!link) { + continue; // Skip if the link is empty } -} - -axios.get(sitemapUrl) - .then(response => { - if (response.status === 200) { - parseString(response.data, (err, result) => { - if (err) { - console.error('Error parsing XML:', err); - return; - } - - const urls = result.urlset.url.map(urlObj => urlObj.loc[0]); - urlsToProcess.push(...urls); // Add individual URLs to the array - }); - } else { - console.error('Failed to fetch sitemap. Status code:', response.status); - } - }) - .catch(error => { - console.error('An error occurred:', error); + + const page2 = await browser.newPage() + const result = await pa11y(link, { + browser, + page: page2 }) - .finally(() => { - // Process the URLs after the response has been handled - urlsToProcess.forEach(processUrl); - }); + + console.log(result); + await page2.close(); + } + await page.close(); + await browser.close(); + } + + + checkLinks(); \ No newline at end of file From 9bd3e7b5244b91169c9c778988fa57f11e6ad1f2 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 08:52:35 -0600 Subject: [PATCH 17/32] Have two runners --- bin/accessibility-check.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 4b4f76584af63a..d1ac24cd939f53 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -28,7 +28,11 @@ async function checkLinks() { const page2 = await browser.newPage() const result = await pa11y(link, { browser, - page: page2 + page: page2, + runners: [ + 'axe', + 'htmlcs' + ] }) console.log(result); From 44a363cdfe1503fc6834e7114845193297da1779 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 10:22:57 -0600 Subject: [PATCH 18/32] small updates --- ...ssibility-audit.yml => test-accessibility.yml} | 11 +++++++---- bin/accessibility-check.js | 15 +++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) rename .github/workflows/{accessibility-audit.yml => test-accessibility.yml} (51%) diff --git a/.github/workflows/accessibility-audit.yml b/.github/workflows/test-accessibility.yml similarity index 51% rename from .github/workflows/accessibility-audit.yml rename to .github/workflows/test-accessibility.yml index 0dd2285e1ffa98..8470f4e1daeef4 100644 --- a/.github/workflows/accessibility-audit.yml +++ b/.github/workflows/test-accessibility.yml @@ -1,17 +1,20 @@ name: Accessibility -# **What it does**: Regularly audits API links in our documentation. -# **Why we have it**: It's too burdensome to check on every commit like we do for internal links. -# **Who does it impact**: PCX team +# **What it does**: Regularly audits our live site for accessibility issues +# **Why we have it**: Because this is too time-consuming for a commit-level check, but absolutely something we should pay attention to. +# **Who does it impact**: PCX team / FE dev. on: pull_request: branches: - production + schedule: + - cron: '0 0 1 * *' # This cron expression triggers the workflow at 00:00 on the 1st day of every month + workflow_dispatch: jobs: test: - name: Test + name: Test accessibility runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index d1ac24cd939f53..0f0410670e7fb6 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -3,6 +3,7 @@ import puppeteer from "puppeteer"; import core from "@actions/core"; const navigationTimeout = 120000; // Set the navigation timeout to 120 seconds (120,000 milliseconds) +let resultsArray = [] async function checkLinks() { const browser = await puppeteer.launch({ @@ -17,12 +18,11 @@ async function checkLinks() { elements.map((el) => el.textContent) ); - const visitedLinks = []; - const brokenLinks = []; - for (const link of sitemapLinks) { if (!link) { continue; // Skip if the link is empty + } else if (link.includes("/support/other-languages/")) { + continue; // Skip if the link is in a certain section } const page2 = await browser.newPage() @@ -32,9 +32,16 @@ async function checkLinks() { runners: [ 'axe', 'htmlcs' - ] + ], + includeNotices: true }) + for (const issue of result.issues) { + if (!resultsArray.contains(issue)) { + resultsArray.push(issue) + } + } + console.log(result); await page2.close(); } From 7335006ec6807709b2e3e73f2aef3f40602d15f7 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 10:46:28 -0600 Subject: [PATCH 19/32] check dark mode too --- bin/accessibility-check.js | 59 +++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 0f0410670e7fb6..c93a8259f0517a 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -3,7 +3,7 @@ import puppeteer from "puppeteer"; import core from "@actions/core"; const navigationTimeout = 120000; // Set the navigation timeout to 120 seconds (120,000 milliseconds) -let resultsArray = [] +let resultsArray = []; async function checkLinks() { const browser = await puppeteer.launch({ @@ -25,29 +25,42 @@ async function checkLinks() { continue; // Skip if the link is in a certain section } - const page2 = await browser.newPage() - const result = await pa11y(link, { - browser, - page: page2, - runners: [ - 'axe', - 'htmlcs' - ], - includeNotices: true - }) - - for (const issue of result.issues) { - if (!resultsArray.contains(issue)) { - resultsArray.push(issue) + let pages; + pages = [await browser.newPage(), await browser.newPage()]; + + pages.forEach(async function (value, index) { + let result; + if (index === 0) { + result = await pa11y(link, { + browser, + page: eachPage, + runners: ["axe", "htmlcs"], + includeNotices: true, + }); + } else { + result = await pa11y(link, { + browser, + page: eachPage, + runners: ["axe", "htmlcs"], + includeNotices: true, + actions: [ + 'click element #ThemeToggle--input', + 'wait for element #DocsSidebar--sections::before to be added' + ] + }); + } + for (const issue of result.issues) { + if (!resultsArray.contains(issue)) { + resultsArray.push(issue); + } } - } - console.log(result); - await page2.close(); - } - await page.close(); - await browser.close(); + await eachPage.close(); + }); } + await page.close(); + await browser.close(); + console.log(resultsArray); +} - - checkLinks(); \ No newline at end of file +checkLinks(); From d4d137750db0d274be4d69221f20d2af9cf11cbb Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 10:50:48 -0600 Subject: [PATCH 20/32] comment out a bit to test dark mode --- bin/accessibility-check.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index c93a8259f0517a..ec0c650596e2fa 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -49,11 +49,12 @@ async function checkLinks() { ] }); } - for (const issue of result.issues) { + console.log(result) + /* for (const issue of result.issues) { if (!resultsArray.contains(issue)) { resultsArray.push(issue); } - } + } */ await eachPage.close(); }); From d51c3d8e709ada987c8ca305662c417ef96ff9a3 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 10:53:25 -0600 Subject: [PATCH 21/32] add another comment --- bin/accessibility-check.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index ec0c650596e2fa..fe11a6a3838f5c 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -61,7 +61,7 @@ async function checkLinks() { } await page.close(); await browser.close(); - console.log(resultsArray); + /* console.log(resultsArray); */ } checkLinks(); From e70a49b81dc30a078ac3a097776a45482e5da394 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 10:55:30 -0600 Subject: [PATCH 22/32] whoops --- bin/accessibility-check.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index fe11a6a3838f5c..9414e67d7b2d9f 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -33,14 +33,14 @@ async function checkLinks() { if (index === 0) { result = await pa11y(link, { browser, - page: eachPage, + page: value, runners: ["axe", "htmlcs"], includeNotices: true, }); } else { result = await pa11y(link, { browser, - page: eachPage, + page: value, runners: ["axe", "htmlcs"], includeNotices: true, actions: [ From 148d0615afe9ab0d33a67482dcbb9094dd57d80f Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 11:00:22 -0600 Subject: [PATCH 23/32] test another way --- bin/accessibility-check.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 9414e67d7b2d9f..bf865cba807093 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -44,8 +44,7 @@ async function checkLinks() { runners: ["axe", "htmlcs"], includeNotices: true, actions: [ - 'click element #ThemeToggle--input', - 'wait for element #DocsSidebar--sections::before to be added' + 'click element #ThemeToggle', ] }); } @@ -56,7 +55,7 @@ async function checkLinks() { } } */ - await eachPage.close(); + await value.close(); }); } await page.close(); From c7dd22e5be10715f524618129f30b3c075552567 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 11:03:41 -0600 Subject: [PATCH 24/32] Remove notices --- bin/accessibility-check.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index bf865cba807093..0d9a4248fd8718 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -35,14 +35,12 @@ async function checkLinks() { browser, page: value, runners: ["axe", "htmlcs"], - includeNotices: true, }); } else { result = await pa11y(link, { browser, page: value, runners: ["axe", "htmlcs"], - includeNotices: true, actions: [ 'click element #ThemeToggle', ] From e9ac25e5b677bf41dbd515a16a3497f75749caf7 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 11:10:40 -0600 Subject: [PATCH 25/32] One more --- bin/accessibility-check.js | 46 +++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 0d9a4248fd8718..595fed30726d6a 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -25,36 +25,32 @@ async function checkLinks() { continue; // Skip if the link is in a certain section } - let pages; - pages = [await browser.newPage(), await browser.newPage()]; - - pages.forEach(async function (value, index) { - let result; - if (index === 0) { - result = await pa11y(link, { - browser, - page: value, - runners: ["axe", "htmlcs"], - }); - } else { - result = await pa11y(link, { - browser, - page: value, - runners: ["axe", "htmlcs"], - actions: [ - 'click element #ThemeToggle', - ] - }); - } - console.log(result) + const page1 = await browser.newPage(); + let result1 = await pa11y(link, { + browser, + page: value, + runners: ["axe", "htmlcs"], + }); + console.log(result1) + await page1.close(); + + const page2 = await browser.newPage(); + let result2 = await pa11y(link, { + browser, + page: value, + runners: ["axe", "htmlcs"], + actions: [ + 'click element #ThemeToggle', + 'wait for element #DocsSidebar:before to be added' + ] + }); + console.log(result2) + await page2.close(); /* for (const issue of result.issues) { if (!resultsArray.contains(issue)) { resultsArray.push(issue); } } */ - - await value.close(); - }); } await page.close(); await browser.close(); From 3d1d1f1ef2f5cc3bfcdc25c17df148a2f379470b Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 11:12:48 -0600 Subject: [PATCH 26/32] another error --- bin/accessibility-check.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 595fed30726d6a..a50f7073c51ff9 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -28,7 +28,7 @@ async function checkLinks() { const page1 = await browser.newPage(); let result1 = await pa11y(link, { browser, - page: value, + page: page1, runners: ["axe", "htmlcs"], }); console.log(result1) @@ -37,7 +37,7 @@ async function checkLinks() { const page2 = await browser.newPage(); let result2 = await pa11y(link, { browser, - page: value, + page: page2, runners: ["axe", "htmlcs"], actions: [ 'click element #ThemeToggle', From 4e103a768918cfe517491da635a4fa2364412ae8 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 11:20:14 -0600 Subject: [PATCH 27/32] double quotes? --- bin/accessibility-check.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index a50f7073c51ff9..cdb6f1f0513ca4 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -26,27 +26,27 @@ async function checkLinks() { } const page1 = await browser.newPage(); - let result1 = await pa11y(link, { + let result1 = await pa11y(link, { browser, page: page1, runners: ["axe", "htmlcs"], }); - console.log(result1) + console.log(result1); await page1.close(); const page2 = await browser.newPage(); - let result2 = await pa11y(link, { + let result2 = await pa11y(link, { browser, page: page2, runners: ["axe", "htmlcs"], actions: [ 'click element #ThemeToggle', 'wait for element #DocsSidebar:before to be added' - ] + ], }); - console.log(result2) + console.log(result2); await page2.close(); - /* for (const issue of result.issues) { + /* for (const issue of result.issues) { if (!resultsArray.contains(issue)) { resultsArray.push(issue); } From 0d1d153b8a4cce939d85a8ed84b6a712fcaab27f Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 11:21:05 -0600 Subject: [PATCH 28/32] Test another version --- bin/accessibility-check.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index cdb6f1f0513ca4..12e9222a659e44 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -40,7 +40,7 @@ async function checkLinks() { page: page2, runners: ["axe", "htmlcs"], actions: [ - 'click element #ThemeToggle', + 'click element #ThemeToggle--toggle', 'wait for element #DocsSidebar:before to be added' ], }); From f38ba3cb0207eabb892baf30e7f1b1969bcb2bba Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 11:26:41 -0600 Subject: [PATCH 29/32] Remove dark mode tests --- bin/accessibility-check.js | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 12e9222a659e44..df4d6abaacc171 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -4,6 +4,7 @@ import core from "@actions/core"; const navigationTimeout = 120000; // Set the navigation timeout to 120 seconds (120,000 milliseconds) let resultsArray = []; +let printArray = []; async function checkLinks() { const browser = await puppeteer.launch({ @@ -25,36 +26,24 @@ async function checkLinks() { continue; // Skip if the link is in a certain section } - const page1 = await browser.newPage(); - let result1 = await pa11y(link, { + const testPage = await browser.newPage(); + let result = await pa11y(link, { browser, page: page1, runners: ["axe", "htmlcs"], }); - console.log(result1); - await page1.close(); - - const page2 = await browser.newPage(); - let result2 = await pa11y(link, { - browser, - page: page2, - runners: ["axe", "htmlcs"], - actions: [ - 'click element #ThemeToggle--toggle', - 'wait for element #DocsSidebar:before to be added' - ], - }); - console.log(result2); - await page2.close(); - /* for (const issue of result.issues) { + + for (const issue of result.issues) { if (!resultsArray.contains(issue)) { resultsArray.push(issue); } - } */ + } + + await testPage.close(); } await page.close(); await browser.close(); - /* console.log(resultsArray); */ + console.log(resultsArray) } checkLinks(); From 9af233c181cf06115ed1aceb1448b2f3268a2744 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 11:29:27 -0600 Subject: [PATCH 30/32] Test --- bin/accessibility-check.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index df4d6abaacc171..003705de342984 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -29,7 +29,7 @@ async function checkLinks() { const testPage = await browser.newPage(); let result = await pa11y(link, { browser, - page: page1, + page: testPage, runners: ["axe", "htmlcs"], }); From e83b83b02ba10a55406e5ea19a30730057a0af75 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Thu, 31 Aug 2023 11:32:43 -0600 Subject: [PATCH 31/32] error fix --- bin/accessibility-check.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index 003705de342984..ade5378558cae4 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -34,7 +34,7 @@ async function checkLinks() { }); for (const issue of result.issues) { - if (!resultsArray.contains(issue)) { + if (!resultsArray.includes(issue)) { resultsArray.push(issue); } } From ea573d23a1f9026049272173c174dfb963bb6d31 Mon Sep 17 00:00:00 2001 From: Kody Jackson Date: Tue, 5 Sep 2023 11:04:14 -0600 Subject: [PATCH 32/32] print out all the results --- bin/accessibility-check.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/bin/accessibility-check.js b/bin/accessibility-check.js index ade5378558cae4..ff73ac0c9d898d 100644 --- a/bin/accessibility-check.js +++ b/bin/accessibility-check.js @@ -32,13 +32,8 @@ async function checkLinks() { page: testPage, runners: ["axe", "htmlcs"], }); + console.log(result) - for (const issue of result.issues) { - if (!resultsArray.includes(issue)) { - resultsArray.push(issue); - } - } - await testPage.close(); } await page.close();