From 80f921556f1b746613a77a7bc8cf73745e86ea84 Mon Sep 17 00:00:00 2001 From: Raphaelle Cantin Date: Mon, 23 Sep 2024 17:15:43 +0100 Subject: [PATCH] Uncomment required test steps and tidy write-report script --- .buildkite/pipeline.yml | 116 +++++++++++++++++------------------ pa11y/webapp/write-report.js | 86 +++++++------------------- 2 files changed, 78 insertions(+), 124 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 634fae32f1..ff63349d61 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -67,67 +67,65 @@ build: - dash image-repository: 130871440101.dkr.ecr.eu-west-1.amazonaws.com/uk.ac.wellcome/buildkite - -# TODO UNCOMMENT BEFORE MERGE, this is just to test faster -# - label: 'diff prismic model' -# branches: 'main' -# plugins: -# - wellcomecollection/aws-assume-role#v0.2.2: -# role: 'arn:aws:iam::130871440101:role/experience-ci' -# - ecr#v2.1.1: -# login: true -# - docker-compose#v3.5.0: -# run: prismic_model -# env: -# - CI -# command: ['yarn', 'diffCustomTypes'] - -# - label: 'test common' -# depends_on: 'build_common' -# plugins: -# - wellcomecollection/aws-assume-role#v0.2.2: -# role: 'arn:aws:iam::130871440101:role/experience-ci' -# - ecr#v2.1.1: -# login: true -# - docker-compose#v3.5.0: -# run: common -# command: ['yarn', 'test'] - -# - label: 'test content' -# depends_on: 'build_content' -# plugins: -# - wellcomecollection/aws-assume-role#v0.2.2: -# role: 'arn:aws:iam::130871440101:role/experience-ci' -# - ecr#v2.1.1: -# login: true -# - docker-compose#v3.5.0: -# run: content -# command: ['yarn', 'test'] - -# - label: 'test identity' -# depends_on: 'build_identity' -# plugins: -# - wellcomecollection/aws-assume-role#v0.2.2: -# role: 'arn:aws:iam::130871440101:role/experience-ci' -# - ecr#v2.1.1: -# login: true -# - docker-compose#v3.5.0: -# run: identity -# command: ['yarn', 'test'] - -# - label: 'test edge_lambdas' -# depends_on: 'build_edge_lambdas' -# plugins: -# - wellcomecollection/aws-assume-role#v0.2.2: -# role: 'arn:aws:iam::130871440101:role/experience-ci' -# - ecr#v2.1.1: -# login: true -# - docker-compose#v3.5.0: -# run: edge_lambdas -# command: ['yarn', 'test'] + +- label: 'diff prismic model' + branches: 'main' + plugins: + - wellcomecollection/aws-assume-role#v0.2.2: + role: 'arn:aws:iam::130871440101:role/experience-ci' + - ecr#v2.1.1: + login: true + - docker-compose#v3.5.0: + run: prismic_model + env: + - CI + command: ['yarn', 'diffCustomTypes'] + +- label: 'test common' + depends_on: 'build_common' + plugins: + - wellcomecollection/aws-assume-role#v0.2.2: + role: 'arn:aws:iam::130871440101:role/experience-ci' + - ecr#v2.1.1: + login: true + - docker-compose#v3.5.0: + run: common + command: ['yarn', 'test'] + +- label: 'test content' + depends_on: 'build_content' + plugins: + - wellcomecollection/aws-assume-role#v0.2.2: + role: 'arn:aws:iam::130871440101:role/experience-ci' + - ecr#v2.1.1: + login: true + - docker-compose#v3.5.0: + run: content + command: ['yarn', 'test'] + +- label: 'test identity' + depends_on: 'build_identity' + plugins: + - wellcomecollection/aws-assume-role#v0.2.2: + role: 'arn:aws:iam::130871440101:role/experience-ci' + - ecr#v2.1.1: + login: true + - docker-compose#v3.5.0: + run: identity + command: ['yarn', 'test'] + +- label: 'test edge_lambdas' + depends_on: 'build_edge_lambdas' + plugins: + - wellcomecollection/aws-assume-role#v0.2.2: + role: 'arn:aws:iam::130871440101:role/experience-ci' + - ecr#v2.1.1: + login: true + - docker-compose#v3.5.0: + run: edge_lambdas + command: ['yarn', 'test'] # This step kicks of the "end-to-end on pull requests" flow. -# # It doesn't run on main, because we run e2es on main by deploying # into our stage/prod environments instead. diff --git a/pa11y/webapp/write-report.js b/pa11y/webapp/write-report.js index a7a0bc67f5..353c334a47 100644 --- a/pa11y/webapp/write-report.js +++ b/pa11y/webapp/write-report.js @@ -74,74 +74,30 @@ const promises = urls.map(url => Promise.all(promises) .then(async results => { - const fakeResults = [ - { - documentTitle: 'First page title', - pageUrl: '/url/here', - issues: [ - { - code: 'string', - context: 'Context of the error', - message: 'This is an error', - selector: '#id-of-the-element', - type: 'warning', - typeCode: 300, - }, - { - code: 'string', - context: 'Context of the error!', - message: 'This is an error too', - selector: '#id-of-the-element', - type: 'error', - typeCode: 300, - }, - ], - }, - { - documentTitle: 'Second page title', - pageUrl: '/url/here2', - issues: [ - { - code: 'string', - context: 'Context of the error', - message: 'This is another error', - selector: '#id-of-the-element', - type: 'warning', - typeCode: 300, - }, - { - code: 'string', - context: 'Context of the error!', - message: 'This is another error too!!', - selector: '#id-of-the-element', - type: 'error', - typeCode: 300, - }, - ], - }, - ]; - if (isPullRequestRun && fakeResults.length > 0) { - const resultsLog = fakeResults - .map(result => ({ - title: result.documentTitle, - url: result.pageUrl, - errors: result.issues.map(issue => ({ - type: issue.type, - message: issue.message, - })), - })) - .flat(); + if (isPullRequestRun) { + if (results.length > 0) { + const resultsLog = results + .map(result => ({ + title: result.documentTitle, + url: result.pageUrl, + errors: result.issues.map(issue => ({ + type: issue.type, + message: issue.message, + })), + })) + .flat(); - console.error(`!!! ${chalk.redBright('Fix these before merging')}`); - console.log(...resultsLog); + console.error(`!!! ${chalk.redBright('Fix these before merging')}`); + console.log(...resultsLog); - // TODO do we want it to stop people from merging also when it's of type "warning" or "notice"? - if ( - fakeResults.find(result => + // TODO do we want it to stop people from merging also when it's of type "warning" or "notice"? + const hasErrors = results.find(result => result.issues.find(issue => issue.type === 'error') - ) - ) - process.exit(1); + ); + if (hasErrors) process.exit(1); + } else { + console.log(chalk.redBright('Report done, no errors found')); + } } else { await fs.promises.mkdir('./.dist', { recursive: true }); await writeFile('./.dist/report.json', JSON.stringify({ results }));