.circleci/config.yml
version: 2
defaults: &defaults
working_directory: ~/table
docker:
- image: cimg/node:lts
# Available images https://hub.docker.com/r/circleci/node/tags/
aliases:
- &restore_pnpm_cache
name: Restore pnpm cache
keys:
- pnpm-packages-{{ .Branch }}-{{ checksum "pnpm-lock.yaml" }}
- pnpm-packages-{{ .Branch }}
- pnpm-packages-
- &save_pnpm_cache
name: Save pnpm cache
paths:
- node_modules
key: pnpm-packages-{{ .Branch }}-{{ checksum "pnpm-lock.yaml" }}
jobs:
install:
<<: *defaults
steps:
- checkout
- restore_cache: *restore_pnpm_cache
- run:
name: Setup github packages access
command: |
set -eo pipefail
# Amend auth token for access to private github packages, to access sprout
echo "@qlik-trial:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN
//npm.pkg.github.com/:always-auth=true" >> ~/.npmrc
- run:
name: Install dependencies
command: pnpm install --frozen-lockfile
- save_cache: *save_pnpm_cache
- store_artifacts:
path: package.json
- persist_to_workspace:
root: ~/table
paths:
- .
build:
<<: *defaults
steps:
- attach_workspace:
at: ~/table
- run:
name: Build
command: pnpm run build
- persist_to_workspace:
root: ~/table
paths:
- dist
- package.json
- core
- src/locale/all.json
integration-tests:
<<: *defaults
docker:
- image: mcr.microsoft.com/playwright:focal
steps:
- attach_workspace:
at: ~/table
- run:
name: Install playwright
command: npx playwright install
- run:
name: Install pnpm
command: npm install -g pnpm
- run:
name: Run integration tests
command: pnpm test:integration
- store_artifacts:
path: test/integration/artifacts
- store_artifacts:
path: test/integration/test-report
rendering-tests:
<<: *defaults
docker:
- image: mcr.microsoft.com/playwright:focal
steps:
- attach_workspace:
at: ~/table
- run:
name: Install playwright
command: npx playwright install
- run:
name: Install pnpm
command: npm install -g pnpm
- run:
name: Run rendering tests
command: pnpm test:rendering
- store_artifacts:
path: test/rendering/table.render.ts-snapshots
- store_artifacts:
path: test/rendering/artifacts
- store_artifacts:
path: test/rendering/test-report
api-spec:
<<: *defaults
steps:
- attach_workspace:
at: ~/table
- run:
name: Update spec
command: pnpm run spec
locale:
<<: *defaults
steps:
- attach_workspace:
at: ~/table
- run:
name: Verify locale
command: pnpm run locale:verify
types:
<<: *defaults
steps:
- attach_workspace:
at: ~/table
- run:
name: Check types
command: pnpm run types:check
lint:
<<: *defaults
steps:
- attach_workspace:
at: ~/table
- run:
name: Lint
command: pnpm run lint
format:
<<: *defaults
steps:
- attach_workspace:
at: ~/table
- run:
name: Format check
command: pnpm run format:check
unit-tests:
<<: *defaults
steps:
- attach_workspace:
at: ~/table
- run:
name: Run unit tests and publish to codeclimate
command: |
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
pnpm test:unit --runInBand --coverage --reporters=default --reporters=jest-junit
./cc-test-reporter after-build --coverage-input-type lcov --exit-code $?
environment:
JEST_JUNIT_OUTPUT_DIR: ./coverage/junit/
- store_artifacts:
path: coverage
publish-dev:
<<: *defaults
steps:
- attach_workspace:
at: ~/table
- run: mv ./dist sn-table && zip -r "sn-table.zip" "./sn-table"
- store_artifacts:
path: ./sn-table.zip
publish:
<<: *defaults
steps:
- attach_workspace:
at: ~/table
- 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
- run:
name: Run API Compliance
command: >
VER=$(cat ./version.txt)
docker run --volumes-from specs
-e SPEC_PATHS="b96971ec-2f58-4ba3-9213-440e689471a0@/specs/properties.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
- unit-tests:
requires:
- build
- lint:
requires:
- build
- format:
requires:
- build
- types:
requires:
- build
- locale:
requires:
- build
- api-spec:
requires:
- build
- rendering-tests:
requires:
- build
- integration-tests:
requires:
- build
- 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
- unit-tests
- rendering-tests
- integration-tests
- lint
- types
- api-spec
- locale
filters:
branches:
only:
- main