-
Notifications
You must be signed in to change notification settings - Fork 13
127 lines (116 loc) · 3.68 KB
/
continuous-integration.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Continuous Integration
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions: read-all
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install --frozen-lockfile --non-interactive
- name: Run eslint
run: yarn lint
integrity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install --frozen-lockfile --non-interactive
- name: 'Integrity: Verify workspace integrity'
run: yarn integrity
- name: 'Integrity: Assert no changes (run `yarn integrity` if this fails)'
run: git diff --exit-code
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install --frozen-lockfile --non-interactive
- name: Install browser dependencies
run: yarn playwright install-deps
- name: Run tests
run: yarn test
env:
NODE_ENV: production
- name: Store coverage
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage/
- name: Save PR number
if: github.event_name == 'pull_request'
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
- name: Store PR number
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v3
with:
name: pr
path: pr/
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install --frozen-lockfile --non-interactive
- name: Run build
run: yarn build
env:
STORYBOOK_COMPONENTS_VERSION: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Store storybook artifacts
uses: actions/upload-artifact@v3
with:
name: storybook
path: dist/storybook/
chromatic:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
needs: [build, lint, test]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install --frozen-lockfile --non-interactive
- name: Generate chromatic stories
run: yarn generate:chromatic-stories
- uses: actions/github-script@v6
id: version
with:
script: |
const sha = context.payload.pull_request?.head.sha ?? context.sha;
return `${require('./package.json').version}-rev.${sha.substring(0, 10)}`;
result-encoding: string
- name: Create versioned storybook for chromatic
run: STORYBOOK_COMPONENTS_VERSION=${{ steps.version.outputs.result }} yarn build:storybook
env:
CHROMATIC: true
- name: Publish to Chromatic
id: chromatic-publish
uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_TOKEN }}
storybookBuildDir: dist/storybook
exitOnceUploaded: true
exitZeroOnChanges: true
zip: true