Skip to content

Commit 44cc849

Browse files
authored
Add upload artifact (#13)
* Add upload artifact * Fix workflow * Fix command * Fix workflow * Fix only one version * Fix path * Fix do not checkout * Fix syntax error * Fix error * Fix error * Fix path * tweak * Fix README * Fix tweak README * Fix const name * Fix add visual regression tests * Fix command * Fix command * Fix add scripts for visualize test * Fix use bash
1 parent ac034e3 commit 44cc849

24 files changed

+372
-34
lines changed

.github/workflows/main.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [10.x, 12.x]
12+
node-version: [10.x]
1313

1414
steps:
1515
- uses: actions/checkout@v1
1616
- name: Use Node.js ${{ matrix.node-version }}
1717
uses: actions/setup-node@v1
1818
with:
1919
node-version: ${{ matrix.node-version }}
20+
2021
- name: Install dependencies
2122
run: yarn install
2223

@@ -31,15 +32,23 @@ jobs:
3132
mkdir -p "./dist/storybook/${{ github.head_ref }}"
3233
yarn build-storybook -o "./dist/storybook/${{ github.head_ref }}"
3334
34-
- name: Deploy branch - "${{ github.head_ref }}"
35+
- name: Prepare upload artifact - "${{ github.head_ref }}"
3536
run: |
36-
echo "not master branch ${{ github.head_ref }}"
37+
echo `which wget`
38+
mkdir -p "./dist/__regressions__${{ github.head_ref }}/actual"
39+
yarn screenshot -o "./dist/__regressions__/${{ github.head_ref }}/actual"
40+
if: contains(github.ref, 'master') == false
41+
42+
- name: Upload artifact
43+
uses: actions/upload-artifact@master
44+
with:
45+
name: screenshots
46+
path: "./dist/__regressions__/${{ github.head_ref }}/actual"
3747
if: contains(github.ref, 'master') == false
3848

3949
- name: Deploy master
4050
run: |
4151
echo "./dist"
4252
ls ./dist
4353
echo "./dist/storybook/${{ github.head_ref }}"
44-
ls "./dist/storybook/${{ github.head_ref }}"
4554
if: contains(github.ref, 'master')

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,4 @@ tmp/
9696
package-lock.json
9797
storybook-static/
9898
__screenshots__/
99+
__regressions__/

README.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# My Site build with React-Static
22

33
[![Build Status](https://github.com/heavenshell/ts-react-static/workflows/build/badge.svg)](https://github.com/heavenshell/ts-react-static/actions)
4-
4+
[![Netlify Status](https://api.netlify.com/api/v1/badges/aa9245e5-3cff-49a0-bf2c-cd3e8d37ca7a/deploy-status)](https://app.netlify.com/sites/heavenshell/deploys)
55

66
| Library | Description |
77
|:---------------|:--------------------------------|
@@ -16,42 +16,47 @@
1616
| Enzyme | React testing library |
1717
| Storybook | UI component dev & test |
1818

19+
- Site
20+
- https://heavenshell.netlify.com/
21+
- Storybook
22+
- https://heavenshell.netlify.com/storybook/
23+
1924
## Install
2025

2126
```
22-
$ yarn
27+
yarn
2328
```
2429

2530
## Usage
2631

2732
### Build
2833

2934
```
30-
$ yarn build
35+
yarn build
3136
```
3237

3338
### Development
3439

3540
```
36-
$ yarn start
41+
yarn start
3742
```
3843

3944
### Storybook
4045

4146
```
42-
$ yarn storybook
47+
yarn storybook
4348
```
4449

4550
### Test
4651

4752
```
48-
$ yarn test
53+
yarn test
4954
```
5055

5156
### Lint
5257

5358
```
54-
$ yarn lint
59+
yarn lint
5560
```
5661

5762
## LICENSE

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"lint:md": "markdownlint contents",
1818
"lint": "run-p -l lint:*",
1919
"test": "jest --maxWorkers=1",
20-
"screenshot": "zisui --serverCmd 'start-storybook -p 6006' --serverTimeout 100000 http://localhost:6006",
21-
"build:all": "yarn build && mkdir -p ./dist/storybook && yarn build-storybook -o ./dist/storybook"
20+
"screenshot": "zisui --serverCmd 'start-storybook -p 6006' --serverTimeout 100000 http://localhost:6006 -i '**/Regression'",
21+
"build:reg": "bash ./scripts/reg.sh",
22+
"build:all": "yarn build && yarn build:reg"
2223
},
2324
"dependencies": {
2425
"@emotion/core": "10.0.17",
@@ -93,6 +94,7 @@
9394
"markdownlint-cli": "0.18.0",
9495
"npm-run-all": "4.1.5",
9596
"prettier": "1.18.2",
97+
"reg-cli": "0.15.7",
9698
"serve": "11.1.0",
9799
"style-loader": "1.0.0",
98100
"ts-config-webpack-plugin": "1.4.0",

scripts/reg.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
3+
function prepare () {
4+
mkdir -p ./dist/storybook
5+
rm -rf ./dist/__regressions__
6+
mkdir -p ./dist/__regressions__/{expected,actual}
7+
yarn build-storybook -o ./dist/storybook
8+
yarn screenshot -o ./dist/__regressions__/actual
9+
}
10+
11+
function download () {
12+
echo "wget expected file"
13+
wget https://heavenshell.netflify.com/__regressions__/expected/files.tar.gz
14+
if [ -e files.tar.gz ]; then
15+
mv files.tar.gz ./dist/__regressions__/expected/files.tar.gz
16+
echo "unzip file.tar.gz"
17+
tar xzf ./dist/__regressions__/expected/files.tar.gz ./dist/__regressions__/exptected
18+
fi
19+
}
20+
21+
function run_reg () {
22+
reg-cli ./dist/__regressions__/actual ./dist/__regressions__/expected ./dist/__regressions__/reports/ -R ./dist/__regressions__/report.html
23+
mv reg.json ./dist/__regressions__/.
24+
}
25+
26+
27+
function compress () {
28+
if [ -d ./dist/__regressions__/expected ]; then
29+
echo "compress files and move to exptected"
30+
tar czf ./dist/__regressions__/expected/files.tar.gz ./dist/__regressions__/actual
31+
fi
32+
}
33+
34+
prepare
35+
download
36+
run_reg
37+
compress
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Lorem ipsum dolor sit amet...",
3+
"content": "Nisi alias cumque alias eligendi et suscipit. Cumque pariatur dolorum sit non est et qui non. Eum modi rerum. Quasi pariatur inventore rerum. Sit cumque et fuga ut eveniet fuga. Ut tempora optio repudiandae cumque iste aliquid labore nemo. Excepturi suscipit eum aliquam natus at delectus. Laborum est earum rerum doloribus. Consectetur officia perferendis et consequatur. Eaque velit soluta et nostrum sit. Voluptate natus aut veniam optio qui voluptatibus qui. Dolores placeat dolore corrupti ipsam. Quo ut eveniet facere."
4+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"title": "Sint sit dolores fugit qui rerum distinctio saepe.",
4+
"date": "2019-01-01",
5+
"slug": "foo"
6+
},
7+
{
8+
"title": "corrupti consequatur dolores",
9+
"date": "2019-01-02",
10+
"slug": "bar"
11+
},
12+
{
13+
"title": "Alias voluptatem molestiae temporibus omnis deserunt dolore non neque. Harum neque optio accusantium. Ipsum quia vero sit quas nemo ea vel quidem sint.",
14+
"date": "2019-01-03",
15+
"slug": "baz"
16+
}
17+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"children": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Perferendis sit nihil.",
3+
"slug": "foo"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"title": "alias iusto cumque",
3+
"contents": "Ipsam velit eaque. Et quia ad natus dignissimos nostrum maiores et similique voluptas. Doloribus ut in officiis dolore a dolor error. Temporibus consequatur qui deserunt nesciunt quis dolorum. Cum adipisci occaecati quidem autem. Sapiente eveniet ullam quo fugit praesentium fuga perferendis. Ea saepe dolorem quis omnis enim. Voluptatum quia eveniet culpa amet dolor. Quia cumque cumque dolorum minus officiis illo animi ab voluptatibus. Et recusandae repudiandae omnis repellendus est. Quaerat nisi ut modi natus quam ut consequatur. Aut sit iusto reprehenderit minus iste fuga quo numquam qui. Aspernatur explicabo enim in dolorum inventore. Quia est ut et at dolorem id sit. Qui ab porro assumenda.",
4+
"date": "2019-01-01",
5+
"slug": "main"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[
2+
{
3+
"title": "Minus optio fugiat harum.",
4+
"date": "2020-01-01",
5+
"slug": "foo"
6+
},
7+
{
8+
"title": "Eveniet fugiat dignissimos ut aliquid consequatur.",
9+
"date": "2020-01-02",
10+
"slug": "bar"
11+
},
12+
{
13+
"title": "Enim qui similique aliquid ut ut repudiandae aspernatur libero.",
14+
"date": "2020-01-03",
15+
"slug": "baz"
16+
},
17+
{
18+
"title": "Consequatur dolore assumenda omnis necessitatibus sit.",
19+
"date": "2020-01-04",
20+
"slug": "spam"
21+
},
22+
{
23+
"title": "Id porro aut cupiditate perspiciatis molestiae omnis accusamus at maiores.",
24+
"date": "2020-01-05",
25+
"slug": "ham"
26+
}
27+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "Iusto maxime est.",
3+
"slug": "bar"
4+
}

src/components/atoms/GitHubIcon/index.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const story = {
88
title: 'atoms/GitHubIcon',
99
}
1010

11-
export const icon: StoryProps = () => <GitHubIcon />
11+
export const component: StoryProps = () => <GitHubIcon />
1212

13-
icon.story = {
13+
component.story = {
1414
name: 'default',
1515
}
1616

src/components/atoms/TwitterIcon/index.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const story = {
88
title: 'atoms/TwitterIcon',
99
}
1010

11-
export const twitterIcon: StoryProps = () => <TwitterIcon />
11+
export const component: StoryProps = () => <TwitterIcon />
1212

13-
twitterIcon.story = {
13+
component.story = {
1414
name: 'default',
1515
}
1616

src/components/pages/About/index.stories.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { lorem } from 'faker'
33

44
import About from '.'
55

6+
import json from '../../__fixtures__/json/about.json'
67
import { createLayoutProps } from '../../__fixtures__/createLayout'
78
import { StoryProps } from '../../../types'
89

@@ -20,4 +21,14 @@ component.story = {
2021
name: 'default',
2122
}
2223

24+
export const regression: StoryProps = () => {
25+
const contents = json.content
26+
const title = json.title
27+
return <About {...createLayoutProps()} contents={contents} title={title} />
28+
}
29+
30+
regression.story = {
31+
name: 'regression',
32+
}
33+
2334
export default story

src/components/pages/Errors/index.stories.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ component.story = {
1515
name: 'default',
1616
}
1717

18+
export const regression: StoryProps = () => (
19+
<NotFound {...createLayoutProps()} />
20+
)
21+
22+
regression.story = {
23+
name: 'regression',
24+
}
25+
1826
export default story

src/components/pages/Home/index.stories.tsx

+23-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { lorem } from 'faker'
44

55
import Home from '.'
66

7+
import json from '../../__fixtures__/json/home.json'
78
import { createLayoutProps } from '../../__fixtures__/createLayout'
89
import { StoryProps } from '../../../types'
910

@@ -16,7 +17,6 @@ export const component: StoryProps = () => {
1617
title: lorem.text(),
1718
slug: lorem.slug(),
1819
date: new Date(),
19-
contents: lorem.sentences(),
2020
}))
2121

2222
return (
@@ -35,4 +35,26 @@ component.story = {
3535
name: 'default',
3636
}
3737

38+
export const regression: StoryProps = () => {
39+
const posts = json.map(({ date, ...props }) => ({
40+
...props,
41+
date: new Date(date),
42+
}))
43+
44+
return (
45+
<Home
46+
{...createLayoutProps()}
47+
onPostLinkClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
48+
e.preventDefault()
49+
action('onPostLinkClick')(e.target)
50+
}}
51+
posts={posts}
52+
/>
53+
)
54+
}
55+
56+
regression.story = {
57+
name: 'regression',
58+
}
59+
3860
export default story

src/components/pages/Home/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import CalendarTodayIcon from '@material-ui/icons/CalendarToday'
44
import dayjs from 'dayjs'
55

66
import Layout, { Props as LayoutProps } from '../../templates/Layout'
7-
import { PostProps } from '../../../types'
7+
import { PostTitleProps } from '../../../types'
88

99
type ViewProps = {
10-
posts: PostProps[]
10+
posts: PostTitleProps[]
1111
}
1212

1313
type ActionProps = {

0 commit comments

Comments
 (0)