-
Notifications
You must be signed in to change notification settings - Fork 1
316 lines (305 loc) · 10.3 KB
/
build.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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: Build, Test, and Deliver Client
env:
do_sonarscan: >-
${{ github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name == github.repository }}
on:
pull_request:
push:
branches:
- main
- release/[0-9]+.[0-9]+.[0-9]+
release:
types:
- created
jobs:
ccc:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./lib
timeout-minutes: 5
steps:
- name: Conventional Commits Check
if: contains(fromJSON('["pull_request", "pull_request_target"]'), github.event_name)
id: conventional-commits
uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Types include:
# - fix: fixes
# - feat: features and enhancements
# - chore: non-feature or enhancement (i.e. docs, ci, linting, automated, etc)
types: |
fix
feat
chore
revert
# Scopes include:
# - sdk: changes to @opentdf/sdk (was lib)
# - cli: changes to @opentdf/ctl
# - ci: anything related to ci
# - tests: test only changes
# - docs: anything related solely to documentation
scopes: |
ci
cli
docs
sdk
tests
lib:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./lib
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ !fromJSON(env.do_sonarscan) && 1 || 0 }}
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: './lib/package-lock.json'
- run: npm ci
- run: npm test
- uses: fingerprintjs/action-coverage-report-md@v2
id: coverage-md
with:
srcBasePath: './'
textReportPath: './lib/coverage/coverage.txt'
- run: echo "${MARKDOWN_REPORT}" >>$GITHUB_STEP_SUMMARY
env:
MARKDOWN_REPORT: '${{ steps.coverage-md.outputs.markdownReport }}'
- run: npm audit --omit dev && npm audit --audit-level high --omit dev
- run: npm run license-check
- run: npm run lint
- run: npm pack
- uses: actions/upload-artifact@v4
with:
name: opentdf-sdk-lib
path: ./lib/opentdf-sdk-*.tgz
- name: SonarCloud Scan
if: fromJSON(env.do_sonarscan)
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
cli:
needs:
- lib
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cli
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: './cli/package-lock.json'
- uses: actions/download-artifact@v4
with:
name: opentdf-sdk-lib
path: lib/
- run: npm uninstall @opentdf/sdk && npm ci && npm i ../lib/opentdf-sdk-*.tgz
- run: npm test
- run: npm audit --omit dev && npm audit --audit-level high --omit dev
- run: npm run license-check
- run: npm run lint
- run: npm pack
- name: Setup Bats and bats libs
uses: bats-core/[email protected]
- run: bats bin/opentdf.bats
- uses: actions/upload-artifact@v4
with:
name: opentdf-ctl
path: ./cli/opentdf-ctl-*.tgz
web-app:
needs:
- lib
runs-on: ubuntu-22.04 # NOTE: Playwright not yet supported on 24.04
defaults:
run:
working-directory: ./web-app
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: './web-app/package-lock.json'
- uses: actions/download-artifact@v4
with:
name: opentdf-sdk-lib
path: lib/
- run: npm uninstall @opentdf/sdk && npm ci && npm i ../lib/opentdf-sdk-*.tgz
- run: npm install
- run: npm audit --omit dev && npm audit --audit-level high --omit dev
- run: npm run license-check
- run: npm run lint
- run: npx playwright install
- run: npm test
- run: npm pack
scripts:
runs-on: ubuntu-latest
defaults:
run:
working-directory: .github/workflows
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: 🦇🦇🦇🦇🦇🦇
run: docker run --rm -v "$PWD:/mnt" --workdir "/mnt" bats/bats:1.11.0 *.bats
- name: 🦪 ✔ 🧼🧼🧼
run: >-
docker run --rm -v "$PWD:/mnt" --workdir "/mnt" "koalaman/shellcheck:v0.10.0"
--color=always *.sh
platform-roundtrip:
needs:
- cli
- lib
- web-app
runs-on: ubuntu-22.04 # NOTE: Playwright not yet supported on 24.04
defaults:
run:
working-directory: .github/workflows/roundtrip
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: './web-app/package-lock.json'
- uses: actions/download-artifact@v4
with:
name: opentdf-sdk-lib
path: lib/
- uses: actions/download-artifact@v4
with:
name: opentdf-ctl
path: cli/
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version: '1.22'
- name: Git clone backend
run: |
git clone --depth 1 https://github.com/opentdf/platform.git
go work init
for x in platform/{protocol/go,lib/{fixtures,ocrypto},sdk,service}; do go work use "$x"; done
- run: docker compose up -d --wait --wait-timeout 240
- env:
PLAYWRIGHT_TESTS_TO_RUN: roundtrip
run: |-
./wait-and-test.sh platform
platform-xtest:
needs:
- cli
- lib
uses: opentdf/tests/.github/workflows/xtest.yml@main
with:
js-ref: ${{ github.ref }}
deliver-ghp:
needs:
- lib
- cli
- web-app
- scripts
- platform-xtest
runs-on: ubuntu-latest
timeout-minutes: 5
# To publish from a release or feature branch, remove the ref == condition below
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')) ||
(github.event_name == 'release' && startsWith(github.ref, 'refs/tags/'))
outputs:
FULL_VERSION: ${{ steps.guess-build-metadata.outputs.FULL_VERSION }}
DIST_TAG: ${{ steps.guess-build-metadata.outputs.DIST_TAG }}
TARGET_VERSION: ${{ steps.check-version.outputs.TARGET_VERSION }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: https://npm.pkg.github.com
- name: Check version number is same between tag, library, and/or release
id: check-version
run: |-
if [[ ${{ github.ref }} = refs/heads/release/* ]]; then
scripts/check-version-is.sh "${GITHUB_REF##*release/}"
elif [[ ${{ github.ref }} = refs/tags/sdk/v* ]]; then
scripts/check-version-is.sh "${GITHUB_REF_NAME#v}"
else
scripts/check-version-is.sh
fi
- name: Check version number is same between tag, library, and/or release
id: guess-build-metadata
run: |-
echo "FULL_VERSION=$(.github/workflows/gh-semver.sh)" >> $GITHUB_OUTPUT
echo "DIST_TAG=$(.github/workflows/guess-dist-tag.sh)" >> $GITHUB_OUTPUT
- run: make doc
- run: >-
echo "::notice file=lib/package.json::Will be published to
[GitHub Packages](https://github.com/opentdf/web-sdk/pkgs/npm/client)
as ${{ steps.guess-build-metadata.outputs.DIST_TAG }}
with version=[${{ steps.guess-build-metadata.outputs.FULL_VERSION }}]"
- run: >-
.github/workflows/publish-to.sh
"${{ steps.guess-build-metadata.outputs.FULL_VERSION }}"
"${{ steps.guess-build-metadata.outputs.DIST_TAG }}"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo "- [Client Library](https://github.com/opentdf/web-sdk/pkgs/npm/client)">>$GITHUB_STEP_SUMMARY
- run: echo "- [Command Line Tool](https://github.com/opentdf/web-sdk/pkgs/npm/cli)">>$GITHUB_STEP_SUMMARY
- name: Publish documentation to gh-pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: lib/dist/docs
deliver-npmjs:
runs-on: ubuntu-latest
timeout-minutes: 5
environment: npmjs
needs: deliver-ghp
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')) ||
(github.event_name == 'release' && startsWith(github.ref, 'refs/tags/sdk/v'))
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- run: make all
- run: >-
.github/workflows/publish-to.sh
"${{ needs.deliver-ghp.outputs.FULL_VERSION }}"
"${{ needs.deliver-ghp.outputs.DIST_TAG }}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: >-
echo "- [Client Library](https://www.npmjs.com/package/@opentdf/sdk/v/${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
- run: >-
echo "- [Command Line Tool](https://www.npmjs.com/package/@opentdf/ctl/v/${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
- run: >-
echo "- [unpkg](https://unpkg.com/browse/@opentdf/sdk@${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
ci:
needs:
- lib
- cli
- web-app
- scripts
- platform-xtest
runs-on: ubuntu-22.04
if: ${{ !cancelled() }}
steps:
- if: contains(needs.*.result, 'failure')
run: echo "Failed due to ${{ contains(needs.*.result, 'failure') }}" && exit 1