Skip to content

Weather login customizations module for limiting access to basic auth features #1603

Weather login customizations module for limiting access to basic auth features

Weather login customizations module for limiting access to basic auth features #1603

Workflow file for this run

name: code standards
on:
pull_request:
merge_group:
jobs:
should-test:
name: check if we should run tests
runs-on: ubuntu-latest
outputs:
"no": ${{ steps.skip-tests.outputs.no }}
"yes": ${{ steps.skip-tests.outputs.yes }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: list files that have changed from main
id: diff
run: echo "diff=$(git diff --name-only origin/main)" | tr "\n" "\t" >> $GITHUB_OUTPUT
- name: determine whether to skip tests
id: skip-tests
uses: actions/github-script@v7
with:
script: |
// The paths that are exempt from testing. If all of the changed
// files are in these paths, we can skip tests completely.
const exemptPaths = [
"docs/",
"scripts/",
".bp-config/",
];
// Get the list of changed files from the previous step and turn it
// into something we can work with.
const changedFiles = ${{ toJSON(steps.diff.outputs.diff) }}
.split("\t")
.filter(value => value.length > 0);
// Determine whether to skip tests. We will skip tests if it is true
// for EVERY FILE that they are in ANY of the exempted paths.
const skipTests = changedFiles.every(file => exemptPaths.some(path => file.startsWith(path)));
// Set the output so other jobs can use it. If we are skipping
// tests, add an annotation so we know, and list out the files that
// were changed. This may be helpful for debugging if things go
// sideways later on.
core.setOutput('no', skipTests);
core.setOutput('yes', !skipTests);
if(skipTests) {
core.notice(`Skipping tests. Modified files are:\n* ${changedFiles.join("\n* ")}`);
}
php-lint:
name: PHP lint
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup PHP
if: needs.should-test.outputs.yes == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
- name: get composer paths
if: needs.should-test.outputs.yes == 'true'
id: composer-paths
run: |
echo "cache-dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "bin-dir=${{ github.workspace }}/$(composer config bin-dir)" >> $GITHUB_OUTPUT
- name: cache composer caches
if: needs.should-test.outputs.yes == 'true'
uses: actions/cache@v4
with:
path: ${{ steps.composer-paths.outputs.cache-dir }}
key: composer-cache-${{ hashFiles('composer.lock') }}
- name: install dependencies
if: needs.should-test.outputs.yes == 'true'
env:
COMPOSER_NO_DEV: 0
run: composer install
- name: run phpcs
if: needs.should-test.outputs.yes == 'true'
run: |
echo "::add-matcher::${{ github.workspace }}/.github/workflows/problem-matcher-phpcs.json"
vendor/bin/phpcs --report=checkstyle
js-lint:
name: JS lint
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup node
if: needs.should-test.outputs.yes == 'true'
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: install dependencies
if: needs.should-test.outputs.yes == 'true'
run: npm ci
- name: install proxy dependencies
if: needs.should-test.outputs.yes == 'true'
run: cd tests/api && npm ci
- name: add problem matcher
if: needs.should-test.outputs.yes == 'true'
run: echo "::add-matcher::${{ github.workspace }}/.github/workflows/problem-matcher-eslint.json"
- name: run eslint
if: needs.should-test.outputs.yes == 'true'
run: npm run js-lint
js-component-tests:
name: JS Component Tests
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup node
if: needs.should-test.outputs.yes == 'true'
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: install dependencies
if: needs.should-test.outputs.yes == 'true'
run: npm ci
- name: install proxy dependencies
if: needs.should-test.outputs.yes == 'true'
run: cd tests/api && npm ci
- name: run js-component-tests
if: needs.should-test.outputs.yes == 'true'
run: npm run js-component-tests
style-lint:
name: SCSS lint
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup node
if: needs.should-test.outputs.yes == 'true'
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: install dependencies
if: needs.should-test.outputs.yes == 'true'
run: npm ci
# Stylelint has a GitHub workflow commands output available by default,
# so we can use that instead of needing a problem matcher.
# https://stylelint.io/user-guide/options#formatter
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
- name: run stylelint
if: needs.should-test.outputs.yes == 'true'
run: npm run style-lint -- -f github
build-drupal-image:
name: build Drupal image
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: build drupal
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/build-drupal-image
populate-database:
name: populate database
runs-on: ubuntu-latest
needs: [build-drupal-image, should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: populate database
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/populate-database
php-tests:
name: PHP tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup site
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/setup-site
- name: run unit tests
if: needs.should-test.outputs.yes == 'true'
run: |
curl http://localhost:8081/play/e2e
make backend-test
- name: store coverage output
if: needs.should-test.outputs.yes == 'true'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: .coverage/clover.xml
retention-days: 1
min-code-coverage:
name: "90% code coverage"
runs-on: ubuntu-latest
needs: [php-tests, should-test]
steps:
- name: get coverage output
id: download
if: needs.should-test.outputs.yes == 'true'
uses: actions/download-artifact@v4
with:
name: coverage-report
- name: 90% code coverage
if: needs.should-test.outputs.yes == 'true'
id: test-coverage
uses: johanvanhelden/gha-clover-test-coverage-check@v1
with:
percentage: 90
filename: clover.xml
metric: statements
accessibility-tests:
name: accessibility tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]
steps:
- uses: browser-actions/setup-chrome@v1
- uses: browser-actions/setup-edge@v1
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup site
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/setup-site
- uses: actions/setup-node@v4
with:
node-version: 18
- name: install dependencies
run: npm ci
- name: install browsers
run: npx playwright install --with-deps
- name: run tests
run: npx playwright test a11y
end-to-end-tests:
name: end-to-end tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup site
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/setup-site
- name: Cypress run
if: needs.should-test.outputs.yes == 'true'
uses: cypress-io/github-action@v6
with:
project: tests/e2e
cache-key: cypress-e2e-${{ hashFiles('package-lock.json') }}
- name: save screenshots
if: needs.should-test.outputs.yes == 'true'
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tests/e2e/cypress/screenshots/screenshots.cy.js/
page-load-time-tests:
name: page load time tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]
if: needs.should-test.outputs.yes == 'true'
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup site
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/setup-site
- name: Cypress run
uses: cypress-io/github-action@v6
with:
project: tests/load-times
cache-key: cypress-a11y-${{ hashFiles('package-lock.json') }}