From afe028a0a05c8b8bb0b33e12b557ff455e47355d Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Mon, 5 Nov 2018 09:09:40 +0000 Subject: [PATCH] CI updates * Use Travis CI to test on Windows * Reorganize test script * Run TAP tests in parallel once more * Slow down timeout tests to prevent them from timing out too quickly in CI * Add Node.js 11 to the test matrix * Simplify .gitattributes --- .gitattributes | 3 +- .travis.yml | 38 ++++++++++++------- appveyor.yml | 33 ---------------- maintaining.md | 2 +- package.json | 6 ++- readme.md | 2 +- .../report/timeoutinmultiplefiles/a.js | 4 +- .../report/timeoutinmultiplefiles/b.js | 6 +-- test/fixture/report/timeoutinsinglefile/a.js | 4 +- test/helper/report.js | 2 +- .../verbose.timeoutinmultiplefiles.log | 4 +- .../reporters/verbose.timeoutinsinglefile.log | 2 +- 12 files changed, 43 insertions(+), 63 deletions(-) delete mode 100644 appveyor.yml diff --git a/.gitattributes b/.gitattributes index c5a6b9cd2..92a6c930e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf *.ai binary *.psd binary diff --git a/.travis.yml b/.travis.yml index d466b85fb..97239133d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: node_js +os: + - windows + - linux node_js: + - 11 - 10 - 8 - 6 @@ -8,26 +12,34 @@ env: - FRESH_DEPS=true matrix: exclude: + - node_js: 11 + env: FRESH_DEPS=true - node_js: 8 env: FRESH_DEPS=true - node_js: 6 env: FRESH_DEPS=true -cache: - directories: - - $HOME/.npm -before_install: - - npm install --global npm@6.3.0 - - npm --version -install: | + - node_js: 10 + env: FRESH_DEPS=true # Assume any bugs that occur with fresh dependencies are not platform specific. + os: windows + - node_js: 6 + os: windows # npm install --global currently fails on Windows. Skip the tests entirely instead. +cache: npm +before_install: if [[ $(node -pe "process.versions.node.split('.')[0]") == "6" ]]; then npm install --global npm@6; fi +install: npm ci +before_script: | if [[ ${FRESH_DEPS} == "true" ]]; then - npm install --no-shrinkwrap --prefer-online; + npm install --no-shrinkwrap --prefer-online else - npm ci; - checksum=$(md5sum package-lock.json); - npm install --package-lock-only; + checksum=$(md5sum package-lock.json) + npm install --package-lock-only if ! echo ${checksum} | md5sum --quiet -c -; then - echo "package-lock.json was modified unexpectedly. Please rebuild it using npm@$(npm -v) and commit the changes."; - exit 1; + echo "package-lock.json was modified unexpectedly. Please rebuild it using npm@$(npm -v) and commit the changes." + exit 1 fi fi + + if [[ "${TRAVIS_OS_NAME}" == 'windows' ]]; then + git config core.symlinks true + git reset --hard + fi after_success: npx codecov --file=./coverage/lcov.info diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 78efd3a84..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,33 +0,0 @@ -build: off -cache: - - '%APPDATA%\npm-cache' -clone_depth: 1 -skip_branch_with_pr: true -skip_commits: - files: - - '**/*.md' -configuration: - - FreshDeps - - LockedDeps -environment: - matrix: - - nodejs_version: 10 - - nodejs_version: 8 - - nodejs_version: 6 -matrix: - fast_finish: true - exclude: - - configuration: FreshDeps - nodejs_version: 8 - - configuration: FreshDeps - nodejs_version: 6 -install: - - ps: Install-Product node $env:nodejs_version - - npm install --global npm@6.3.0 - - npm --version - - git config core.symlinks true - - git reset --hard - - if %configuration% == FreshDeps (npm install --no-shrinkwrap --prefer-online) - - if %configuration% == LockedDeps (npm ci) -test_script: - - npm run test-win diff --git a/maintaining.md b/maintaining.md index f33a56bec..00c3be6f0 100644 --- a/maintaining.md +++ b/maintaining.md @@ -17,7 +17,7 @@ Read and adhere to the [Code of Conduct](code-of-conduct.md). ## Release process - Bump dependencies. -- Ensure [Travis CI](https://travis-ci.org/avajs/ava) and [AppVeyor](https://ci.appveyor.com/project/avajs/ava/branch/master) are green. +- Ensure [Travis CI](https://travis-ci.org/avajs/ava) is green. - If [necessary](docs/support-statement.md), update the `engines` field in `package.json` - Publish a new version using [`np`](https://github.com/sindresorhus/np) with a version number according to [semver](http://semver.org). - Write a [release note](https://github.com/avajs/ava/releases/new) following the style of previous release notes. diff --git a/package.json b/package.json index eaa9ed532..54504c400 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,10 @@ }, "scripts": { "lint": "xo", - "test": "npm run lint && flow check test/flow-types && tsc --noEmit -p test/ts-types && nyc tap --no-cov --timeout=300 test/*.js test/reporters/*.js test/integration/*.js", - "test-win": "tap --no-cov --reporter=classic --timeout=300 test/*.js test/reporters/*.js test/integration/*.js" + "test:flow": "flow check test/flow-types", + "test:tap": "tap --no-cov --reporter=classic --timeout=300 --jobs=2 test/*.js test/reporters/*.js test/integration/*.js", + "test:typescript": "tsc --noEmit -p test/ts-types", + "test": "npm run lint && npm run test:flow && npm run test:typescript && nyc npm run test:tap" }, "files": [ "lib", diff --git a/readme.md b/readme.md index 1a11c2573..f9b3f00e5 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ > Futuristic test runner -[![Build Status: Linux](https://travis-ci.org/avajs/ava.svg?branch=master)](https://travis-ci.org/avajs/ava) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/e7v91mu2m5x48ehx/branch/master?svg=true)](https://ci.appveyor.com/project/ava/ava/branch/master) [![Coverage Status](https://codecov.io/gh/avajs/ava/branch/master/graph/badge.svg)](https://codecov.io/gh/avajs/ava/branch/master) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/ava) +[![Build Status](https://travis-ci.org/avajs/ava.svg?branch=master)](https://travis-ci.org/avajs/ava) [![Coverage Status](https://codecov.io/gh/avajs/ava/branch/master/graph/badge.svg)](https://codecov.io/gh/avajs/ava/branch/master) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/ava) [![Mentioned in Awesome Node.js](https://awesome.re/mentioned-badge.svg)](https://github.com/sindresorhus/awesome-nodejs) Even though JavaScript is single-threaded, IO in Node.js can happen in parallel due to its async nature. AVA takes advantage of this and runs your tests concurrently, which is especially beneficial for IO heavy tests. In addition, test files are run in parallel as separate processes, giving you even better performance and an isolated environment for each test file. [Switching](https://github.com/sindresorhus/pageres/commit/663be15acb3dd2eb0f71b1956ef28c2cd3fdeed0) from Mocha to AVA in Pageres brought the test time down from 31 to 11 seconds. Having tests run concurrently forces you to write atomic tests, meaning tests don't depend on global state or the state of other tests, which is a great thing! diff --git a/test/fixture/report/timeoutinmultiplefiles/a.js b/test/fixture/report/timeoutinmultiplefiles/a.js index 21618fcfe..ad870d3ba 100644 --- a/test/fixture/report/timeoutinmultiplefiles/a.js +++ b/test/fixture/report/timeoutinmultiplefiles/a.js @@ -3,10 +3,10 @@ import test from '../../../..'; test('a passes', t => t.pass()); test.cb('a slow', t => { - setTimeout(t.end, 5000); + setTimeout(t.end, 15000); }); test.cb('a slow two', t => { - setTimeout(t.end, 5000); + setTimeout(t.end, 15000); }); test('a passes two', t => t.pass()); diff --git a/test/fixture/report/timeoutinmultiplefiles/b.js b/test/fixture/report/timeoutinmultiplefiles/b.js index 089221966..4040ea5c0 100644 --- a/test/fixture/report/timeoutinmultiplefiles/b.js +++ b/test/fixture/report/timeoutinmultiplefiles/b.js @@ -3,13 +3,13 @@ import test from '../../../..'; test('b passes', t => t.pass()); test.cb('b slow', t => { - setTimeout(t.end, 5000); + setTimeout(t.end, 15000); }); test.cb('b slow two', t => { - setTimeout(t.end, 5000); + setTimeout(t.end, 15000); }); test.cb('b slow three', t => { - setTimeout(t.end, 5000); + setTimeout(t.end, 15000); }); test('b passes two', t => t.pass()); diff --git a/test/fixture/report/timeoutinsinglefile/a.js b/test/fixture/report/timeoutinsinglefile/a.js index df8eed30b..f452c5f2e 100644 --- a/test/fixture/report/timeoutinsinglefile/a.js +++ b/test/fixture/report/timeoutinsinglefile/a.js @@ -3,10 +3,10 @@ import test from '../../../..'; test('passes', t => t.pass()); test.cb('slow', t => { - setTimeout(t.end, 5000); + setTimeout(t.end, 15000); }); test.cb('slow two', t => { - setTimeout(t.end, 5000); + setTimeout(t.end, 15000); }); test('passes two', t => t.pass()); diff --git a/test/helper/report.js b/test/helper/report.js index a9b9dbac2..a1b041af0 100644 --- a/test/helper/report.js +++ b/test/helper/report.js @@ -97,7 +97,7 @@ const run = (type, reporter) => { babelConfig: {testOptions: {}}, resolveTestsFrom: projectDir, projectDir, - timeout: type.startsWith('timeout') ? '1000ms' : undefined, + timeout: type.startsWith('timeout') ? '10s' : undefined, concurrency: 1, updateSnapshots: false, snapshotDir: false, diff --git a/test/reporters/verbose.timeoutinmultiplefiles.log b/test/reporters/verbose.timeoutinmultiplefiles.log index c0225fc9d..d3b6050a4 100644 --- a/test/reporters/verbose.timeoutinmultiplefiles.log +++ b/test/reporters/verbose.timeoutinmultiplefiles.log @@ -5,7 +5,7 @@ ✔ a › a passes two ---tty-stream-chunk-separator  - ✖ Exited because no new tests completed within the last 1000ms of inactivity + ✖ Exited because no new tests completed within the last 10000ms of inactivity 2 tests still running in ~/test/fixture/report/timeoutinmultiplefiles/a.js: @@ -18,7 +18,7 @@ ✔ b › b passes two ---tty-stream-chunk-separator  - ✖ Exited because no new tests completed within the last 1000ms of inactivity + ✖ Exited because no new tests completed within the last 10000ms of inactivity 3 tests still running in ~/test/fixture/report/timeoutinmultiplefiles/b.js: diff --git a/test/reporters/verbose.timeoutinsinglefile.log b/test/reporters/verbose.timeoutinsinglefile.log index a55aaf820..f2e3cc32e 100644 --- a/test/reporters/verbose.timeoutinsinglefile.log +++ b/test/reporters/verbose.timeoutinsinglefile.log @@ -5,7 +5,7 @@ ✔ passes two ---tty-stream-chunk-separator  - ✖ Exited because no new tests completed within the last 1000ms of inactivity + ✖ Exited because no new tests completed within the last 10000ms of inactivity 2 tests still running in ~/test/fixture/report/timeoutinsinglefile/a.js: