-
Notifications
You must be signed in to change notification settings - Fork 0
269 lines (220 loc) · 7.91 KB
/
deploy.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
name: Deploy
on:
push:
branches:
- main
- prod
pull_request:
merge_group:
defaults:
run:
working-directory: ./remix-ui
jobs:
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
- name: Checkout repo
uses: actions/checkout@v3
- name: Get package manager version
id: get-pnpm-version
run: echo "version=$(cat package.json | jq -r .packageManager | sed s/pnpm@//)" >> $GITHUB_OUTPUT
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ steps.get-pnpm-version.outputs.version }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: remix-ui/package.json
cache-dependency-path: remix-ui/pnpm-lock.yaml
cache: pnpm
- name: Download deps
run: pnpm install --frozen-lockfile
# Linting fails in CI because `~/styles/tailwind.css` does not exist and
# thus my `import/order` rule errors (because it doesn't mark that as a
# local import as the file doesn't exist). This addresses that.
- name: Stub imported css
run: mkdir app/styles && touch app/styles/tailwind.css
- name: Generate prisma
run: pnpm prisma generate --generator js
- name: Lint
run: pnpm lint
typecheck:
name: TypeScript
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
- name: Checkout repo
uses: actions/checkout@v3
- name: Get package manager version
id: get-pnpm-version
run: echo "version=$(cat package.json | jq -r .packageManager | sed s/pnpm@//)" >> $GITHUB_OUTPUT
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ steps.get-pnpm-version.outputs.version }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: remix-ui/package.json
cache-dependency-path: remix-ui/pnpm-lock.yaml
cache: pnpm
- name: Download deps
run: pnpm install --frozen-lockfile
- name: Generate prisma
run: pnpm prisma generate --generator js
- name: Type check
run: pnpm typecheck
vitest:
name: Vitest
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
- name: Checkout repo
uses: actions/checkout@v3
- name: Get package manager version
id: get-pnpm-version
run: echo "version=$(cat package.json | jq -r .packageManager | sed s/pnpm@//)" >> $GITHUB_OUTPUT
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ steps.get-pnpm-version.outputs.version }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: remix-ui/package.json
cache-dependency-path: remix-ui/pnpm-lock.yaml
cache: pnpm
- name: Download deps
run: pnpm install --frozen-lockfile
- name: Run vitest
run: pnpm test -- --coverage
cypress:
name: Cypress
runs-on: ubuntu-latest
env:
PORT: '8811'
services:
localhost:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
- name: Checkout repo
uses: actions/checkout@v3
- name: Get package manager version
id: get-pnpm-version
run: echo "version=$(cat package.json | jq -r .packageManager | sed s/pnpm@//)" >> $GITHUB_OUTPUT
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ steps.get-pnpm-version.outputs.version }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: remix-ui/package.json
cache-dependency-path: remix-ui/pnpm-lock.yaml
cache: pnpm
- name: Cache cypress binary
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-${{ hashFiles('remix-ui/pnpm-lock.yaml') }}
- name: Download deps
run: pnpm install --frozen-lockfile
- name: Download cypress binary
run: pnpm cypress install
- name: Copy test env vars
run: cp .env.example .env
- name: Setup database
run: pnpm prisma migrate reset --force --skip-seed --skip-generate
- name: Build
run: pnpm build
- name: Start frontend
id: startfrontend
run: |
pnpm start:mocks > frontend.log 2>&1 &
echo $! > frontend_pid.txt
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
- name: Wait for frontend
run: pnpm wait-on --timeout 60000 http://localhost:${{ env.PORT }}
- name: Run cypress tests
run: pnpm cypress run --record --tag ${{ github.event_name }} --spec cypress/e2e/smoke.cy.ts
env:
# testing keys (e.g. cypress) and other environment variables.
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# override the github commit message for better Cypress Cloud mesages.
# @see https://github.com/cypress-io/github-action/issues/124#issuecomment-653180260
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
# re-enable the Cypress GitHub PR comment bot
# @see https://docs.cypress.io/guides/continuous-integration/github-actions#Pull-requests-commit-message-is-merge-SHA-into-SHA
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
- name: Kill frontend
if: ${{ always() && steps.startfrontend.outcome == 'success' }}
run: |
frontend_pid=$(cat frontend_pid.txt)
kill $frontend_pid
- name: Display frontend logs
if: always()
run: |
cat frontend.log
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
- name: Checkout repo
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=ref,event=branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
flavor: |
latest=auto
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker build
uses: docker/build-push-action@v3
with:
context: ./remix-ui
platforms: linux/amd64
# only upload main branch (on pushes) to GHCR. otherwise, just check
# to ensure that the docker build completes without error.
push: ${{ (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prod') && github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max