-
Notifications
You must be signed in to change notification settings - Fork 0
237 lines (225 loc) · 7.09 KB
/
build.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
name: build
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main'}}
on:
push:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm run lint
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm run build
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm run test
test-int:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- uses: pnpm/action-setup@v4
- uses: rrainn/[email protected]
with:
port: 8001
- run: pnpm install
- run: pnpm run test:int
test-e2e:
needs: [lint, build, test, test-int]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
working-directory: e2e
- uses: rrainn/[email protected]
with:
port: 8000
- name: Start services
run: |
pnpm run --filter api db:init
pnpm run dev &
working-directory: .
env:
VITE_API_URL: http://localhost:3000
- name: Configure environment
run: |
touch .env
echo "USER1_EMAIL=$USER1_EMAIL" >> .env
echo "USER1_PASSWORD=$USER1_PASSWORD" >> .env
echo "USER2_EMAIL=$USER2_EMAIL" >> .env
echo "USER2_PASSWORD=$USER2_PASSWORD" >> .env
env:
USER1_EMAIL: ${{ secrets.TEST_USER1_EMAIL }}
USER1_PASSWORD: ${{ secrets.TEST_USER1_PASSWORD }}
USER2_EMAIL: ${{ secrets.TEST_USER2_EMAIL }}
USER2_PASSWORD: ${{ secrets.TEST_USER2_PASSWORD }}
working-directory: e2e
- name: Wait for services
run: |
npx --yes wait-on http://localhost:3000
# Note: wait-on doesn't work with Vite when sending a head request
# https://github.com/jeffbski/wait-on/issues/78
npx --yes wait-on tcp:5173
- name: Run Playwright tests
run: pnpm run test:e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: e2e/playwright-report/
retention-days: 1
test-mutate:
runs-on: ubuntu-latest
needs: [test-e2e]
if: github.ref == 'refs/heads/main'
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- uses: pnpm/action-setup@v4
- run: pnpm --filter api install
- run: pnpm --filter api run test:mutate
test-mutate-data:
runs-on: ubuntu-latest
needs: [test-e2e]
if: github.ref == 'refs/heads/main'
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- uses: pnpm/action-setup@v4
- uses: rrainn/[email protected]
with:
port: 8001
- run: pnpm --filter api install
- run: pnpm run --filter api db:test:init
- run: pnpm --filter api run test:mutate:data
build-api:
needs: [test-e2e]
if: github.ref == 'refs/heads/main'
uses: jbrunton/workflows/.github/workflows/build-image.yml@v1
with:
repo-name: jbrunton/chat-demo-api
build-directory: services/api/isolate
prepare-cmd: |
pnpm install
pnpm --filter api build
pnpm --filter api isolate
node-version-file: "package.json"
publish: true
docker-username: jbrunton
cache-image: jbrunton/chat-demo-api-cache-image:latest
run-image: jbrunton/run-google-22
secrets:
docker-access-token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
deploy-staging:
environment:
name: Staging
url: https://chat-demo.staging.jbrunton-aws.com
concurrency: staging
needs: [build-api]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- uses: pnpm/action-setup@v4
- name: Build Client
env:
VITE_API_URL: https://chat-demo-api.staging.jbrunton-aws.com
run: |
pnpm --filter client install
pnpm --filter client run build
- run: pnpm install --ignore-workspace
working-directory: pulumi
- uses: pulumi/actions@v3
with:
command: up
stack-name: staging
upsert: true
work-dir: pulumi
comment-on-pr: true
github-token: ${{ secrets.CI_MINION_PAT }}
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
API_TAG: ${{ needs.build-api.outputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy-production:
environment:
name: Production
url: https://chat-demo.jbrunton-aws.com
concurrency: production
needs: [build-api, deploy-staging]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: "package.json"
- uses: pnpm/action-setup@v4
- name: build
env:
VITE_API_URL: https://chat-demo-api.jbrunton-aws.com
run: |
pnpm --filter client install
pnpm --filter client run build
- run: pnpm install --ignore-workspace
working-directory: pulumi
- uses: pulumi/actions@v3
with:
command: up
stack-name: production
upsert: true
work-dir: pulumi
comment-on-pr: true
github-token: ${{ secrets.CI_MINION_PAT }}
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
API_TAG: ${{ needs.build-api.outputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}