-
-
Notifications
You must be signed in to change notification settings - Fork 440
199 lines (154 loc) · 4.9 KB
/
main.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
name: Main
on:
push:
branches:
- master
- "push-action/**"
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
main-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node and pnpm
uses: silverhand-io/actions-node-pnpm-run-steps@v5
- name: Build
run: pnpm ci:build
main-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node and pnpm
uses: silverhand-io/actions-node-pnpm-run-steps@v5
- name: Prepack
run: pnpm prepack
- name: Check
run: pnpm -r check
main-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node and pnpm
uses: silverhand-io/actions-node-pnpm-run-steps@v5
- name: Prepack
run: pnpm prepack
- name: Lint
run: pnpm ci:lint
- name: Stylelint
run: pnpm ci:stylelint
main-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node and pnpm
uses: silverhand-io/actions-node-pnpm-run-steps@v5
- name: Build for test
run: pnpm -r build:test
- name: Test
run: pnpm ci:test
- name: Codecov core
uses: codecov/codecov-action@v4
with:
flags: core
directory: ./packages/core
token: ${{ secrets.CODECOV_TOKEN }}
- name: Codecov ui
uses: codecov/codecov-action@v4
with:
flags: ui
directory: ./packages/ui
token: ${{ secrets.CODECOV_TOKEN }}
main-dockerize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/build-push-action@v6
with:
context: .
build-args: | # Test cloud build
additional_connector_args=--cloud
main-alteration:
runs-on: ubuntu-latest
steps:
# ** Checkout fresh and alteration ref **
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: ./fresh
# Fetch the current version by finding the latest tag starts with "v", e.g. "v1.0.0-beta.19"
- id: version
working-directory: ./fresh
run: echo "current=$(git describe --match "@logto/core@*" --abbrev=0)" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
ref: ${{ steps.version.outputs.current }}
path: ./alteration
# ** End **
- name: Copy lockfile # Make setup workflow happy
run: cp ./fresh/pnpm-lock.yaml ./
- name: Setup Node and pnpm
uses: silverhand-io/actions-node-pnpm-run-steps@v5
with:
run-install: false
# ** Prepack packages **
- name: Prepack fresh
working-directory: ./fresh
run: pnpm i && pnpm prepack
- name: Prepack alteration
working-directory: ./alteration
run: pnpm i && pnpm prepack
# ** End **
- name: Setup Postgres
uses: ikalnytskyi/action-setup-postgres@v6
# ** Setup up-to-date databases and compare (test `up`) **
- name: Setup fresh database
working-directory: ./fresh
run: pnpm cli db seed --test
env:
DB_URL: postgres://postgres:postgres@localhost:5432/fresh
- name: Setup alteration database
working-directory: ./alteration
run: |
cd packages/cli
pnpm start db seed --test
env:
DB_URL: postgres://postgres:postgres@localhost:5432/alteration
- name: Run alteration scripts
working-directory: ./fresh
run: pnpm cli db alt deploy next
env:
ALTERATION_TEST: true
DB_URL: postgres://postgres:postgres@localhost:5432/alteration
- name: Compare databases
working-directory: ./fresh
run: node .scripts/compare-database.js fresh alteration
# ** End **
# ** Setup old databases and compare (test `down`) **
- name: Setup old database
working-directory: ./alteration
run: |
cd packages/cli
pnpm start db seed --test
env:
DB_URL: postgres://postgres:postgres@localhost:5432/old
- name: Revert fresh database to old
working-directory: ./fresh
run: pnpm cli db alt r v$(echo ${{ steps.version.outputs.current }} | cut -d@ -f3)
env:
ALTERATION_TEST: true
DB_URL: postgres://postgres:postgres@localhost:5432/fresh
- name: Compare manifests
working-directory: ./fresh
run: node .scripts/compare-database.js fresh old
# ** End **
- name: Check alteration sequence
working-directory: ./fresh
run: node .scripts/check-alterations-sequence.js