Repository navigation
195 lines (181 loc) · 7.74 KB
/
Copy pathexamples.yml
File metadata and controls
195 lines (181 loc) · 7.74 KB
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
name: Examples
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
# Every job in this workflow checks the same example sources directly against
# `src/` (no build step). This is only possible because the SDK is
# source-isomorphic: every internal import uses `.ts` extensions, and
# `allowImportingTsExtensions` is on in tsconfig.json. If a job below ever has
# to be preceded by `pnpm build`, that means we accidentally broke source
# isomorphism somewhere.
jobs:
changes:
name: Detect changes
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]' }}
runs-on: ubuntu-latest
outputs:
code: ${{ steps.changed-files.outputs.code }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- id: changed-files
uses: ./.github/actions/detect-changes
with:
event-name: ${{ github.event_name }}
base-sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || '' }}
head-sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
typecheck-node:
name: Typecheck (Node ${{ matrix.node-version }})
needs: changes
if: ${{ needs.changes.outputs.code == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]') }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [22.22.2, 24]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Typecheck examples against src/
run: pnpm typecheck:examples
typecheck-bun:
name: Typecheck (Bun)
needs: changes
if: ${{ needs.changes.outputs.code == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22.22.2
cache: pnpm
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest
- run: pnpm install --frozen-lockfile
# Bun ships its own JS/TS runtime but we invoke `tsc` (from the pinned
# devDep) so failures are apples-to-apples with the Node typecheck job.
- name: Typecheck examples against src/ (Bun-hosted tsc)
run: bunx --bun tsc --noEmit -p examples/tsconfig.json
smoke-examples:
name: Smoke-run examples (B2Simulator)
needs: changes
if: ${{ needs.changes.outputs.code == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22.22.2
cache: pnpm
- run: pnpm install --frozen-lockfile
# This tracked executable is also the version-matched entry point used by
# sdkharness. Keeping one implementation prevents CI and fleet evidence
# from silently testing different customer flows.
- name: Run repository-owned customer health contract
run: ./.sdkharness/tests/health-examples
typecheck-deno:
name: Typecheck (Deno)
needs: changes
if: ${{ needs.changes.outputs.code == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: denoland/setup-deno@22d081ff2d3a40755e97629de92e3bcbfa7cf2ed # v2.0.5
with:
deno-version: v2.x
# `deno check` uses Deno's own TS toolchain. The import map in
# examples/deno.json points the bare specifiers (@backblaze-labs/b2-sdk, ...)
# straight at the SDK source under ../src/*.ts. No build, no
# node_modules, no npm: specifier dance.
- name: Typecheck examples with Deno (no build, source only)
working-directory: examples
run: |
deno check \
node-list-buckets.ts \
node-upload.ts \
node-download.ts \
node-sync-cli.ts \
node-with-progress.ts \
partner-authorize.ts \
partner-create-group-member.ts \
partner-list-groups-and-members.ts \
partner-eject-group-member.ts \
partner-reserve-trial-account.ts \
partner-reserve-trial-accounts.ts \
backup-list-computers.ts \
backup-delete-computer.ts \
node-backup-cli/backup.ts \
node-backup-cli/crypto.ts \
node-backup-cli/manifest.ts \
node-backup-cli/worker.ts \
node-plugin-template/index.ts \
node-plugin-template/storage.ts
examples-result:
name: Examples result
needs: [changes, typecheck-node, typecheck-bun, smoke-examples, typecheck-deno]
if: ${{ always() && (github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]') }}
runs-on: ubuntu-latest
steps:
- name: Check job results
env:
CODE_CHANGED: ${{ needs.changes.outputs.code }}
CHANGES_RESULT: ${{ needs.changes.result }}
TYPECHECK_NODE_RESULT: ${{ needs.typecheck-node.result }}
TYPECHECK_BUN_RESULT: ${{ needs.typecheck-bun.result }}
SMOKE_EXAMPLES_RESULT: ${{ needs.smoke-examples.result }}
TYPECHECK_DENO_RESULT: ${{ needs.typecheck-deno.result }}
run: |
set -euo pipefail
failed=false
require_success() {
if [ "$2" != "success" ]; then
echo "::error::$1 concluded '$2'; expected success."
failed=true
fi
}
require_skipped() {
if [ "$2" != "skipped" ]; then
echo "::error::$1 concluded '$2'; expected skipped."
failed=true
fi
}
require_success changes "$CHANGES_RESULT"
if [ "$CODE_CHANGED" = "true" ]; then
require_success typecheck-node "$TYPECHECK_NODE_RESULT"
require_success typecheck-bun "$TYPECHECK_BUN_RESULT"
require_success smoke-examples "$SMOKE_EXAMPLES_RESULT"
require_success typecheck-deno "$TYPECHECK_DENO_RESULT"
else
require_skipped typecheck-node "$TYPECHECK_NODE_RESULT"
require_skipped typecheck-bun "$TYPECHECK_BUN_RESULT"
require_skipped smoke-examples "$SMOKE_EXAMPLES_RESULT"
require_skipped typecheck-deno "$TYPECHECK_DENO_RESULT"
fi
if [ "$failed" = "true" ]; then
exit 1
fi