.circleci/config.yml
version: 2
defaults: &defaults
working_directory: ~/scatter
# Available images https://hub.docker.com/r/circleci/node/tags/
aliases:
- &restore_yarn_cache
name: Restore yarn cache
keys:
- yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-packages-{{ .Branch }}
- yarn-packages-
- &save_yarn_cache
name: Save yarn cache
paths:
- ~/.cache/yarn
key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
jobs:
install:
<<: *defaults
docker:
- image: cimg/node:lts
steps:
- checkout
- restore_cache: *restore_yarn_cache
- run: yarn install --frozen-lockfile
- save_cache: *save_yarn_cache
- store_artifacts:
path: package.json
- persist_to_workspace:
root: ~/scatter
paths:
- .
build:
<<: *defaults
docker:
- image: cimg/node:lts-browsers
- image: mcr.microsoft.com/playwright:focal
steps:
- attach_workspace:
at: ~/scatter
- run:
name: Build
command: yarn run build
- run:
name: Lint
command: yarn run lint
- run:
name: Update spec
command: yarn run spec
- run:
name: Run unit tests and publish to codeclimate
command: |
if [ ! -z "$CC_TEST_REPORTER_ID" ]; then
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
yarn run test:unit --maxWorkers=2 --coverage
./cc-test-reporter after-build --coverage-input-type lcov --exit-code $?
fi
- run:
name: Install Playwright
command: |
npx playwright install
- run:
name: Install Fonts
command: |
sudo apt-get update
sudo apt-get install cabextract
sudo wget https://www.freedesktop.org/software/fontconfig/webfonts/webfonts.tar.gz
sudo tar -xzf webfonts.tar.gz
cd msfonts/
sudo cabextract *.exe
sudo cp *.ttf *.TTF /usr/share/fonts/
- run:
name: Rendering tests
command: yarn test:rendering
- store_artifacts:
path: test/rendering/index.spec.js-snapshots
- store_artifacts:
path: ./test/rendering/__artifacts__
- store_artifacts:
path: test/rendering/test-report
- run:
name: Integration tests
command: yarn test:integration
- store_artifacts:
path: test/integration/index.spec.js-snapshots
- store_artifacts:
path: ./test/integration/__artifacts__
- store_artifacts:
path: test/integration/test-report
- persist_to_workspace:
root: ~/scatter
paths:
- .
publish-dev:
<<: *defaults
docker:
- image: cimg/node:lts
steps:
- attach_workspace:
at: ~/scatter
- run: zip -r "sn-scatter-plot-ext.zip" "./sn-scatter-plot-ext"
- store_artifacts:
path: ./sn-scatter-plot-ext.zip
publish:
<<: *defaults
docker:
- image: cimg/node:lts
steps:
- attach_workspace:
at: ~/scatter
- run:
name: Setup npm
command: |
set -eo pipefail
# Amend auth token for access to public npm registry for @nebula.js packages
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run:
name: Publish
command: |
set -euo pipefail
PROJ_VER=v$(cat package.json | jq -r '.version')
TAG_NAME=$(git tag --points-at HEAD)
if [ "$TAG_NAME" == "$PROJ_VER" ]
then
echo "Running >> npm publish"
npm publish
fi
api-governance:
machine:
image: ubuntu-2004:current
working_directory: ~/project
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: Create version.txt
command: |
set -x
if [ -n "${CIRCLE_TAG}" ]; then
version=${CIRCLE_TAG#v}
else
version=$(git describe --tags --abbrev=7 --match "v*")
version=${version#v}
fi
echo "$version" > ./version.txt
echo "Building $version"
- run:
name: Prepare API Compliance
command: |
docker pull ghcr.io/qlik-download/api-compliance
docker create -v /specs --name specs alpine:3.4 /bin/true
docker cp ./api-specifications/properties.json specs:/specs
docker cp ./api-specifications/plugins.json specs:/specs
- run:
name: Run API Compliance
command: >
VER=$(cat ./version.txt)
docker run --volumes-from specs
-e SPEC_PATHS="0395aa3a-3d13-439f-a0a6-3d47e0462a8f@/specs/properties.json,86d3d254-a759-433c-b235-c14b479b4521@/specs/plugins.json"
-e COMMIT_SHA="$CIRCLE_SHA1"
-e RELEASE_TAG="$VER"
-e CREDENTIALS_S3_SECRETKEY="$APICULTURIST_S3"
-e CREDENTIALS_GITHUB="$APICULTURIST_GITHUB"
-e CREDENTIALS_COLONY="$APICULTURIST_TOKEN"
ghcr.io/qlik-download/api-compliance
workflows:
version: 2
build-all:
jobs:
- install
- build:
requires:
- install
- api-governance:
context: api-compliance
filters:
branches:
# Forked pull requests have CIRCLE_BRANCH set to pull/XXX
ignore: /pull\/[0-9]+/
tags:
only:
- /v.*/
- publish-dev:
requires:
- build
- publish:
requires:
- build
filters:
branches:
only:
- main
- /release\/.*/