Skip to content

Commit

Permalink
fix: only build on release
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 28, 2018
1 parent c98a8e4 commit 0f5e7db
Show file tree
Hide file tree
Showing 21 changed files with 44 additions and 50 deletions.
60 changes: 28 additions & 32 deletions templates/app/package-scripts.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,51 @@ const linters = {
<%_ if (semantic_release) { _%>
commitlint: script('commitlint --from origin/master', 'ensure that commits are in valid conventional-changelog format'),
<%_ } _%>
<%_ if (ts && mocha) { _%>
tsc: script('tsc -p test --noEmit', 'syntax check with tsc'),
tslint: script('tslint -p test', 'lint ts files'),
<%_ } else if (ts) { _%>
tsc: script('tsc -p . --noEmit', 'syntax check with tsc'),
tslint: script('tslint -p .', 'lint ts files'),
<%_ } _%>
}

const scripts = {
...linters,
lint: concurrent(linters),
<%_ if (ts) { _%>
build: series('rm -rf lib', 'tsc'),
<%_ } _%>
<%_ if (mocha) { _%>
test: script(concurrent.nps(...Object.keys(linters), 'mocha'), 'lint and run all tests'),
mocha: script('mocha --forbid-only "test/**/*.test.<%= _ext %>"', 'run all mocha tests'),
<%_ } else { _%>
test: concurrent(linters),
tsc: script('tsc -p <%- ts ? 'test' : '.' %> --noEmit', 'syntax check with tsc'),
tslint: script('tslint -p <%- ts ? 'test' : '.' %>', 'lint ts files'),
<%_ } _%>
}

<%_ if (mocha) { _%>
let test = 'mocha --forbid-only "test/**/*.test.<%- _ext %>"'
if (process.env.CI) {
if (process.env.CIRCLECI) {
scripts.test.script = series(mkdirp('reports'), scripts.test.script)
// add mocha junit reporter
scripts.mocha.script = crossEnv(`MOCHA_FILE=reports/mocha.xml ${scripts.mocha.script} --reporter mocha-junit-reporter`)
test = crossEnv(`MOCHA_FILE=reports/mocha.xml ${test} --reporter mocha-junit-reporter`)
// add eslint reporter
scripts.eslint.script = `${scripts.eslint.script} --format junit --output-file reports/eslint.xml`
linters.eslint.script = `${linters.eslint.script} --format junit --output-file reports/eslint.xml`
<%_ if (ts) { _%>
// add tslint reporter
scripts.tslint.script = `${scripts.tslint.script} --format junit > reports/tslint.xml`
linters.tslint.script = `${linters.tslint.script} --format junit > reports/tslint.xml`
<%_ } _%>
scripts.release = 'semantic-release -e @dxcli/semantic-release'
}
// add code coverage reporting with nyc
const nyc = 'nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc'
const nycReport = `${nyc} report --reporter text-lcov > coverage.lcov`
scripts.mocha.script = series(`${nyc} ${scripts.mocha.script}`, nycReport)
test = series(`${nyc} ${test}`, nycReport)
}
<%_ } else if (mocha) { _%>
if (process.env.CI) {
if (process.env.CIRCLECI) {
scripts.release = 'semantic-release -e @dxcli/semantic-release'
}
}
test = concurrent({
...linters,
test: series(<%- ts ? "'nps build', " : ''%>test),
})
if (process.env.CI) test = series(mkdirp('reports'), test)
<%_ } else { _%>
let test = concurrent(linters)
<%_ } _%>

module.exports = {
scripts: {
...linters,
<%_ if (ts) { _%>
build: series('rm -rf lib', 'tsc'),
<%_ } _%>
module.exports = {scripts}
lint: concurrent(linters),
test,
<%_ if (semantic_release) { _%>
release: 'semantic-release -e @dxcli/semantic-release',
<%_ } _%>
},
}
3 changes: 3 additions & 0 deletions templates/app/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "../tsconfig",
"compilerOptions": {
"sourceMap": true
},
"include": [
"./**/*",
"../src/**/*"
Expand Down
1 change: 0 additions & 1 deletion templates/app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"rootDirs": [
"./src"
],
"sourceMap": true,
"strict": true,
"target": "es2017"
},
Expand Down
2 changes: 1 addition & 1 deletion test/commands/base/everything.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ const run = require('../../run')

