-
Notifications
You must be signed in to change notification settings - Fork 0
192 lines (164 loc) · 6.41 KB
/
ci.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: CI
on:
pull_request:
branches: [develop]
push:
branches: [develop]
env:
CACHED_DEPENDENCY_PATHS: |
${{ github.workspace }}/.yarn/cache
${{ github.workspace }}/node_modules
CACHED_BUILD_PACKAGE_UI_PATHS: ${{ github.workspace }}/packages/ui/dist
CACHED_BUILD_PACKAGE_CORE_PATHS: ${{ github.workspace }}/packages/core/dist
DEFAULT_NODE_VERSION: "v20.11.1"
DEFAULT_YARN_VERSION: "4.3.1"
jobs:
job_install_dependencies:
name: Install Dependencies
runs-on: ubuntu-latest
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Set up Yarn
run: |
corepack enable
yarn set version ${{ env.DEFAULT_YARN_VERSION }}
yarn --version
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Compute dependency cache key
id: compute_lockfile_hash
run: echo "hash=${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}" >> $GITHUB_OUTPUT
- name: Check dependency cache
uses: actions/cache@v4
id: cache_dependencies
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: yarn install --immutable
outputs:
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}
yarn_cache_dir_path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
${{ env.CACHED_DEPENDENCY_PATHS }}
job_packages_build:
name: Build
needs: [job_install_dependencies]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Check dependency cache
uses: actions/cache@v4
with:
path: ${{ needs.job_install_dependencies.outputs.yarn_cache_dir_path }}
key: ${{ needs.job_install_dependencies.outputs.dependency_cache_key }}
- name: Compute @dnd-academy/core cache key
id: compute_core_cache_key
run: echo "hash=${{ runner.os }}-core-build-${{ hashFiles('packages/core/**') }}" >> $GITHUB_OUTPUT
- name: Check @dnd-academy/core build cache
uses: actions/cache@v4
id: cache_built_core_packages
with:
path: ${{ env.CACHED_BUILD_PACKAGE_CORE_PATHS }}
key: ${{ steps.compute_core_cache_key.outputs.hash }}
- name: Build @dnd-academy/core
if: steps.cache_built_core_packages.outputs.cache-hit != 'true'
run: yarn workspace @dnd-academy/core build
- name: Compute @dnd-academy/ui cache key
id: compute_ui_cache_key
run: echo "hash=${{ runner.os }}-ui-build-${{ hashFiles('packages/ui/**') }}" >> $GITHUB_OUTPUT
- name: Check @dnd-academy/ui build cache
uses: actions/cache@v4
id: cache_built_ui_packages
with:
path: ${{ env.CACHED_BUILD_PACKAGE_UI_PATHS }}
key: ${{ steps.compute_ui_cache_key.outputs.hash }}
- name: Build @dnd-academy/ui
if: steps.cache_built_ui_packages.outputs.cache-hit != 'true'
run: yarn workspace @dnd-academy/ui build
outputs:
dependency_cache_key: ${{ needs.job_install_dependencies.outputs.dependency_cache_key }}
yarn_cache_dir_path: ${{ needs.job_install_dependencies.outputs.yarn_cache_dir_path }}
build_package_core_cache_key: ${{ steps.compute_core_cache_key.outputs.hash }}
build_package_ui_cache_key: ${{ steps.compute_ui_cache_key.outputs.hash }}
# continuous-integration:
# needs: [job_packages_build]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Set up Node
# uses: actions/setup-node@v4
# with:
# node-version: ${{ env.DEFAULT_NODE_VERSION }}
# - name: Check dependency cache
# uses: actions/cache@v4
# with:
# path: ${{ needs.job_packages_build.outputs.yarn_cache_dir_path }}
# key: ${{ needs.job_packages_build.outputs.dependency_cache_key }}
# - name: Check build package cache
# uses: actions/cache@v4
# with:
# path: ${{ env.CACHED_BUILD_PACKAGE_UI_PATHS }}
# key: ${{ needs.job_packages_build.outputs.build_package_ui_cache_key }}
# - name: Check Lint
# if: ${{ github.event_name == 'pull_request' }}
# run: |
# yarn lint
# yarn stylelint
# - name: Check Unit Test
# run: yarn test:coverage
job_publish_storybook_chromatic:
needs: [job_packages_build]
name: Chromatic Publish
runs-on: ubuntu-latest
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Check dependency cache
uses: actions/cache@v4
with:
path: ${{ needs.job_packages_build.outputs.yarn_cache_dir_path }}
key: ${{ needs.job_packages_build.outputs.dependency_cache_key }}
- name: Check build core package cache
uses: actions/cache@v4
with:
path: ${{ env.CACHED_BUILD_PACKAGE_CORE_PATHS }}
key: ${{ needs.job_packages_build.outputs.build_package_core_cache_key }}
- name: Check build ui package cache
uses: actions/cache@v4
with:
path: ${{ env.CACHED_BUILD_PACKAGE_UI_PATHS }}
key: ${{ needs.job_packages_build.outputs.build_package_ui_cache_key }}
- name: Publish Project to Chromatic
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
workingDir: apps/web
skip: "dependabot/**"
exitOnceUploaded: true
onlyChanged: true
autoAcceptChanges: true
buildScriptName: "build:storybook"