feat(travis/tests): run tests on files that differs from master (#3599)
Fixes #2703
This commit is contained in:
parent
e047649c3b
commit
0011bfea8c
@ -21,5 +21,4 @@ cache:
|
||||
yarn: true
|
||||
|
||||
script:
|
||||
- yarn run test
|
||||
- yarn run test-integration
|
||||
- yarn run travis-tests
|
||||
|
@ -58,7 +58,8 @@
|
||||
"prepare": "scripts/run-script prepare",
|
||||
"pretest": "eslint --ignore-path .gitignore .",
|
||||
"test": "jest \"^(?!.*\\.integ\\.spec\\.js$)\"",
|
||||
"test-integration": "jest \".integ\\.spec\\.js$\""
|
||||
"test-integration": "jest \".integ\\.spec\\.js$\"",
|
||||
"travis-tests": "scripts/travis-tests"
|
||||
},
|
||||
"workspaces": [
|
||||
"@xen-orchestra/*",
|
||||
|
45
scripts/travis-tests
Executable file
45
scripts/travis-tests
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { execFileSync, spawnSync } = require('child_process')
|
||||
|
||||
const run = (command, args) => {
|
||||
const { status } = spawnSync(command, args, { stdio: 'inherit' })
|
||||
if (status !== 0) {
|
||||
process.exit(status)
|
||||
}
|
||||
}
|
||||
|
||||
const getFiles = () =>
|
||||
execFileSync(
|
||||
'git',
|
||||
[
|
||||
'diff-index',
|
||||
'--diff-filter=AM',
|
||||
'--ignore-submodules',
|
||||
'--name-only',
|
||||
'master',
|
||||
],
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
.split('\n')
|
||||
.filter(_ => _ !== '')
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Travis vars : https://docs.travis-ci.com/user/environment-variables#default-environment-variables.
|
||||
if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
|
||||
const files = getFiles().filter(_ => _.endsWith('.js'))
|
||||
if (files.length !== 0) {
|
||||
run(
|
||||
'./node_modules/.bin/jest',
|
||||
[
|
||||
'--testRegex=^(?!.*.integ.spec.js$).*.spec.js$',
|
||||
'--findRelatedTests',
|
||||
'--passWithNoTests',
|
||||
].concat(files)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
run('yarn', ['test'])
|
||||
run('yarn', ['test-integration'])
|
||||
}
|
Loading…
Reference in New Issue
Block a user