Skip to content

Commit

Permalink
Simplify CI setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Glen Mailer committed Jan 31, 2021
1 parent 0635d00 commit d156bbc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 151 deletions.
184 changes: 37 additions & 147 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,159 +1,49 @@
version: 2
version: 2.1

unit_tests: &unit_tests
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: NPM Rebuild
command: npm install
- run:
name: Run unit tests.
command: npm run ci:test
canary_tests: &canary_tests
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: NPM Rebuild
command: npm install
- run:
name: Install Webpack Canary
command: npm i --no-save webpack@next
- run:
name: Run unit tests.
command: if [[ $(compver --name webpack --gte next --lt latest) < 1 ]] ; then printf "Next is older than Latest - Skipping Canary Suite"; else npm run ci:test ; fi
workflows:
workflow:
jobs:
- lint:
filters:
tags:
only: /.*/
- test:
matrix:
parameters:
node_version: [lts, current]
filters:
tags:
only: /.*/

jobs:
dependency_cache:
docker:
- image: webpackcontrib/circleci-node-base:latest
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- ./node_modules

node8-latest:
docker:
- image: webpackcontrib/circleci-node8:latest
commands:
setup:
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: NPM Rebuild
command: npm install
- run:
name: Run unit tests.
command: npm run ci:coverage
- run:
name: Submit coverage data to codecov.
command: bash <(curl -s https://codecov.io/bash)
when: on_success
node6-latest:
docker:
- image: webpackcontrib/circleci-node6:latest
<<: *unit_tests
node9-latest:
docker:
- image: webpackcontrib/circleci-node9:latest
<<: *unit_tests
node8-canary:
docker:
- image: webpackcontrib/circleci-node8:latest
<<: *canary_tests
analysis:
keys:
- npm-cache-{{ checksum "package-lock.json" }}
- npm-cache-
- run: npm ci

jobs:
lint:
working_directory: /mnt/ramdisk
docker:
- image: webpackcontrib/circleci-node-base:latest
- image: cimg/node:lts
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Install Latest NPM.
command: npm i -g npm@latest
- setup
- run:
name: NPM Rebuild
command: npm install
- run:
name: Run linting.
command: npm run lint
- run:
name: Run NSP Security Check.
command: npm run security
# - run:
# name: Validate Commit Messages
# command: npm run ci:lint:commits
publish:
when: always

test:
parameters:
node_version:
type: string
docker:
- image: webpackcontrib/circleci-node-base:latest
- image: cimg/node:<< parameters.node_version >>
working_directory: /mnt/ramdisk
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: NPM Rebuild
command: npm install
# - run:
# name: Validate Commit Messages
# command: npm run release:validate
- run:
name: Publish to NPM
command: printf "noop running conventional-github-releaser"

workflows:
version: 2
validate-publish:
jobs:
- dependency_cache
- node6-latest:
requires:
- dependency_cache
filters:
tags:
only: /.*/
- analysis:
requires:
- dependency_cache
filters:
tags:
only: /.*/
- node8-latest:
requires:
- analysis
- node6-latest
filters:
tags:
only: /.*/
- node9-latest:
requires:
- analysis
- node6-latest
filters:
tags:
only: /.*/
- node8-canary:
requires:
- analysis
- node6-latest
filters:
tags:
only: /.*/
- publish:
requires:
- node8-latest
- node8-canary
- node9-latest
filters:
branches:
only:
- master
- setup
- run: npm test
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
"main": "middleware.js",
"scripts": {
"test": "mocha",
"security": "npm audit",
"ci:lint": "npm run lint && npm run security",
"ci:test": "npm run test",
"ci:coverage": "nyc npm run test",
"coverage": "nyc npm run test",
"lint": "eslint . --max-warnings 0",
"prettier": "prettier --write ."
},
Expand Down

0 comments on commit d156bbc

Please sign in to comment.