Skip to content

Commit bdce29b

Browse files
authored
Merge pull request #42 from stlab/npd/swift-check
Build and check Swift snippets
2 parents c19ab8c + 8309cd4 commit bdce29b

4 files changed

Lines changed: 297 additions & 51 deletions

File tree

.github/workflows/build.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v6
24-
24+
2525
# Cache Rust toolchain and cargo registry
2626
- name: Cache Rust
2727
uses: actions/cache@v4
@@ -36,24 +36,28 @@ jobs:
3636
key: ${{ runner.os }}-cargo-${{ hashFiles('versions.txt') }}
3737
restore-keys: |
3838
${{ runner.os }}-cargo-
39-
39+
4040
- name: Install mdBook and plugins (Linux)
4141
if: runner.os != 'Windows'
4242
run: |
4343
chmod +x scripts/install-tools.sh
4444
./scripts/install-tools.sh
45-
45+
4646
- name: Install mdBook and plugins (Windows)
4747
if: runner.os == 'Windows'
4848
run: .\scripts\install-tools.ps1
49-
49+
50+
# Install Swift for testing Swift code examples in the book (Ubuntu only; setup-swift does not support Windows)
51+
- name: Setup Swift
52+
if: runner.os != 'Windows'
53+
uses: swift-actions/setup-swift@v2
54+
5055
- name: Build with mdBook
5156
run: mdbook build ./better-code
52-
57+
5358
- name: Upload build artifact
5459
uses: actions/upload-artifact@v4
5560
with:
5661
name: mdbook-build-${{ matrix.os }}
5762
path: ./better-code/book
5863
retention-days: 1
59-

better-code/book.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,14 @@ enable = true
2020
[output.html.print]
2121
enable = true
2222

23+
[output.html.code.hidelines]
24+
swift = "#"
25+
2326
[preprocessor.katex]
2427

28+
# Tests all Swift code blocks during `mdbook build`
29+
# supported-platforms: Only run on these platforms (python3 sys.platform values); omitted => run on all
30+
[output.swift-test]
31+
command = "python3 ../../../scripts/mdbook-swift-test.py"
32+
# Note: setup-swift@v3 does not support Windows
33+
supported-platforms = ["linux", "darwin"]

0 commit comments

Comments
 (0)