-
Notifications
You must be signed in to change notification settings - Fork 7
256 lines (209 loc) · 7.54 KB
/
ci.yaml
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
name: CI
on:
push:
branches: ['main', 'v1.2', 'v1.3']
tags: ['**']
pull_request:
workflow_dispatch:
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- job_name: eslint
run_script: yarn run eslint:lint
- job_name: build
run_script: yarn run build
- job_name: test
run_script: yarn run test
- job_name: api-exporter
run_script: |
yarn run ts:build
yarn run ae:test
- job_name: lint-imports
run_script: yarn tsx ./scripts/lint/module-import-linter.ts
- job_name: dedupe
run_script: yarn dedupe --check
container: node:16-alpine
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get yarn cache directory path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
id: yarn-cache-dir-path
- name: Install GNU tar
run: apk add --no-cache tar
- name: Set up yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install yarn deps
run: |
yarn --version
yarn install --immutable
- name: Run ${{ matrix.job_name }}
run: ${{ matrix.run_script }}
playwright:
needs: [ test ]
runs-on: ubuntu-latest
container: mcr.microsoft.com/playwright:v1.32.3-focal
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_PASSWORD: 'contember'
POSTGRES_USER: 'contember'
POSTGRES_DB: 'contember'
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
contember-engine:
image: contember/engine:1.2.0
env:
NODE_ENV: 'development'
CONTEMBER_PORT: '4000'
CONTEMBER_ROOT_EMAIL: 'superadmin@localhost'
CONTEMBER_ROOT_PASSWORD: 'superadmin@localhost'
CONTEMBER_ROOT_TOKEN: '0000000000000000000000000000000000000000'
CONTEMBER_LOGIN_TOKEN: '1111111111111111111111111111111111111111'
CONTEMBER_ENCRYPTION_KEY: '0000000000000000000000000000000000000000000000000000000000000000'
DEFAULT_DB_HOST: 'postgres'
DEFAULT_DB_PORT: '5432'
DEFAULT_DB_USER: 'contember'
DEFAULT_DB_PASSWORD: 'contember'
TENANT_DB_NAME: 'contember'
DEFAULT_S3_ENDPOINT: 'http://minio:9000'
DEFAULT_S3_PROVIDER: 'minio'
DEFAULT_S3_REGION: ''
DEFAULT_S3_BUCKET: 'contember'
DEFAULT_S3_PREFIX: 'data'
DEFAULT_S3_KEY: 'contember'
DEFAULT_S3_SECRET: 'contember'
minio:
image: bitnami/minio
env:
MINIO_ROOT_USER: 'contember'
MINIO_ROOT_PASSWORD: 'contember'
MINIO_DEFAULT_BUCKETS: 'contember:download'
env:
VITE_CONTEMBER_ADMIN_API_BASE_URL: 'http://contember-engine:4000'
VITE_CONTEMBER_ADMIN_SESSION_TOKEN: '0000000000000000000000000000000000000000'
HOME: '/root'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Set up yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install yarn deps
run: |
yarn --version
yarn install --immutable
- name: Prepare for playwright tests
run: |
yarn run admin:pw:build
- name: Run playwright tests
run: yarn run admin:pw:test --forbid-only
- uses: jakejarvis/s3-sync-action@master
if: always()
with:
args: --acl public-read
env:
AWS_S3_BUCKET: 'contember-admin'
AWS_ACCESS_KEY_ID: ${{ secrets.PLAYWRIGHT_S3_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PLAYWRIGHT_S3_SECRET }}
AWS_S3_ENDPOINT: 'https://fra1.digitaloceanspaces.com'
SOURCE_DIR: 'packages/admin/tests/playwright/report'
DEST_DIR: ${{ github.sha }}
- uses: phulsechinmay/[email protected]
if: always() && github.event_name == 'pull_request'
with:
message: '[Playwright Test Report](https://contember-admin.fra1.digitaloceanspaces.com/${{ github.sha }}/index.html)'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
if: github.event_name == 'push' && github.ref_type == 'tag'
needs: [test, playwright]
runs-on: ubuntu-latest
container: node:16-alpine
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Install GNU tar
run: apk add --no-cache tar
- name: Set up yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Extract version from tag
run: echo "PACKAGE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install yarn deps
run: |
yarn --version
yarn install --immutable
- name: Build
run: yarn run build
- name: Publish
run: |
yarn config set npmAuthToken "$NPM_TOKEN"
yarn workspaces foreach -t version "${GITHUB_REF:11}"
yarn workspaces foreach -pt --no-private npm publish --access public
publish-docker:
if: (github.event_name == 'push' && github.ref_type == 'tag') || github.event_name == 'workflow_dispatch'
needs: [test, playwright]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Release Tag
if: github.event_name == 'push' && github.ref_type == 'tag'
run: 'echo "TAG=${GITHUB_REF:11}" >> $GITHUB_ENV'
- name: Canary Tag
if: github.event_name == 'workflow_dispatch'
run: 'echo "TAG=canary-${GITHUB_SHA:0:10}" >> $GITHUB_ENV'
- name: Build & Publish Docker Image
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
docker login --username "$DOCKER_USER" --password "$DOCKER_PASSWORD"
docker buildx build \
--platform linux/amd64,linux/arm64 \
--file ee/admin-server/Dockerfile \
--cache-from type=registry,ref=ghcr.io/contember/admin \
--cache-to type=registry,ref=ghcr.io/contember/admin,mode=max \
--tag "contember/admin:$TAG" \
--push \
.