Skip to content

Commit 18fd204

Browse files
committed
feat(storybook): run storybook tests on CI
1 parent 6575d72 commit 18fd204

7 files changed

Lines changed: 212 additions & 43 deletions

File tree

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: 'End-to-End Tests'
22

33
on:
44
push:
@@ -7,31 +7,7 @@ on:
77
types: [opened, synchronize]
88

99
jobs:
10-
build:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v3
15-
- name: Install pnpm
16-
uses: pnpm/action-setup@v4
17-
with:
18-
run_install: false
19-
- name: Setup Node
20-
uses: actions/setup-node@v4
21-
with:
22-
node-version: '22'
23-
cache: 'pnpm'
24-
- run: pnpm install
25-
- name: Build nivo packages
26-
run: make pkgs-build
27-
- run: make pkgs-lint
28-
- run: make pkgs-test
29-
# Make sure that we can build the website
30-
- run: make website-build
31-
# Make sure that we can build storybook
32-
- run: make storybook-build
33-
34-
end-to-end-tests:
10+
test:
3511
runs-on: ubuntu-22.04
3612
steps:
3713
- name: Checkout
@@ -43,7 +19,7 @@ jobs:
4319
- name: Setup Node
4420
uses: actions/setup-node@v4
4521
with:
46-
node-version: '22'
22+
node-version-file: '.nvmrc'
4723
cache: 'pnpm'
4824
- name: Cypress install
4925
uses: cypress-io/github-action@v6
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'Storybook Tests'
2+
3+
on:
4+
push:
5+
branches: ['master']
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
test:
11+
timeout-minutes: 60
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
- name: Install pnpm
17+
uses: pnpm/action-setup@v4
18+
with:
19+
run_install: false
20+
- name: Setup Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version-file: '.nvmrc'
24+
cache: 'pnpm'
25+
- name: Install dependencies & build packages
26+
run: make init
27+
- name: Build Storybook
28+
run: make storybook-build
29+
- name: Serve Storybook and run tests
30+
run: make storybook-test-ci

.github/workflows/tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: ['master']
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Install pnpm
16+
uses: pnpm/action-setup@v4
17+
with:
18+
run_install: false
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version-file: '.nvmrc'
23+
cache: 'pnpm'
24+
- run: pnpm install
25+
- name: Build nivo packages
26+
run: make pkgs-build
27+
- run: make pkgs-lint
28+
- run: make pkgs-test
29+
# Make sure that we can build the website
30+
- run: make website-build

Makefile

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ init: ##@0 global cleanup/install/bootstrap
5050
@$(MAKE) clean-all
5151
@$(MAKE) install
5252
@$(MAKE) pkgs-build
53+
@$(MAKE) storybook-playwright-install
5354

5455
fmt: ##@0 global format code using prettier (js, css, md)
5556
@pnpm prettier --color --write \
@@ -91,13 +92,13 @@ vercel-build: ##@0 global Build the website and storybook to vercel
9192
@cp -a storybook/storybook-static website/public/storybook
9293

9394
clean-all: ##@0 global uninstall node modules, remove transpiled code & lock files
94-
rm -rf node_modules
95-
rm -rf package-lock.json
96-
$(foreach source, $(SOURCES), $(call clean-source-all, $(source)))
97-
rm -rf website/node_modules
98-
rm -rf website/package-lock.json
99-
rm -rf api/node_modules
100-
rm -rf api/package-lock.json
95+
@rm -rf node_modules
96+
@rm -rf package-lock.json
97+
@$(foreach source, $(SOURCES), $(call clean-source-all, $(source)))
98+
@rm -rf website/node_modules
99+
@rm -rf website/package-lock.json
100+
@rm -rf api/node_modules
101+
@rm -rf api/package-lock.json
101102

102103
define clean-source-lib
103104
rm -rf $(1)/*/cjs
@@ -269,16 +270,27 @@ website-sprites: ##@2 website build sprite sheet
269270
storybook: ##@3 storybook start storybook in dev mode on port 6006
270271
@pnpm --filter storybook dev
271272

273+
storybook-test: ##@3 storybook test storybook stories
274+
@echo "${YELLOW}Testing storybook${RESET}"
275+
@pnpm --filter storybook test
276+
272277
storybook-build: ##@3 storybook build storybook
273278
@echo "${YELLOW}Building storybook${RESET}"
274279
@pnpm --filter storybook build
275280

276-
storybook-deploy: ##@3 storybook build and deploy storybook
277-
@$(MAKE) storybook-build
278-
281+
storybook-deploy: storybook-build ##@3 storybook build and deploy storybook
279282
@echo "${YELLOW}Deploying storybook${RESET}"
280283
@pnpm gh-pages -d storybook/storybook-static -r [email protected]:plouc/nivo.git -b gh-pages -e storybook
281284

285+
storybook-playwright-install: ##@3 storybook install playwright
286+
@echo "${YELLOW}Installing playwright${RESET}"
287+
@pnpm pnpm exec playwright install chromium
288+
289+
storybook-test-ci: ##@3 start storybook & run playwright tests
290+
@echo "${YELLOW}Start storybook and run playwright tests${RESET}"
291+
@npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
292+
"npx http-server storybook/storybook-static --port 6006 --silent" \
293+
"npx wait-on tcp:127.0.0.1:6006 && make storybook-test"
282294

283295
########################################################################################################################
284296
#

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"babel-loader": "^8.2.3",
3939
"chalk": "^5.2.0",
4040
"chalk-template": "^1.0.0",
41+
"concurrently": "^9.1.2",
4142
"cypress": "^12.11.0",
4243
"enzyme": "^3.11.0",
4344
"eslint": "^8.39.0",
@@ -49,11 +50,13 @@
4950
"eslint-plugin-react": "^7.32.2",
5051
"eslint-plugin-react-hooks": "^4.6.0",
5152
"gh-pages": "^5.0.0",
53+
"http-server": "^14.1.1",
5254
"jest": "^29.5.0",
5355
"jest-environment-jsdom": "^29.5.0",
5456
"jsdom": "^22.0.0",
5557
"lerna": "^6.6.1",
5658
"lodash": "^4.17.21",
59+
"playwright": "^1.52.0",
5760
"prettier": "^2.8.8",
5861
"puppeteer": "^19.11.1",
5962
"raf": "^3.4.1",
@@ -68,6 +71,7 @@
6871
"rollup-plugin-visualizer": "^5.5.2",
6972
"serve": "^13.0.2",
7073
"typescript": "^4.9.5",
74+
"wait-on": "^8.0.3",
7175
"yargs": "^17.7.2"
7276
},
7377
"resolutions": {

0 commit comments

Comments
 (0)