192 строки
5.4 KiB
YAML
192 строки
5.4 KiB
YAML
# These environment variables must be set in CircleCI UI
|
|
#
|
|
# NPM_TOKEN - A valid NPM token for releases
|
|
version: 2.1
|
|
|
|
orbs:
|
|
codecov: codecov/codecov@3.2.4
|
|
|
|
references:
|
|
defaults: &defaults
|
|
working_directory: ~/addons-linter
|
|
docker:
|
|
# This is the NodeJS version we run in production.
|
|
- image: cimg/node:18.20
|
|
|
|
defaults-next: &defaults-next
|
|
<<: *defaults
|
|
docker:
|
|
# This is the next NodeJS version we will support.
|
|
- image: cimg/node:20.17
|
|
|
|
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.
|
|
- image: cimg/node:22.7
|
|
|
|
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_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
|
|
|
|
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
|
|
|
|
jobs:
|
|
test:
|
|
<<: *defaults
|
|
steps:
|
|
- checkout
|
|
- *restore_build_cache
|
|
- *run_npm_install
|
|
- *save_build_cache
|
|
- *make_production_build
|
|
- run: npm run test-ci
|
|
- codecov/upload
|
|
# 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
|
|
- 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
|
|
# 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: .
|
|
# This should run after we persist the workspace because this command
|
|
# invokes `npm install`.
|
|
- run: npm run webext-test-functional
|
|
- run: npm run smoke-test-eslint-version-conflicts
|
|
- 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
|
|
- run: npm run smoke-test-eslint-version-conflicts
|
|
|
|
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
|
|
- run: npm run smoke-test-eslint-version-conflicts
|
|
|
|
lint-locales:
|
|
working_directory: ~/addons-linter
|
|
docker:
|
|
- image: cimg/python:3.11.3
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: lint locale files
|
|
command: |
|
|
pip install dennis
|
|
dennis-cmd lint --errorsonly locale/
|
|
|
|
release-tag:
|
|
<<: *defaults
|
|
steps:
|
|
- attach_workspace:
|
|
at: ~/addons-linter
|
|
- run:
|
|
name: authenticate with registry
|
|
# We don't want to expand the token in this file, npm will do it.
|
|
command: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > ~/addons-linter/.npmrc
|
|
- 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
|
|
- test-alternate
|
|
- lint-locales
|
|
- release-tag:
|
|
requires:
|
|
- test
|
|
filters:
|
|
tags:
|
|
only: /.*/
|
|
branches:
|
|
ignore: /.*/
|