From a29a9f1f6c67946d3eb2e266d8c0e7baca9edcda Mon Sep 17 00:00:00 2001 From: Jithen Shriyan Date: Sat, 20 Jan 2024 20:47:55 -0500 Subject: [PATCH] [feat] add microsite accessibility workflow, add microsite lighthouse config Signed-off-by: Jithen Shriyan --- .../workflows/verify_accessibility-noop.yml | 2 +- .github/workflows/verify_accessibility.yml | 4 +- .../verify_microsite_accessibility-noop.yml | 31 +++++++++ .../verify_microsite_accessibility.yml | 40 +++++++++++ microsite/lighthouserc.js | 66 +++++++++++++++++++ package.json | 1 + 6 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/verify_microsite_accessibility-noop.yml create mode 100644 .github/workflows/verify_microsite_accessibility.yml create mode 100644 microsite/lighthouserc.js diff --git a/.github/workflows/verify_accessibility-noop.yml b/.github/workflows/verify_accessibility-noop.yml index 79c9962fce..dc356c8809 100644 --- a/.github/workflows/verify_accessibility-noop.yml +++ b/.github/workflows/verify_accessibility-noop.yml @@ -7,7 +7,7 @@ on: branches: [master] paths-ignore: - 'lighthouserc.js' - - '.github/workflows/verify_accessibility_core.yml' + - '.github/workflows/verify_accessibility.yml' - 'plugins/catalog/src/**' - 'plugins/catalog-react/src/**' - 'plugins/techdocs/src/**' diff --git a/.github/workflows/verify_accessibility.yml b/.github/workflows/verify_accessibility.yml index 1310fc15f4..cbe66838fd 100644 --- a/.github/workflows/verify_accessibility.yml +++ b/.github/workflows/verify_accessibility.yml @@ -1,11 +1,11 @@ name: Accessibility on: - # NOTE: If you change these you must update verify_accessibility_core-noop.yml as well + # NOTE: If you change these you must update verify_accessibility-noop.yml as well pull_request: branches: [master] paths: - 'lighthouserc.js' - - '.github/workflows/verify_accessibility_core.yml' + - '.github/workflows/verify_accessibility.yml' - 'plugins/catalog/src/**' - 'plugins/catalog-react/src/**' - 'plugins/techdocs/src/**' diff --git a/.github/workflows/verify_microsite_accessibility-noop.yml b/.github/workflows/verify_microsite_accessibility-noop.yml new file mode 100644 index 0000000000..35a7b3e19d --- /dev/null +++ b/.github/workflows/verify_microsite_accessibility-noop.yml @@ -0,0 +1,31 @@ +# NO-OP placeholder that always passes for other paths +# This is here so that we're able to set the status check as required + +name: Microsite Accessibility +on: + pull_request: + branches: [master] + paths-ignore: + - '.github/workflows/verify_microsite_accessibility.yml' + - 'microsite/scripts/**' + - 'microsite/src/**' + - 'microsite/data/**' + - 'microsite/blog/**' + - 'microsite/static/**' + - 'beps/**' + - 'mkdocs.yml' + - 'docs/**' +permissions: + contents: read + +jobs: + noop: + name: Microsite Accessibility + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 + with: + egress-policy: audit + + - run: echo NOOP diff --git a/.github/workflows/verify_microsite_accessibility.yml b/.github/workflows/verify_microsite_accessibility.yml new file mode 100644 index 0000000000..482d8270bd --- /dev/null +++ b/.github/workflows/verify_microsite_accessibility.yml @@ -0,0 +1,40 @@ +name: Microsite Accessibility +on: + # NOTE: If you change these you must update verify_microsite_accessibility-noop.yml as well + pull_request: + branches: [master] + paths: + - '.github/workflows/verify_microsite_accessibility.yml' + - 'microsite/**' + - 'beps/**' + - 'mkdocs.yml' + - 'docs/**' +jobs: + lhci: + name: Microsite Accessibility + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 + with: + egress-policy: audit + + - uses: actions/checkout@v4.1.1 + + - name: Use Node.js 18.x + uses: actions/setup-node@v4.0.1 + with: + node-version: 18.x + + - name: top-level install + run: yarn install --immutable + + - name: yarn install + run: yarn install --immutable + working-directory: microsite + + - name: run Lighthouse CI + run: | + yarn dlx @lhci/cli@0.11.x --config=microsite/lighthouserc.js autorun + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/microsite/lighthouserc.js b/microsite/lighthouserc.js new file mode 100644 index 0000000000..a980a53287 --- /dev/null +++ b/microsite/lighthouserc.js @@ -0,0 +1,66 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var sidebars = require('./sidebars.json') + +module.exports = { + ci: { + collect: { + url: [ + /** Home */ + 'http://localhost:3000', + /** Docs - Getting Started */ + 'http://localhost:3000/docs/getting-started', + /** Docs - Software Catalog */ + 'http://localhost:3000/docs/features/software-catalog', + /** Docs - Create a Plugin */ + 'http://localhost:3000/docs/plugins/create-a-plugin', + /** Docs - Designing for Backstage */ + 'http://localhost:3000/docs/dls/design', + /** Blog */ + 'http://localhost:3000/blog', + /** Plugins */ + 'http://localhost:3000/plugins', + /** Demos */ + 'http://localhost:3000/demos', + /** Community */ + 'http://localhost:3000/community', + /** Releases */ + ...(sidebars.releases['Release Notes'].map((path) => `http://localhost:3000/docs/${path}`)), + ], + settings: { + onlyCategories: ['accessibility'], + output: ['html', 'json'], + outputPath: './.lighthouseci/reports', + preset: 'desktop', + }, + // refers to root package scripts + startServerCommand: 'yarn run start:microsite', + startServerReadyPattern: 'compiled successfully', + startServerReadyTimeout: 600000, + numberOfRuns: 1, + }, + assert: { + assertions: { + 'categories:performance': 'off', + 'categories:pwa': 'off', + 'categories:best-practices': 'off', + 'categories:seo': 'off', + 'categories:accessibility': ['error', { minScore: 0.95 }], + }, + }, + }, +}; diff --git a/package.json b/package.json index 483e02fdb5..d8d49a0b1d 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "start-backend": "yarn workspace example-backend start", "start:next": "yarn workspace example-app-next start", "start-backend:next": "yarn workspace example-backend-next start", + "start:microsite": "cd microsite/ && yarn start", "build:backend": "yarn workspace example-backend build", "build:all": "backstage-cli repo build --all", "build:api-reports": "yarn build:api-reports:only --tsc",