|
1 |
| -# Javascript Node CircleCI 2.0 configuration file |
2 |
| -# |
3 |
| -# Check https://circleci.com/docs/2.0/language-javascript/ for more details |
4 |
| -# |
| 1 | +# Cache key for CircleCI. We want to invalidate the cache whenever the npm shrinkwrap |
| 2 | +# changed. |
| 3 | +var_1: &cache_key preboot-{{ checksum "npm-shrinkwrap.json" }} |
| 4 | +# Use the CircleCI browsers image that comes with NodeJS installed |
| 5 | +var_2: &default_docker_image circleci/node:10.12-browsers |
| 6 | + |
| 7 | +# Settings common to each job |
| 8 | +var_3: &job_defaults |
| 9 | + working_directory: ~/ng |
| 10 | + docker: |
| 11 | + - image: *default_docker_image |
| 12 | + |
| 13 | +# Job step for checking out the source code from GitHub. This also ensures that the source code |
| 14 | +# is rebased on top of master. |
| 15 | +var_4: &checkout_code |
| 16 | + checkout: |
| 17 | + # After checkout, rebase on top of master. By default, PRs are not rebased on top of master, |
| 18 | + # which we want. See https://discuss.circleci.com/t/1662 |
| 19 | + post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge" |
| 20 | + |
| 21 | +# Restores the cache that could be available for the current Yarn lock file. The cache usually |
| 22 | +# includes the node modules. |
| 23 | +var_5: &restore_cache |
| 24 | + restore_cache: |
| 25 | + key: *cache_key |
| 26 | + |
| 27 | +# Saves the cache for the current Yarn lock file. We store the node modules |
| 28 | +# in order to make subsequent builds faster. |
| 29 | +var_6: &save_cache |
| 30 | + save_cache: |
| 31 | + key: *cache_key |
| 32 | + paths: |
| 33 | + - "node_modules" |
| 34 | + |
| 35 | +# Job step that ensures that the node module dependencies are installed and up-to-date. We use |
| 36 | +# Yarn with the frozen lockfile option in order to make sure that lock file and package.json are |
| 37 | +# in sync. Unlike in Travis, we don't need to manually purge the node modules if stale because |
| 38 | +# CircleCI automatically discards the cache if the checksum of the lock file has changed. |
| 39 | +var_7: &yarn_install |
| 40 | + run: yarn install --frozen-lockfile --non-interactive |
| 41 | + |
| 42 | +# Attaches the release output which has been stored in the workspace to the current job. |
| 43 | +# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs |
| 44 | +var_8: &attach_release_output |
| 45 | + attach_workspace: |
| 46 | + at: dist/ |
| 47 | + |
| 48 | + |
| 49 | +# ----------------------------- |
| 50 | +# Container version of CircleCI |
| 51 | +# ----------------------------- |
5 | 52 | version: 2
|
| 53 | + |
| 54 | +# ----------------------------------------------------------------------------------------- |
| 55 | +# Job definitions. Jobs which are defined just here, will not run automatically. Each job |
| 56 | +# must be part of a workflow definition in order to run for PRs and push builds. |
| 57 | +# ----------------------------------------------------------------------------------------- |
6 | 58 | jobs:
|
| 59 | + |
7 | 60 | build:
|
8 |
| - docker: |
9 |
| - # specify the version you desire here |
10 |
| - - image: circleci/node:8.9 |
| 61 | + <<: *job_defaults |
| 62 | + steps: |
| 63 | + - *checkout_code |
| 64 | + - *restore_cache |
| 65 | + - *yarn_install |
| 66 | + |
| 67 | + - run: npm run build |
| 68 | + |
| 69 | + # Store the release output in the workspace storage. This means that other jobs |
| 70 | + # in the same workflow can attach the release output to their job. |
| 71 | + - persist_to_workspace: |
| 72 | + root: dist |
| 73 | + paths: |
| 74 | + - "*" |
| 75 | + - "**/*" |
| 76 | + |
| 77 | + - *save_cache |
| 78 | + |
| 79 | + test: |
| 80 | + <<: *job_defaults |
| 81 | + steps: |
| 82 | + - *checkout_code |
| 83 | + - *restore_cache |
| 84 | + - *yarn_install |
11 | 85 |
|
12 |
| - # Specify service dependencies here if necessary |
13 |
| - # CircleCI maintains a library of pre-built images |
14 |
| - # documented at https://circleci.com/docs/2.0/circleci-images/ |
15 |
| - # - image: circleci/mongo:3.4.4 |
| 86 | + - run: npm run test:once |
16 | 87 |
|
17 |
| - working_directory: ~/repo |
| 88 | + - *save_cache |
18 | 89 |
|
| 90 | + e2e: |
| 91 | + <<: *job_defaults |
19 | 92 | steps:
|
20 |
| - - checkout |
| 93 | + - *checkout_code |
| 94 | + - *restore_cache |
| 95 | + - *attach_release_output |
21 | 96 |
|
22 |
| - # Download and cache dependencies |
23 |
| - - restore_cache: |
24 |
| - keys: |
25 |
| - - v1-dependencies-{{ checksum "package.json" }} |
26 |
| - # fallback to using the latest cache if no exact match is found |
27 |
| - - v1-dependencies- |
| 97 | + - run: npm run e2e |
28 | 98 |
|
29 |
| - - run: npm install |
| 99 | + - *save_cache |
30 | 100 |
|
31 |
| - - save_cache: |
32 |
| - paths: |
33 |
| - - node_modules |
34 |
| - key: v1-dependencies-{{ checksum "package.json" }} |
| 101 | +# ---------------------------------------------------------------------------------------- |
| 102 | +# Workflow definitions. A workflow usually groups multiple jobs together. This is useful if |
| 103 | +# one job depends on another. |
| 104 | +# ---------------------------------------------------------------------------------------- |
| 105 | +workflows: |
| 106 | + version: 2 |
35 | 107 |
|
36 |
| - # run the build! |
37 |
| - - run: npm run build |
| 108 | + build_and_test: |
| 109 | + jobs: |
| 110 | + - build |
| 111 | + - test |
| 112 | + - e2e: |
| 113 | + requires: |
| 114 | + - build |
0 commit comments