mirror of
https://github.com/vale981/apollo-server
synced 2025-03-04 17:21:42 -05:00

This should hopefully make it easier to quickly identify failing tests within the CircleCI interface since CircleCI will be able to programmatically consume the test results.
114 lines
4 KiB
YAML
114 lines
4 KiB
YAML
version: 2
|
|
|
|
#
|
|
# Reusable Snippets!
|
|
#
|
|
# These are re-used by the various tests below, to avoid repetition.
|
|
#
|
|
run_install_desired_npm: &run_install_desired_npm
|
|
run:
|
|
# Due to a bug, npm upgrades from the version of npm that ships with
|
|
# Node.js 6 (npm v3.10.10) go poorly and generally causes other problems
|
|
# with the environment. Since yarn is already available here we can just
|
|
# use that to work-around the issue. It's possible that npm cleanup might
|
|
# prevent this from being necessary, but this installation can be switched
|
|
# to use `npm` (rather than `yarn`) once Node 6 is no longer tested below.
|
|
name: Install npm@6, but with yarn.
|
|
command: sudo yarn global add npm@6
|
|
|
|
# These are the steps used for each version of Node which we're testing
|
|
# against. Thanks to YAMLs inability to merge arrays (though it is able
|
|
# to merge objects), every version of Node must use the exact same steps,
|
|
# or these steps would need to be repeated in a version of Node that needs
|
|
# something different. Probably best to avoid that, out of principle, though.
|
|
common_test_steps: &common_test_steps
|
|
steps:
|
|
- *run_install_desired_npm
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
# When lock file changes, use increasingly general patterns to restore cache
|
|
- npm-v2-{{ .Branch }}-{{ checksum "package-lock.json" }}
|
|
- npm-v2-{{ .Branch }}-
|
|
- npm-v2-
|
|
- run: npm --version
|
|
- run: npm ci
|
|
- save_cache:
|
|
key: npm-v2-{{ .Branch }}-{{ checksum "package-lock.json" }}
|
|
paths:
|
|
# This should cache the npm cache instead of node_modules, which is needed because
|
|
# npm ci actually removes node_modules before installing to guarantee a clean slate.
|
|
- ~/.npm
|
|
- run:
|
|
command: npm run test:ci
|
|
environment:
|
|
JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml"
|
|
- run: npm run coverage:upload
|
|
- store_test_results:
|
|
path: reports/junit
|
|
- store_artifacts:
|
|
path: reports/junit
|
|
|
|
# Important! When adding a new job to `jobs`, make sure to define when it
|
|
# executes by also adding it to the `workflows` section below!
|
|
jobs:
|
|
# Platform tests, each with the same tests but different platform or version.
|
|
# The docker tag represents the Node.js version and the full list is available
|
|
# at https://hub.docker.com/r/circleci/node/.
|
|
|
|
# NODE: Note certain tests are currently being skipped for Node.js 6.
|
|
Node.js 6:
|
|
docker: [{ image: 'circleci/node:6' }]
|
|
<<: *common_test_steps
|
|
|
|
Node.js 8:
|
|
docker: [{ image: 'circleci/node:8' }]
|
|
<<: *common_test_steps
|
|
|
|
# NODE: Note certain tests are currently being skipped for Node.js 10.
|
|
Node.js 10:
|
|
docker: [{ image: 'circleci/node:10' }]
|
|
<<: *common_test_steps
|
|
|
|
# Other tests, unrelated to typical code tests.
|
|
Linting:
|
|
docker: [{ image: 'circleci/node:8' }]
|
|
steps:
|
|
# (speed) Intentionally omitted, unnecessary, run_install_desired_npm.
|
|
- checkout
|
|
# (speed) --ignore-scripts to skip unnecessary Lerna build during linting.
|
|
- run: npm install --ignore-scripts
|
|
- run: npm run lint
|
|
Docs:
|
|
docker: [{ image: 'circleci/node:8' }]
|
|
steps:
|
|
# (speed) Intentionally omitted, unnecessary, run_install_desired_npm.
|
|
- checkout
|
|
- restore_cache:
|
|
key: dependency-cache-{{ checksum "./docs/package.json" }}
|
|
# (speed) Ignore scripts to skip the Lerna build stuff for linting.
|
|
- run: npm install-test --prefix ./docs
|
|
- save_cache:
|
|
key: dependency-cache-{{ checksum "./docs/package.json" }}
|
|
paths:
|
|
- ./docs/node_modules
|
|
|
|
ignore_doc_branches: &ignore_doc_branches
|
|
filters:
|
|
branches:
|
|
# If 'docs' is found, with word boundaries on either side, skip.
|
|
ignore: /.*?\bdocs\b.*/
|
|
|
|
workflows:
|
|
version: 2
|
|
Build and Test:
|
|
jobs:
|
|
- Node.js 6:
|
|
<<: *ignore_doc_branches
|
|
- Node.js 8:
|
|
<<: *ignore_doc_branches
|
|
- Node.js 10:
|
|
<<: *ignore_doc_branches
|
|
- Linting:
|
|
<<: *ignore_doc_branches
|
|
- Docs
|