ci: use cimg/node:lts and node orb

This commit is contained in:
Christopher Willis-Ford 2022-08-25 10:44:51 -07:00
parent 123759233c
commit 6556f414f1

View file

@ -1,8 +1,11 @@
version: 2.1 version: 2.1
orbs:
node: circleci/node@5.0.2
browser-tools: circleci/browser-tools@1.2.4
aliases: aliases:
- &defaults - &defaults
docker: docker:
- image: cimg/node:12.22.11-browsers - image: cimg/node:lts-browsers
auth: auth:
username: $DOCKERHUB_USERNAME username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD password: $DOCKERHUB_PASSWORD
@ -10,94 +13,86 @@ aliases:
environment: environment:
NODE_ENV: production NODE_ENV: production
- &setup - &setup
name: "setup" node/install-packages:
command: | override-ci-command: npm --production=false ci
npm --production=false ci
mkdir ./test/results
- &lint - &lint
name: "run lint tests" run:
command: npm run lint -- --format junit -o ./test/results/lint-results.xml name: "run lint tests"
command: npm run lint -- --format junit -o ./test/results/lint-results.xml
- &unit - &unit
name: "run unit tests" run:
command: JEST_JUNIT_OUTPUT_NAME=unit-jest-results.xml npm run unit -- --reporters=jest-junit name: "run unit tests"
command: JEST_JUNIT_OUTPUT_NAME=unit-jest-results.xml npm run unit -- --reporters=jest-junit
- &build - &build
name: "run npm build" run:
command: | name: "run npm build"
NODE_ENV=production npm run build command: |
NODE_ENV=production npm run build
- &tag-setup - &tag-setup
name: "setup tags" run:
command: | name: "setup tags"
RELEASE_TIMESTAMP="$(date +'%Y%m%d%H%M%S')" command: |
VPKG=$($(npm bin)/json -f package.json version) RELEASE_TIMESTAMP="$(date +'%Y%m%d%H%M%S')"
echo export RELEASE_VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP} >> $BASH_ENV VPKG=$($(npm bin)/json -f package.json version)
echo export NPM_TAG=latest >> $BASH_ENV echo export RELEASE_VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP} >> $BASH_ENV
if [[ "$CIRCLE_BRANCH" == hotfix/* ]]; then # double brackets are important for matching the wildcard echo export NPM_TAG=latest >> $BASH_ENV
echo export NPM_TAG=hotfix >> $BASH_ENV if [[ "$CIRCLE_BRANCH" == hotfix/* ]]; then # double brackets are important for matching the wildcard
fi echo export NPM_TAG=hotfix >> $BASH_ENV
fi
- &deploy-gh-pages - &deploy-gh-pages
name: "deploy to gh pages" run:
command: | name: "deploy to gh pages"
git config --global user.email $(git log --pretty=format:"%ae" -n1) command: |
git config --global user.name $(git log --pretty=format:"%an" -n1) git config --global user.email $(git log --pretty=format:"%ae" -n1)
npm run deploy -- -e $CIRCLE_BRANCH git config --global user.name $(git log --pretty=format:"%an" -n1)
npm run deploy -- -e $CIRCLE_BRANCH
- &deploy-npm - &deploy-npm
name: "deploy to npm" run:
command: | name: "deploy to npm"
echo "npm tag: $NPM_TAG" command: |
echo "release version: $RELEASE_VERSION" echo "npm tag: $NPM_TAG"
npm version --no-git-tag-version $RELEASE_VERSION echo "release version: $RELEASE_VERSION"
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN npm version --no-git-tag-version $RELEASE_VERSION
npm publish --tag $NPM_TAG npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
npm publish --tag $NPM_TAG
- &tag-commit - &tag-commit
name: "tag commit in github" run:
command: | name: "tag commit in github"
echo $RELEASE_VERSION command: |
git tag $RELEASE_VERSION echo $RELEASE_VERSION
git push $CIRCLE_REPOSITORY_URL $RELEASE_VERSION git tag $RELEASE_VERSION
git push $CIRCLE_REPOSITORY_URL $RELEASE_VERSION
jobs: jobs:
build-test: build-test:
<<: *defaults <<: *defaults
steps: steps:
- checkout - checkout
- run: - *setup
<<: *setup - *lint
- run: - *unit
<<: *lint - *build
- run:
<<: *unit
- run:
<<: *build
- store_test_results: - store_test_results:
path: test/results path: test/results
build-test-deploy: build-test-deploy:
<<: *defaults <<: *defaults
steps: steps:
- checkout - checkout
- run: - *setup
<<: *setup - *lint
- run: - *unit
<<: *lint - *build
- run:
<<: *unit
- run:
<<: *build
- store_test_results: - store_test_results:
path: test/results path: test/results
- run: - *tag-setup
<<: *tag-setup - *deploy-gh-pages
- run: - *deploy-npm
<<: *deploy-gh-pages - *tag-commit
- run:
<<: *deploy-npm
- run:
<<: *tag-commit
push-translations: push-translations:
<<: *defaults <<: *defaults
steps: steps:
- checkout - checkout
- run: - *setup
<<: *setup
- run: - run:
name: "run i18n script" name: "run i18n script"
command: | command: |