Skip to content

Commit 07cc98e

Browse files
authored
Merge pull request #11 from Cardinal-Cryptography/SD-23-add-chromatic
SD-23: Set up chromatic
2 parents 54a4eb6 + eb455bf commit 07cc98e

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Chromatic
2+
description: Publish Storybook, run visual regression tests and setup snapshot baselines for
3+
the following tests.
4+
5+
inputs:
6+
chromatic-project-token:
7+
description: Chromatic project token
8+
required: true
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0 # Pull more than just last commit for Chromatic to run it's git-based diffing
16+
- uses: ./.github/actions/setup-project
17+
18+
- name: Publish Storybook and run visual regression tests
19+
env:
20+
NODE_OPTIONS: "--max_old_space_size=4096"
21+
uses: chromaui/action@v1
22+
with:
23+
projectToken: ${{ inputs.chromatic-project-token }}
24+
exitZeroOnChanges: true
25+
onlyChanged: true

.github/workflows/chromatic.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Chromatic
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
env:
10+
NODE_OPTIONS: --max-old-space-size=16384
11+
12+
jobs:
13+
install: # Warm up node_modules cache for the following jobs
14+
name: Set up Node.js and install npm dependencies
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: ./.github/actions/setup-project
19+
# with:
20+
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
21+
22+
storybook:
23+
name: Chromatic toolset initialization
24+
needs: [install]
25+
runs-on: ubuntu-22.04
26+
environment: dev
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Export variables
30+
env:
31+
VARS_CONTEXT: ${{ toJson(vars) }}
32+
run: |
33+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
34+
to_envs() { jq -r "to_entries[] | select(.key|startswith(\"PUBLIC_VAR\")) | \"\(.key)<<$EOF\n\(.value)\n$EOF\n\""; }
35+
echo "$VARS_CONTEXT" | to_envs >> $GITHUB_ENV
36+
- uses: ./.github/actions/chromatic
37+
with:
38+
chromatic-project-token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

0 commit comments

Comments
 (0)