Skip to content

Commit cb07a95

Browse files
authored
Add CI check for stub files (#722)
1 parent 8ee7a5f commit cb07a95

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

scripts/ci

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
const shell = require('shelljs');
1313
const helpers = require('./helpers');
1414

15+
const stubResult = shell.exec('scripts/stub-check').code;
16+
if(stubResult != 0) { shell.exit(stubResult); }
17+
1518
const checkResult = shell.exec('scripts/checksum').code;
1619
if(checkResult != 0) { shell.exit(checkResult); }
1720

scripts/helpers.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
*/
55

66
const shell = require('shelljs');
7+
const fs = require('fs');
78

89
const exerciseDirs = shell.ls('-d', 'exercises/*');
910

10-
const assignments = exerciseDirs.map(dir => dir.split('/')[1]);
11+
const config = JSON.parse(fs.readFileSync('config.json'))['exercises'];
12+
const assignments = exerciseDirs.map(dir => dir.split('/')[1])
13+
.filter(exercise => !exercise.deprecated);
1114

1215
// Preapre all exercises (see above) & run a given command
1316
function prepareAndRun(command, infoStr, failureStr) {

scripts/stub-check

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Run this script (from root directory): npx @babel/node scripts/stub-check
5+
*
6+
* This script checks that all exercises have a stub file.
7+
* Ref: https://github.com/exercism/javascript/issues/705
8+
*/
9+
10+
const shell = require('shelljs');
11+
const helpers = require('./helpers');
12+
13+
const noStubs = helpers.assignments.filter(
14+
assignment => !shell.test('-f', `exercises/${assignment}/${assignment}.js`)
15+
);
16+
if(noStubs.length > 0) {
17+
shell.echo('[Error]: No stub files found for following exercises:');
18+
shell.echo(noStubs.join('\n'));
19+
shell.exit(1);
20+
}
21+
else {
22+
shell.echo('[Success]: Stub files present for all exercises!');
23+
}

0 commit comments

Comments
 (0)