-
Notifications
You must be signed in to change notification settings - Fork 1
executable file
·251 lines (218 loc) · 8.32 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Continuous Integration
on:
push:
branches:
- main
- dev
env:
APP_NAME: mediature
CONTAINER_REGISTRY: ghcr.io
CONTAINER_IMAGE_FOLDER: ghcr.io/${{ github.repository }}
NODE_OPTIONS: --max_old_space_size=4096
NODE_VERSION: 16.15.0
PNPM_VERSION: 7.27.1
CYPRESS_CACHE_FOLDER_SUFFIX: .cache/Cypress
PLAYWRIGHT_BROWSERS_CACHE_FOLDER_SUFFIX: .cache/ms-playwright
jobs:
requirements:
name: Continuous Integration
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set environment for branch
run: |
if [[ $GITHUB_REF_NAME == 'main' ]]; then
echo "APP_MODE=prod" >> $GITHUB_ENV
elif [[ $GITHUB_REF_NAME == 'dev' ]]; then
echo "APP_MODE=dev" >> $GITHUB_ENV
else
echo "APP_MODE=test" >> $GITHUB_ENV
fi
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
- name: Export pnpm store directory as an environment variable
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: actions/cache@v3
name: Setup Next.js build cache
with:
path: ${{ github.workspace }}/apps/main/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Install dependencies
env:
CYPRESS_CACHE_FOLDER: ${{ env.STORE_PATH }}/${{ env.CYPRESS_CACHE_FOLDER_SUFFIX }}
PLAYWRIGHT_BROWSERS_PATH: ${{ env.STORE_PATH }}/${{ env.PLAYWRIGHT_BROWSERS_CACHE_FOLDER_SUFFIX }}
run: make deps
- name: Prepare linting
run: make lint-prepare
- name: Lint
run: make lint
- name: Format check
run: make format-check
- name: Prepare tests
run: make test-prepare
- uses: KengoTODA/actions-setup-docker-compose@v1
name: Install `docker-compose` for local CI/CD simulations (https://github.com/nektos/act/issues/112#issuecomment-1387307297)
if: ${{ env.ACT }}
with:
version: '2.14.2'
- name: Install `Xvfb` and others to run browsers for end-to-end testing in local CI/CD simulations (https://github.com/nektos/act/issues/1300#issuecomment-1387344639)
if: ${{ env.ACT }}
run: sudo apt-get update && sudo apt-get install -y xvfb && npx playwright install-deps
- name: Test unit
run: make test-unit
- name: Build
env:
SENTRY_URL: ${{ secrets.SENTRY_URL }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_RELEASE_UPLOAD: true
run: make build
- name: Test end-to-end
env:
CYPRESS_CACHE_FOLDER: ${{ env.STORE_PATH }}/${{ env.CYPRESS_CACHE_FOLDER_SUFFIX }}
PLAYWRIGHT_BROWSERS_PATH: ${{ env.STORE_PATH }}/${{ env.PLAYWRIGHT_BROWSERS_CACHE_FOLDER_SUFFIX }}
run: make test-e2e
# TODO: enable again once Next 13 with "appDir: true" is compatible with `next export`
# Ref: https://beta.nextjs.org/docs/app-directory-roadmap#supported-and-planned-features
# - name: Accessibility with Lighthouse
# run: make accessibility
# env:
# LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
# - name: Release
# if: ${{ !env.ACT }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# run: npx semantic-release
publish-chromatic:
name: Publish to Chromatic
if: ${{ !github.event.act }}
# if: ${{ !github.event.act && (github.ref_name == 'dev' || github.ref_name == 'main') }}
needs: [requirements]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
- name: Install turbo
run: npm install -g turbo
- name: Export pnpm store directory as an environment variable
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Reduce dependency list
run: turbo prune --scope=docs
- name: Install dependencies
env:
CYPRESS_CACHE_FOLDER: ${{ env.STORE_PATH }}/${{ env.CYPRESS_CACHE_FOLDER_SUFFIX }}
PLAYWRIGHT_BROWSERS_PATH: ${{ env.STORE_PATH }}/${{ env.PLAYWRIGHT_BROWSERS_CACHE_FOLDER_SUFFIX }}
run: pnpm install
- uses: chromaui/action@v1
env:
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
with:
# Note: since we use `buildScriptName` we have to specify some of those parameters into the underlying `package.json` script named `chromatic`
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
workingDir: apps/docs
buildScriptName: build
autoAcceptChanges: true
onlyChanged: true
externals: public/**
exitZeroOnChanges: true
#
# Note: since we use Scalingo we dropped the usage of Docker images. Commenting this section for now
# but the following could help deploying to another platform that accepts Docker images.
#
# build-and-push-images:
# name: Build and push container images
# if: ${{ !github.event.act && (github.ref_name == 'dev' || github.ref_name == 'main') }}
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Log in to the Container registry
# uses: docker/login-action@v2
# with:
# registry: ${{ env.CONTAINER_REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: '"main" image'
# uses: docker/build-push-action@v3
# with:
# context: .
# file: ./apps/main/Dockerfile
# push: true
# tags: ${{ env.CONTAINER_IMAGE_FOLDER }}/${{ env.APP_NAME }}-${{ github.ref_name }}:${{ github.sha }},${{ env.CONTAINER_IMAGE_FOLDER }}/${{ env.APP_NAME }}-${{ github.ref_name }}:latest
# - name: '"docs" image'
# uses: docker/build-push-action@v3
# with:
# context: .
# file: ./apps/docs/Dockerfile
# push: true
# tags: ${{ env.CONTAINER_IMAGE_FOLDER }}/${{ env.APP_NAME }}-docs-${{ github.ref_name }}:${{ github.sha }},${{ env.CONTAINER_IMAGE_FOLDER }}/${{ env.APP_NAME }}-docs-${{ github.ref_name }}:latest
# deploy-dev:
# name: Deploy to development
# if: ${{ !github.event.act && github.ref_name == 'dev' }}
# environment:
# name: dev
# needs: [requirements]
# runs-on: ubuntu-latest
# steps:
# - run: echo Should deploy the Docker image to development
# deploy-prod:
# name: Deploy to production
# if: ${{ !github.event.act && github.ref_name == 'main' }}
# environment:
# name: prod
# needs: [requirements]
# runs-on: ubuntu-latest
# steps:
# - run: echo Should deploy the Docker image to production