-
Notifications
You must be signed in to change notification settings - Fork 8
358 lines (298 loc) · 9.78 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
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for the "main" and "pre-release" branches
push:
branches: [ main, pre-release ]
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
sdk-ref:
description: 'sdk commit/tag/branch reference. Defaults to main.'
required: false
type: string
default: main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
setup:
name: setup
runs-on: ubuntu-latest
outputs:
sdk-ref: ${{ inputs.sdk-ref || '83740c3595ac16b29896c76a2e8790fba0535ab3' }}
package-version: '0.5.0'
steps:
- run: echo "set pre-setup output variables"
build-packages:
needs: setup
name: build packages
uses: breez/breez-sdk/.github/workflows/publish-all-platforms.yml@main
with:
repository: breez/breez-sdk
ref: ${{ needs.setup.outputs.sdk-ref }}
package-version: ${{ needs.setup.outputs.package-version }}
packages-to-publish: '["csharp", "flutter", "golang", "react-native", "python"]'
use-dummy-binaries: true
check-rust:
needs: setup
name: Check rust snippets
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
# Set up Rust environment and run checks
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: snippets/rust -> snippets/rust/target
- name: temporarily get sdk
uses: actions/checkout@v4
with:
repository: breez/breez-sdk
ref: ${{ needs.setup.outputs.sdk-ref }}
path: breez-sdk
- id: rev-parse
name: get proper rev
working-directory: breez-sdk
run: |
rev=$(git rev-parse HEAD)
echo "$rev"
echo "rev=$rev" >> $GITHUB_OUTPUT
- name: set sdk version
working-directory: snippets/rust
run: |
cargo add --git https://github.com/breez/breez-sdk.git breez-sdk-core --rev "${{ steps.rev-parse.outputs.rev }}"
- name: clippy
working-directory: snippets/rust
run: |
# Explicitly allow clippy::dead_code lint because the functions aren't called in the docs snippets
# Explicitly allow clippy::unused_variables because snippets might have to demonstrate how to get certain variables without using them afterward
cargo clippy -- --allow dead_code --allow unused_variables --deny warnings
check-dart:
needs:
- setup
- build-packages
name: Check dart snippets
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
# Set up the flutter environment and run checks
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- uses: actions/download-artifact@v4
with:
name: breez-sdk-flutter-${{ needs.setup.outputs.package-version }}
path: snippets/dart_snippets/packages/breez-sdk-flutter
- name: pub-get
working-directory: snippets/dart_snippets
run: flutter pub get
- name: dart-analyze
working-directory: snippets/dart_snippets
run: dart analyze --fatal-infos
check-csharp:
needs:
- setup
- build-packages
name: Check C# snippets
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
- name: Download archived package
uses: actions/download-artifact@v4
with:
name: Breez.Sdk.${{ needs.setup.outputs.package-version }}.nupkg
path: .
- name: Create nuget package source
working-directory: snippets/csharp
run: |
mkdir packages
nuget add ../../Breez.Sdk.${{ needs.setup.outputs.package-version }}.nupkg -Source ./packages
- name: Add nuget dependency
working-directory: snippets/csharp
run: |
dotnet add package Breez.Sdk -s ./packages --prerelease
- name: Build the csharp project
working-directory: snippets/csharp
run: dotnet build
check-react-native:
needs:
- setup
- build-packages
name: Check react native snippets
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Download archived package
uses: actions/download-artifact@v4
with:
name: react-native-${{ needs.setup.outputs.package-version }}
path: snippets/react-native/packages
- name: Install dependencies
working-directory: snippets/react-native
run: yarn
- name: Check syntax
working-directory: snippets/react-native
run: tsc
- name: Check formatting
working-directory: snippets/react-native
run: yarn run lint
check-golang:
needs:
- setup
- build-packages
name: Check Go snippets
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Download archived package
uses: actions/download-artifact@v4
with:
name: breez-sdk-go-${{ needs.setup.outputs.package-version }}
path: snippets/go/packages/breez-sdk-go
- name: Format the Go snippets
working-directory: snippets/go
run: go fmt
- name: Test formatted correctly
working-directory: snippets/go
run: |
status=$(git status --porcelain)
if [[ -n "$status" ]]; then
echo "Git status has changes"
echo "$status"
git diff
exit 1
else
echo "No changes in git status"
fi
- name: Build the Go snippets
working-directory: snippets/go
run: |
go get
go build .
check-python:
needs:
- build-packages
name: Check Python snippets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Download archived package
uses: actions/download-artifact@v4
with:
name: python-wheel-3.8-manylinux_2_31_x86_64
path: snippets/python/packages
- name: Install dependencies
working-directory: snippets/python
run: |
python -m pip install --upgrade pip
pip install ruff
whlfile=$(ls packages | grep .whl)
pip install "packages/$whlfile"
- name: Check python formatting
working-directory: snippets/python/src
run: ruff check --ignore F841 --ignore F401 --add-noqa .
- name: Check python syntax
working-directory: snippets/python
run: python3 -m compileall src
check-swift:
name: Check Swift snippets
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Set up Swift
uses: swift-actions/setup-swift@v1
with:
swift-version: "5"
- name: Build
working-directory: snippets/swift/BreezSDKExamples
run: |
swift build
check-kotlin:
needs: setup
name: Check kotlin MPP snippets
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Java 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 17
- name: Compile Kotlin
working-directory: snippets/kotlin_mpp_lib
run: |
./gradlew build
build:
name: Build mdbook
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install rust
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
. -> target
snippets-processor -> snippets-processor/target
- name: Install dependencies
run: |
cargo install mdbook --vers "^0.4" --locked
cargo install --path ./snippets-processor
- name: Build mdbook
run: mdbook build
- name: Archive book
uses: actions/upload-artifact@v4
with:
name: book
path: book
- name: Push book to main-generated branch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
git config --global user.name "Generator"
git config --global user.email "[email protected]"
git add -f book
git commit -m "Generate documentation"
git push origin --force main:main-generated
- name: Push book to pre-release-generated branch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/pre-release' }}
run: |
git config --global user.name "Generator"
git config --global user.email "[email protected]"
git add -f book
git commit -m "Generate documentation"
git push origin --force pre-release:pre-release-generated