forked from vuejs-templates/webpack
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve template CI tests (close vuejs-templates#1218)
* Batman! * fix wrong job name * fix working dir paths * fix node_modules path * test other step order * try other shell * ...and another one * rewrite test.sh * try running a bash script instead * and another attempt. * make executable * anpother try... * fix workflow errors * fix path * Batman! * added scenarios and made it work!! * refactors and comments * just fumbling around * adfda * adjust test scenarios for autoInstall * x<vb<xb * first try since a long time * small fix * fix path to vue-cli * fix scenarios * fix persist paths * testing with quotes for the path * removing unhelpful quotes * New Test * fixed indentation * test with full setup * 2nd full test * bump jest version * other docker image * test with runinband * test with airbnb/karma as well * remove superfluous checkout * run unit and e2e individually. * fix eslint paths for test subdirs * adjust for airbnb preset * only lint e2e specs, config differences are unfixable. * adding a small readme * remove test.sh not needed anymore
- Loading branch information
Showing
11 changed files
with
247 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
version: 2 | ||
vm_settings: &vm_settings | ||
docker: | ||
- image: circleci/node:8.9.4-browsers | ||
|
||
jobs: | ||
install_template_deps: | ||
<<: *vm_settings | ||
working_directory: ~/project/webpack-template | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
key: template-cache-{{ checksum "package.json" }} | ||
- run: | ||
name: Install npm dependencies | ||
command: npm install | ||
- save_cache: | ||
key: template-cache-{{ checksum "package.json" }} | ||
paths: | ||
- node_modules | ||
- run: | ||
name: Rollout minimal scenario | ||
command: VUE_TEMPL_TEST=minimal node_modules/.bin/vue init . test-minimal | ||
- run: | ||
name: Rollout full scenario | ||
command: VUE_TEMPL_TEST=full node_modules/.bin/vue init . test-full | ||
- run: | ||
name: Rollout full-karma-airbnb scenario | ||
command: VUE_TEMPL_TEST=full-karma-airbnb node_modules/.bin/vue init . test-full-karma-airbnb | ||
- persist_to_workspace: | ||
root: ~/project/webpack-template | ||
paths: | ||
- node_modules | ||
- test-* | ||
|
||
scenario_minimal: | ||
<<: *vm_settings | ||
environment: | ||
- VUE_TEMPL_TEST: minimal | ||
working_directory: ~/project/webpack-template/test-minimal | ||
steps: | ||
- attach_workspace: | ||
at: '~/project/webpack-template' | ||
- restore_cache: | ||
key: template-cache-minimal-{{ checksum "package.json" }} | ||
- run: | ||
name: Install npm dependencies | ||
command: npm install | ||
- save_cache: | ||
key: template-cache-minimal-{{ checksum "package.json" }} | ||
paths: | ||
- node_modules | ||
- run: | ||
name: Test build | ||
command: npm run build | ||
|
||
scenario_full: | ||
<<: *vm_settings | ||
working_directory: ~/project/webpack-template/test-full | ||
environment: | ||
- VUE_TEMPL_TEST: full | ||
steps: | ||
- attach_workspace: | ||
at: '~/project/webpack-template' | ||
- restore_cache: | ||
key: template-cache-full-{{ checksum "package.json" }} | ||
- run: | ||
name: Install npm dependencies | ||
command: npm install | ||
- save_cache: | ||
key: template-cache-full-{{ checksum "package.json" }} | ||
paths: | ||
- node_modules | ||
- run: | ||
name: Run Lint | ||
command: npm run lint -- --fix | ||
- run: | ||
name: Run Unit tests | ||
command: npm run unit | ||
when: always | ||
- run: | ||
name: Run e2e tests | ||
command: npm run e2e | ||
when: always | ||
- run: | ||
name: Test build | ||
command: npm run build | ||
when: always | ||
|
||
scenario_full-karma-airbnb: | ||
<<: *vm_settings | ||
working_directory: ~/project/webpack-template/test-full-karma-airbnb | ||
environment: | ||
- VUE_TEMPL_TEST: full-karma-airbnb | ||
steps: | ||
- attach_workspace: | ||
at: '~/project/webpack-template' | ||
- restore_cache: | ||
key: template-cache-full-karma-airbnb-{{ checksum "package.json" }} | ||
- run: | ||
name: Install npm dependencies | ||
command: npm install | ||
- save_cache: | ||
key: template-cache-full-karma-airbnb-{{ checksum "package.json" }} | ||
paths: | ||
- node_modules | ||
- run: | ||
name: Run Lint | ||
command: npm run lint -- --fix | ||
- run: | ||
name: Run Unit tests | ||
command: npm run unit | ||
when: always | ||
- run: | ||
name: Run e2e tests | ||
command: npm run e2e | ||
when: always | ||
- run: | ||
name: Test build | ||
command: npm run build | ||
when: always | ||
|
||
|
||
workflows: | ||
version: 2 | ||
build_and_test: | ||
jobs: | ||
- install_template_deps | ||
- scenario_minimal: | ||
requires: | ||
- install_template_deps | ||
- scenario_full: | ||
requires: | ||
- install_template_deps | ||
- scenario_full-karma-airbnb: | ||
requires: | ||
- install_template_deps |
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
## What is this folder? | ||
|
||
This folder contains test scenarios for the automated tests of the template on CircleCI. | ||
|
||
Each `.json`file contains an object that represents a set of answers to the questions that vue-cli asks the user when installing the template. | ||
|
||
With the code from `index.js`, we insert those answers into the metalsmith metadata and skip the inquirer questions, thus allowing us to run different test scenarios in CI without having to actually provide any answers to inquirer or to mock it. | ||
|
||
## The scenarios | ||
|
||
We currently have 3 scenrios set up: | ||
|
||
1. 'minimal': it basically answers "no" to ever choice, so no router, no elint, no tests | ||
2. 'full': It answers "yes" to every choice. With router, with linting (standard), with full tests (jest & e2e) | ||
3. 'full-airbnb-karma': like 'full', but using airbnb eslint config instead od standard and karma instead of jest for unnit tests. | ||
|
||
Other permutations might be worth testing to secure against edge cases, but this gives us a decent level of security over common combinations. | ||
|
||
## How to use it? | ||
|
||
Choosing a scenario is done through setting an ENV variable named `VUE_TEMPL_TEST`. | ||
|
||
You can run a scenario yourself by running this in your terminal: | ||
|
||
```` | ||
VUE_TEMPL_TEST=minimal vue init webpack your-directory | ||
``` |
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,14 @@ | ||
{ | ||
"noEscape": true, | ||
"name": "test", | ||
"description": "A Vue.js project", | ||
"author": "CircleCI", | ||
"build": "standalone", | ||
"router": false, | ||
"lint": true, | ||
"lintConfig": "airbnb", | ||
"unit": true, | ||
"runner": "karma", | ||
"e2e": true, | ||
"autoInstall": false | ||
} |
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,14 @@ | ||
{ | ||
"noEscape": true, | ||
"name": "test", | ||
"description": "A Vue.js project", | ||
"author": "CircleCI", | ||
"build": "runtime", | ||
"router": false, | ||
"lint": true, | ||
"lintConfig": "standard", | ||
"unit": true, | ||
"runner": "jest", | ||
"e2e": true, | ||
"autoInstall": false | ||
} |
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,19 @@ | ||
const scenarios = [ | ||
'full', | ||
'full-karma-airbnb', | ||
'minimal' | ||
] | ||
|
||
const index = scenarios.indexOf(process.env.VUE_TEMPL_TEST) | ||
|
||
const isTest = exports.isTest = index !== -1 | ||
|
||
const scenario = isTest && require(`./${scenarios[index]}.json`) | ||
|
||
exports.addTestAnswers = (metalsmith, options, helpers) => { | ||
Object.assign(metalsmith.metadata(), { | ||
isNotTest: !isTest, | ||
...(isTest ? scenario : undefined) | ||
}) | ||
// console.log(metalsmith.metadata()) | ||
} |
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,14 @@ | ||
{ | ||
"noEscape": true, | ||
"name": "test-minimal", | ||
"description": "Testing the minimal template setup", | ||
"author": "CircleCI", | ||
"build": "standalone", | ||
"router": false, | ||
"lint": false, | ||
"lintConfig": "standard", | ||
"unit": false, | ||
"runner": "jest", | ||
"e2e": false, | ||
"autoInstall": false | ||
} |
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