Skip to content

Commit

Permalink
Uncomment required test steps and tidy write-report script
Browse files Browse the repository at this point in the history
  • Loading branch information
rcantin-w committed Sep 23, 2024
1 parent 53f7ac0 commit 80f9215
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 124 deletions.
116 changes: 57 additions & 59 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
86 changes: 21 additions & 65 deletions pa11y/webapp/write-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down

0 comments on commit 80f9215

Please sign in to comment.