-
Notifications
You must be signed in to change notification settings - Fork 8
228 lines (219 loc) · 7.27 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
name: Lint, Build, Test and Doc
on:
push:
branches:
- main
- alpha
- 'alpha-*'
- beta
- 'beta-*'
pull_request:
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
name: Installing & Building
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Cancel previous running workflows
uses: fkirc/skip-duplicate-actions@master
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.17.0
- uses: actions/cache@v4
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}-${{ hashFiles('packages/*/package.json') }}
- name: Install & Bootstrap
run: yarn && yarn bootstrap --ci
- name: Build
run: yarn build
- uses: actions/cache/save@v4
with:
path: packages/*/dist
key: ${{ runner.os }}-build-${{ github.sha }}
lint:
name: Lint commit messages
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Lint commit message
uses: wagoid/commitlint-github-action@v5
test:
name: Linting & Testing
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [build]
strategy:
matrix:
package:
- agent
- forest-cloud
- datasource-customizer
- datasource-dummy
- datasource-mongoose
- datasource-replica
- datasource-mongo
- datasource-sequelize
- datasource-sql
- datasource-toolkit
- forestadmin-client
- plugin-aws-s3
- plugin-export-advanced
- plugin-flattener
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.14.0
- name: Start docker containers
if: ${{ matrix.package == 'datasource-mongo' || matrix.package == 'datasource-mongoose' || matrix.package == 'datasource-sql' || matrix.package == 'datasource-sequelize' }}
run: docker compose -f ./packages/${{ matrix.package }}/docker-compose.yml up -d; sleep 5
- name: Restore dependencies from cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}-${{ hashFiles('packages/*/package.json') }}
fail-on-cache-miss: true
- name: Restore build from cache
uses: actions/cache/restore@v4
with:
path: packages/*/dist
key: ${{ runner.os }}-build-${{ github.sha }}
fail-on-cache-miss: true
- name: Lint Typescript
run: cd packages/${{ matrix.package }} && yarn lint && cd -
- name: Test code
run: cd packages/${{ matrix.package }} && yarn test --coverage && cd -
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }}
path: packages/${{ matrix.package }}/coverage/clover.xml
retention-days: 1
send-coverage:
name: Send Coverage
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [test]
steps:
- uses: actions/checkout@v4
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
path: reports
- name: Send coverage
uses: paambaati/codeclimate-action@84cea27117a473d605400ca3a97fcef7e433e2d6
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{github.workspace}}/reports/**/clover.xml:clover
build-api-reference:
name: Build API Reference
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.17.0
- name: Restore dependencies from cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}-${{ hashFiles('packages/*/package.json') }}
fail-on-cache-miss: true
- name: Restore build from cache
uses: actions/cache/restore@v4
with:
path: packages/*/dist
key: ${{ runner.os }}-build-${{ github.sha }}
fail-on-cache-miss: true
- name: Build doc
run: yarn docs
- name: Archive documentation artifacts
uses: actions/upload-pages-artifact@v1
with:
path: api-reference
release:
name: Release packages
runs-on: ubuntu-latest
needs: [build-api-reference, send-coverage, lint]
if: |
github.event_name == 'push'
&& (
github.ref == 'refs/heads/main'
|| github.ref == 'refs/heads/beta'
|| github.ref == 'refs/heads/alpha'
|| startsWith(github.ref, 'refs/heads/alpha-')
|| startsWith(github.ref, 'refs/heads/beta-')
)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false # GITHUB_TOKEN must not be set for the semantic release
- uses: actions/setup-node@v4
with:
node-version: 18.17.0
- name: Restore dependencies from cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}-${{ hashFiles('packages/*/package.json') }}
fail-on-cache-miss: true
- name: Restore build from cache
uses: actions/cache/restore@v4
with:
path: packages/*/dist
key: ${{ runner.os }}-build-${{ github.sha }}
fail-on-cache-miss: true
# TODO: this can be done as a oneliner using the registry option in actions/setup-node step
- name: Configure npm
run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
cat .npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Disable workspaces-update
run: npm config set workspaces-update false
- name: 'Run multi-semantic-release'
run: '$(yarn bin)/multi-semantic-release --deps.bump=override'
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
publish-api-reference:
name: Publish API Reference
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [build-api-reference, send-coverage, lint]
steps:
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1