describe('base', () => {
run('base', 'everything')
.retries(2).it()
.it()
})
2 changes: 1 addition & 1 deletion test/commands/base/mocha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ const run = require('../../run')

describe('base', () => {
run('base', 'mocha')
.retries(2).it()
.it()
})
2 changes: 1 addition & 1 deletion test/commands/base/plain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ const run = require('../../run')

describe('base', () => {
run('base', 'plain')
.retries(2).it()
.it()
})
2 changes: 1 addition & 1 deletion test/commands/base/typescript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ const run = require('../../run')

describe('base', () => {
run('base', 'typescript')
.retries(2).it()
.it()
})
2 changes: 1 addition & 1 deletion test/commands/multi/everything.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const run = require('../../run')

describe('multi', () => {
run('multi', 'everything')
.retries(2).it(() => {
.it(() => {
sh.exec('node ./bin/run version')
sh.exec('node ./bin/run hello')
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/multi/mocha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const run = require('../../run')

describe('multi', () => {
run('multi', 'mocha')
.retries(2).it(() => {
.it(() => {
sh.exec('node ./bin/run version')
sh.exec('node ./bin/run hello')
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/multi/plain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const run = require('../../run')

describe('multi', () => {
run('multi', 'plain')
.retries(2).it(() => {
.it(() => {
sh.exec('node ./bin/run version')
sh.exec('node ./bin/run hello')
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/multi/typescript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const run = require('../../run')

describe('multi', () => {
run('multi', 'typescript')
.retries(2)

.it(() => {
sh.exec('node ./bin/run version')
sh.exec('node ./bin/run hello')
Expand Down
1 change: 0 additions & 1 deletion test/commands/plugin/everything.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const run = require('../../run')

describe('plugin', () => {
run('plugin', 'everything')
.retries(2)
.it(() => {
sh.exec('node ./bin/run hello')
})
Expand Down
1 change: 0 additions & 1 deletion test/commands/plugin/mocha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const run = require('../../run')

describe('plugin', () => {
run('plugin', 'mocha')
.retries(2)
.it(() => {
sh.exec('node ./bin/run hello')
})
Expand Down
1 change: 0 additions & 1 deletion test/commands/plugin/plain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const run = require('../../run')

describe('plugin', () => {
run('plugin', 'plain')
.retries(2)
.it(() => {
sh.exec('node ./bin/run hello')
})
Expand Down
1 change: 0 additions & 1 deletion test/commands/plugin/typescript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const run = require('../../run')

describe('plugin', () => {
run('plugin', 'typescript')
.retries(2)
.it(() => {
sh.exec('node ./bin/run hello')
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/single/everything.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const run = require('../../run')

describe('single', () => {
run('single', 'everything')
.retries(2).it(() => {
.it(() => {
sh.exec('node ./bin/run')
})
})
2 changes: 1 addition & 1 deletion test/commands/single/mocha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const run = require('../../run')

describe('single', () => {
run('single', 'mocha')
.retries(2).it(() => {
.it(() => {
sh.exec('node ./bin/run')
})
})
2 changes: 1 addition & 1 deletion test/commands/single/plain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const run = require('../../run')

describe('single', () => {
run('single', 'plain')
.retries(2).it(() => {
.it(() => {
sh.exec('node ./bin/run')
})
})
2 changes: 1 addition & 1 deletion test/commands/single/typescript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const run = require('../../run')

describe('single', () => {
run('single', 'typescript')
.retries(2).it(() => {
.it(() => {
sh.exec('node ./bin/run')
})
})
1 change: 1 addition & 0 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {CI} = process.env
module.exports = (type, features) => {
return test
.env({CI: undefined})
.retries(CI ? 1 : 0)
.do(ctx => {
process.chdir(path.join(__dirname, '..'))
let options = ''
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"rootDirs": [
"./src"
],
"sourceMap": true,
"strict": true,
"target": "es2017"
},
Expand Down

0 comments on commit 0f5e7db

Please sign in to comment.