2020-12-15 21:58:40 +03:00
|
|
|
# These environment variables must be set in CircleCI UI
|
|
|
|
#
|
|
|
|
# NPM_TOKEN - A valid NPM token for releases
|
|
|
|
version: 2.1
|
|
|
|
|
2021-10-27 21:14:48 +03:00
|
|
|
orbs:
|
2022-06-07 01:55:03 +03:00
|
|
|
codecov: codecov/codecov@3.2.3
|
2021-10-27 21:14:48 +03:00
|
|
|
|
2020-12-15 21:58:40 +03:00
|
|
|
references:
|
|
|
|
defaults: &defaults
|
|
|
|
working_directory: ~/addons-linter
|
|
|
|
docker:
|
|
|
|
# This is the NodeJS version we run in production.
|
2022-07-28 17:03:14 +03:00
|
|
|
- image: cimg/node:14.20
|
2020-12-15 21:58:40 +03:00
|
|
|
|
|
|
|
defaults-next: &defaults-next
|
2021-07-08 13:13:47 +03:00
|
|
|
<<: *defaults
|
2020-12-15 21:58:40 +03:00
|
|
|
docker:
|
|
|
|
# This is the next NodeJS version we will support.
|
2022-10-13 11:56:08 +03:00
|
|
|
- image: cimg/node:16.18
|
2020-12-15 21:58:40 +03:00
|
|
|
|
2021-07-08 13:13:47 +03:00
|
|
|
defaults-alternate: &defaults-alternate
|
|
|
|
<<: *defaults
|
|
|
|
docker:
|
|
|
|
# This is an alternate Node version we support or want to support in the
|
|
|
|
# (far) future. It can either be lower or higher than the current Node
|
|
|
|
# version we run in production.
|
2022-10-04 11:43:40 +03:00
|
|
|
- image: cimg/node:18.10
|
2022-03-28 16:02:30 +03:00
|
|
|
environment:
|
|
|
|
## workaround `npm run build` issue triggered by webpack
|
|
|
|
## on nodejs 17.
|
|
|
|
NODE_OPTIONS: --openssl-legacy-provider
|
2021-07-08 13:13:47 +03:00
|
|
|
|
2020-12-15 21:58:40 +03:00
|
|
|
restore_build_cache: &restore_build_cache
|
|
|
|
restore_cache:
|
|
|
|
name: restore npm package cache
|
|
|
|
keys:
|
|
|
|
- npm-packages-{{ checksum "package-lock.json" }}
|
|
|
|
|
|
|
|
run_npm_install: &run_npm_install
|
|
|
|
run:
|
|
|
|
name: install dependencies
|
|
|
|
command: npm install
|
|
|
|
|
|
|
|
save_build_cache: &save_build_cache
|
|
|
|
save_cache:
|
|
|
|
name: save npm package cache
|
|
|
|
key: npm-packages-{{ checksum "package-lock.json" }}
|
|
|
|
paths:
|
|
|
|
- ./node_modules
|
|
|
|
|
|
|
|
make_production_build: &make_production_build
|
|
|
|
run:
|
|
|
|
name: build project
|
|
|
|
command: |
|
|
|
|
node scripts/build-locales
|
|
|
|
NODE_ENV=production npm run build
|
|
|
|
|
|
|
|
restore_next_build_cache: &restore_next_build_cache
|
|
|
|
restore_cache:
|
|
|
|
name: restore npm package cache
|
|
|
|
keys:
|
|
|
|
- next-npm-packages-{{ checksum "package-lock.json" }}
|
|
|
|
|
|
|
|
save_next_build_cache: &save_next_build_cache
|
|
|
|
save_cache:
|
|
|
|
name: save npm package cache
|
|
|
|
key: next-npm-packages-{{ checksum "package-lock.json" }}
|
|
|
|
paths:
|
|
|
|
- ./node_modules
|
|
|
|
|
2021-07-08 13:13:47 +03:00
|
|
|
restore_alternate_build_cache: &restore_alternate_build_cache
|
|
|
|
restore_cache:
|
|
|
|
name: restore npm package cache
|
|
|
|
keys:
|
|
|
|
- alternate-npm-packages-{{ checksum "package-lock.json" }}
|
|
|
|
|
|
|
|
save_alternate_build_cache: &save_alternate_build_cache
|
|
|
|
save_cache:
|
|
|
|
name: save npm package cache
|
|
|
|
key: alternate-npm-packages-{{ checksum "package-lock.json" }}
|
|
|
|
paths:
|
|
|
|
- ./node_modules
|
|
|
|
|
2020-12-15 21:58:40 +03:00
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
<<: *defaults
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- *restore_build_cache
|
|
|
|
- *run_npm_install
|
|
|
|
- *save_build_cache
|
|
|
|
- *make_production_build
|
|
|
|
- run: npm run test-ci
|
2021-10-27 21:14:48 +03:00
|
|
|
- codecov/upload
|
2020-12-15 21:58:40 +03:00
|
|
|
# run integration tests using an addons-linter binary in a
|
|
|
|
# production-like environment
|
|
|
|
- run: npm run test-integration:production
|
|
|
|
- run: npm run lint
|
|
|
|
- run: npm run prettier-ci
|
2021-08-03 16:09:00 +03:00
|
|
|
- run:
|
|
|
|
name: build rules
|
|
|
|
command: |
|
|
|
|
npm run build-rules
|
|
|
|
# This will return a non-zero exit code if content in the docs/
|
|
|
|
# folder has changed. When this fails, run the following command
|
|
|
|
# and commit the changes:
|
|
|
|
#
|
|
|
|
# npm run build-rules
|
|
|
|
#
|
|
|
|
git diff --name-only --exit-code docs
|
2020-12-15 21:58:40 +03:00
|
|
|
# Set up a workspace to share data between this job and the `release-tag`
|
|
|
|
# one when we want to publish a new npm version.
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: ~/addons-linter
|
|
|
|
paths: .
|
2021-06-11 15:11:47 +03:00
|
|
|
# This should run after we persist the workspace because this command
|
|
|
|
# invokes `npm install`.
|
|
|
|
- run: npm run webext-test-functional
|
2021-12-13 20:09:43 +03:00
|
|
|
- run: npm run smoke-test-eslint-version-conflicts
|
2020-12-15 21:58:40 +03:00
|
|
|
- store_artifacts:
|
|
|
|
path: coverage
|
|
|
|
|
|
|
|
test-next:
|
|
|
|
<<: *defaults-next
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- *restore_next_build_cache
|
|
|
|
- *run_npm_install
|
|
|
|
- *save_next_build_cache
|
|
|
|
- *make_production_build
|
|
|
|
- run: npm run test-ci
|
|
|
|
# run integration tests using an addons-linter binary in a
|
|
|
|
# production-like environment
|
|
|
|
- run: npm run test-integration:production
|
|
|
|
- run: npm run webext-test-functional
|
2021-12-13 20:09:43 +03:00
|
|
|
- run: npm run smoke-test-eslint-version-conflicts
|
2020-12-15 21:58:40 +03:00
|
|
|
|
2021-07-08 13:13:47 +03:00
|
|
|
test-alternate:
|
|
|
|
<<: *defaults-alternate
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- *restore_alternate_build_cache
|
|
|
|
- *run_npm_install
|
|
|
|
- *save_alternate_build_cache
|
|
|
|
- *make_production_build
|
|
|
|
- run: npm run test-ci
|
|
|
|
# run integration tests using an addons-linter binary in a
|
|
|
|
# production-like environment
|
|
|
|
- run: npm run test-integration:production
|
|
|
|
- run: npm run webext-test-functional
|
2021-12-13 20:09:43 +03:00
|
|
|
- run: npm run smoke-test-eslint-version-conflicts
|
2021-07-08 13:13:47 +03:00
|
|
|
|
2020-12-15 21:58:40 +03:00
|
|
|
release-tag:
|
|
|
|
<<: *defaults
|
|
|
|
steps:
|
|
|
|
- attach_workspace:
|
|
|
|
at: ~/addons-linter
|
|
|
|
- run:
|
|
|
|
name: authenticate with registry
|
2020-12-18 16:07:40 +03:00
|
|
|
# We don't want to expand the token in this file, npm will do it.
|
2020-12-18 17:48:05 +03:00
|
|
|
command: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > ~/addons-linter/.npmrc
|
2020-12-15 21:58:40 +03:00
|
|
|
- run:
|
|
|
|
name: publish package
|
|
|
|
command: npm publish
|
|
|
|
|
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
default-workflow:
|
|
|
|
jobs:
|
|
|
|
- test:
|
|
|
|
filters: # required since `release-tag` has tag filters AND requires `test`
|
|
|
|
tags:
|
|
|
|
only: /.*/
|
|
|
|
- test-next
|
2021-07-08 13:13:47 +03:00
|
|
|
- test-alternate
|
2020-12-15 21:58:40 +03:00
|
|
|
- release-tag:
|
|
|
|
requires:
|
|
|
|
- test
|
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /.*/
|
|
|
|
branches:
|
|
|
|
ignore: /.*/
|