.circleci/config.yml
version: 2.1
orbs:
browser-tools: circleci/browser-tools@1.4.4
defaults: &defaults
working_directory: ~/grommet-ci
docker:
- image: cimg/node:18.13.0-browsers
jobs:
checkout:
<<: *defaults
resource_class: large # resource class size determined by run time of jobs
steps:
- checkout
- restore_cache:
keys:
- yarn-cache-{{ checksum "yarn.lock" }}
- run: yarn --frozen-lockfile
- save_cache:
key: yarn-cache-{{ checksum "yarn.lock" }}
paths:
- ~/.cache
- ./node_modules
- persist_to_workspace:
root: ~/grommet-ci
paths:
- ./
lint:
<<: *defaults
resource_class: small
steps:
- attach_workspace:
at: ~/grommet-ci
- run:
name: Running linter
command: yarn lint
jest:
<<: *defaults
resource_class: large
steps:
- attach_workspace:
at: ~/grommet-ci
- run:
name: Running jest
command: yarn test
chromatic:
<<: *defaults
resource_class: large
steps:
- attach_workspace:
at: ~/grommet-ci
- run:
name: Running chromatic test
command: yarn chromatic -t $CHROMATIC_TOKEN --exit-zero-on-changes
chromatic-accept:
<<: *defaults
steps:
- attach_workspace:
at: ~/grommet-ci
- run:
name: Running chromatic test
command: yarn chromatic -t $CHROMATIC_TOKEN --exit-zero-on-changes --auto-accept-changes
build:
<<: *defaults
resource_class: medium+
steps:
- attach_workspace:
at: ~/grommet-ci
- run:
name: Build
command: yarn build
- persist_to_workspace:
root: ~/grommet-ci
paths:
- ./
bundlesize:
<<: *defaults
resource_class: small
steps:
- attach_workspace:
at: ~/grommet-ci
- run:
name: size
command: yarn test-bundlesize
test:
<<: *defaults
resource_class: small
# Assigned a size small resource class because we currently only have 3 end
# to end tests. As we expand our e2e testing we may want to adjust this.
steps:
- attach_workspace:
at: ~/grommet-ci
- run: sudo apt-get update
- browser-tools/install-chrome:
replace-existing: true
chrome-version: 116.0.5845.96
# temporary solution until
# https://github.com/CircleCI-Public/browser-tools-orb/issues/90
# is fixed. Once fixed remove chrome-version.
- browser-tools/install-chromedriver
- run:
name: Start project
command: yarn start
background: true
- run:
name: End to end test
command: yarn test-e2e-ci
- store_test_results:
path: /tmp/test-results
release:
<<: *defaults
steps:
- attach_workspace:
at: ~/grommet-ci
- run:
command: |
git config --global user.name "Grommet Community Bot"
git config --global user.email "grommet@hpe.com"
yarn release-stable
release-styled-components-beta-stable:
<<: *defaults
steps:
- attach_workspace:
at: ~/grommet-ci
- run:
command: |
git config --global user.name "Grommet Community Bot"
git config --global user.email "grommet@hpe.com"
yarn release-styled-components-beta-stable
publish:
<<: *defaults
steps:
- attach_workspace:
at: ~/grommet-ci
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/grommet-ci/dist/.npmrc
- run:
name: Add npmignore
command: echo "**/__tests__/**" > ~/grommet-ci/dist/.npmignore
- run:
name: Publish package
command: cd dist && npm publish
workflows:
build_test:
jobs:
- checkout:
filters:
tags:
only: /.*/
- lint:
requires:
- checkout
filters:
tags:
only: /.*/
- jest:
requires:
- checkout
filters:
tags:
only: /.*/
- test:
requires:
- checkout
filters:
tags:
only: /.*/
- chromatic:
requires:
- checkout
filters:
tags:
only: /.*/
branches:
ignore:
- master
- chromatic-accept:
requires:
- checkout
filters:
branches:
only:
- master
- build:
requires:
- checkout
filters:
tags:
only: /.*/
- bundlesize:
requires:
- build
filters:
tags:
only: /.*/
- release:
context:
- grommet
requires:
- jest
- chromatic
- lint
- build
filters:
branches:
only:
- master
- release-styled-components-beta-stable:
requires:
- jest
- chromatic
- lint
- build
filters:
branches:
only:
- styled-components-beta
- publish:
context:
- grommet
requires:
- jest
- chromatic
- lint
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/