-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from codemod-js/ci-refactor
test(ci): refactor test/lint infrastructure
- Loading branch information
Showing
30 changed files
with
258 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { join } from 'path'; | ||
import runNodePackageBinary from '../../../../script/_utils/runNodePackageBinary'; | ||
|
||
export default async function main( | ||
args: Array<string>, | ||
stdin: NodeJS.ReadStream, | ||
stdout: NodeJS.WriteStream, | ||
stderr: NodeJS.WriteStream | ||
): Promise<number> { | ||
const rest = args.slice(1); | ||
|
||
switch (args[0]) { | ||
case undefined: | ||
return ( | ||
(await build(rest, stdin, stdout, stderr)) || | ||
(await lint(rest, stdin, stdout, stderr)) || | ||
(await runTests(rest, stdin, stdout, stderr)) | ||
); | ||
|
||
case 'test': | ||
return ( | ||
(await build(rest, stdin, stdout, stderr)) || | ||
(await runTests(rest, stdin, stdout, stderr)) | ||
); | ||
|
||
case 'lint': | ||
return await lint(rest, stdin, stdout, stderr); | ||
|
||
default: | ||
throw new Error(`unexpected command: ${args[0]}`); | ||
} | ||
} | ||
|
||
async function build( | ||
args: Array<string>, | ||
stdin: NodeJS.ReadStream, | ||
stdout: NodeJS.WriteStream, | ||
stderr: NodeJS.WriteStream | ||
): Promise<number> { | ||
return await runNodePackageBinary( | ||
'tsc', | ||
[], | ||
join(__dirname, '../..'), | ||
stdin, | ||
stdout, | ||
stderr | ||
); | ||
} | ||
|
||
async function runTests( | ||
args: Array<string>, | ||
stdin: NodeJS.ReadStream, | ||
stdout: NodeJS.WriteStream, | ||
stderr: NodeJS.WriteStream | ||
): Promise<number> { | ||
return await runNodePackageBinary( | ||
'mocha', | ||
[ | ||
'test/**/*Test.js', | ||
...(isCI() | ||
? [ | ||
'--reporter', | ||
'mocha-junit-reporter', | ||
'--reporter-options', | ||
'mochaFile=reports/junit/js-test-results.xml' | ||
] | ||
: []) | ||
], | ||
join(__dirname, '../..'), | ||
stdin, | ||
stdout, | ||
stderr | ||
); | ||
} | ||
|
||
async function lint( | ||
args: Array<string>, | ||
stdin: NodeJS.ReadStream, | ||
stdout: NodeJS.WriteStream, | ||
stderr: NodeJS.WriteStream | ||
): Promise<number> { | ||
return await runNodePackageBinary( | ||
'eslint', | ||
[ | ||
'packages/cli', | ||
'--ext', | ||
'.ts', | ||
...(isCI() | ||
? ['--format', 'junit', '-o', 'reports/junit/eslint-results.xml'] | ||
: []), | ||
...args | ||
], | ||
join(__dirname, '../../../..'), | ||
stdin, | ||
stdout, | ||
stderr | ||
); | ||
} | ||
|
||
function isCI(): boolean { | ||
return process.env.CI === 'true'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../../../script/_utils/runCommand')( | ||
require.resolve('./_commands/ci.ts') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import * as Babel from '@babel/core'; | ||
import { PluginObj } from './BabelPluginTypes'; | ||
|
||
export default function(babel: typeof Babel) { | ||
export default function(): PluginObj { | ||
// We don't need to override anything; babel will do what babel does. | ||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.