Skip to content

Commit 685f0ca

Browse files
author
katiegoines
committed
running validation to catch all issues
1 parent 9ece25e commit 685f0ca

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

.github/workflows/check_pr_for_broken_links.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ jobs:
3535
return await checkDevLinks();
3636
- name: Fail if broken links have been found
3737
if: ${{ steps.checkLinks.outputs.result }}
38-
run: exit 1
38+
run: exit 1 && echo ${{ toJson(steps.checkLinks.outputs.result) }}

.github/workflows/scripts/validate-redirects.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
invalidRedirects: () => {
33
const Ajv = require('ajv');
4-
const redirectsImport = require('../../../redirects.json');
4+
const redirects = require('../../../redirects.json');
55
const ajv = new Ajv();
66

77
const schema = {
@@ -31,30 +31,27 @@ module.exports = {
3131
}
3232
};
3333

34-
let redirects = redirectsImport;
3534
const errors = [];
35+
const validate = ajv.compile(schema);
3636

3737
const validateEntries = (redirects) => {
38-
const validate = ajv.compile(schema);
3938
const valid = validate(redirects);
4039

4140
if (!valid) {
4241
const error = validate.errors[0];
4342
const invalidEntry =
4443
JSON.stringify(redirects[error.instancePath.slice(1, -7)]);
4544
const loc = error.schemaPath.slice(error.schemaPath.indexOf('properties') + 11, -8);
46-
const errorMessage = '\n\n' + 'INVALID ENTRY: Please correct the error in the "' + loc +'" property of the following entry: \n' + invalidEntry + '\n\n' + 'ERROR MESSAGE: ' + error.message;
47-
48-
errors.push(errorMessage)
49-
redirects = redirects.splice(error.instancePath.slice(1, -7))
50-
51-
validateEntries(redirects)
52-
} else if (valid && errors.length > 0) {
53-
return errors.stringify();
54-
}
55-
}
45+
const errorMessage = '\n\n' + 'INVALID ENTRY: Please correct the error in the "' + loc +'" property of the following entry: \n' + invalidEntry + '\n' + 'ERROR MESSAGE: ' + error.message;
46+
errors.push(errorMessage);
47+
48+
validateEntries(redirects.splice(parseInt(error.instancePath.slice(1, -7)) + 1));
5649

50+
}
51+
}
5752
validateEntries(redirects);
53+
54+
return errors;
5855
}
5956
}
6057

.github/workflows/validate_redirects.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
const { invalidRedirects } = require('./.github/workflows/scripts/validate-redirects.js');
2929
return await invalidRedirects();
3030
- name: Fail if any invalid redirects have been found
31-
if: ${{ steps.redirects.outputs.result != 'undefined' }}
31+
if: ${{ steps.redirects.outputs.result }}
3232
run: exit 1 && echo ${{ steps.redirects.outputs.result }}

redirects.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"status": "301"
66
},
77
{
8-
"source": "cli/function/function/",
8+
"source": "/cli/function/function/",
99
"target": "/javascript/build-a-backend/functions/set-up-function/",
1010
"status": "301"
1111
},
1212
{
1313
"source": "/lib/ssr/ssr/",
1414
"target": "/gen1/javascript/prev/build-a-backend/server-side-rendering/",
15-
"status": "601"
15+
"status": "301"
1616
},
1717
{
1818
"source": "/cli/plugins/",

0 commit comments

Comments
 (0)