Skip to content

Commit 8bd20aa

Browse files
authored
Setup Wasm workflow (#10)
* Setup Wasm * Fix testing * Next try * User carton * Revert "User carton" This reverts commit 711c4c8. * Postpone testing * Add .wasm extension * Test wasmer * Point to wasmer * Specific wasmer * Checkout /bin * Try wasmer * WASM * Try without swift * Don't user Swift container * With swift * Bring back tests * Static swift lib * Make build very verbose * Not tests for now * Run without std lib * Build product and let wasmtime run it * Run non-verbose * Try 5.10 - since the other one produces a parsing error * Fix swift wasm index version * Get snapshot with SDK * Use only one swift version
1 parent 10cac18 commit 8bd20aa

4 files changed

Lines changed: 76 additions & 5 deletions

File tree

.github/workflows/_selftest.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ jobs:
2626
selftest-windows:
2727
name: Windows
2828
uses: ./.github/workflows/ci-windows.yml
29+
30+
selftest-wasm:
31+
name: WASM
32+
uses: ./.github/workflows/ci-wasm.yml

.github/workflows/ci-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626
build_config:
2727
- debug
2828
- release
29-
3029
container:
3130
image: swift:${{ matrix.swift_version }}
31+
3232
steps:
3333
- uses: actions/checkout@v4
3434

.github/workflows/ci-wasm.yml

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,71 @@ on:
44
workflow_call:
55

66
jobs:
7-
wasm:
7+
WASM-SPM:
8+
name: SPM Wasm
9+
timeout-minutes: 30
810
runs-on: ubuntu-latest
9-
container: swift:6.0.3
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
swift_version: # https://github.com/swiftwasm/swift-sdk-index/tree/main/v1/builds
15+
- "6.0.3-RELEASE"
16+
build_config:
17+
- debug
18+
- release
19+
1020
steps:
1121
- uses: actions/checkout@v4
12-
- uses: swiftwasm/setup-swiftwasm@v2
13-
- run: swift build --swift-sdk wasm32-unknown-wasi
22+
23+
- name: Setup Swift ${{ matrix.swift_version }} WASM SDK
24+
id: setup-swiftwasm
25+
uses: swiftwasm/setup-swiftwasm@v2
26+
with:
27+
tag: "swift-${{ matrix.swift_version }}"
28+
target: "wasm32-unknown-wasi"
29+
30+
- name: Setup wasmtime
31+
uses: bytecodealliance/actions/wasmtime/setup@v1
32+
with:
33+
version: "30.0.2"
34+
35+
- name: Setup Wasm Runtime
36+
uses: wasmerio/setup-wasmer@v3
37+
with:
38+
version: "v5.0.4"
39+
40+
- name: Cache SPM dependencies
41+
uses: actions/cache@v4
42+
with:
43+
path: |
44+
~/.cache/org.swift.swiftpm
45+
.build/artifacts
46+
.build/checkouts
47+
.build/repositories
48+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
49+
restore-keys: |
50+
${{ runner.os }}-spm-
51+
52+
- name: Build
53+
run: |
54+
swift build -c ${{ matrix.build_config }} --swift-sdk "${{ steps.setup-swiftwasm.outputs.swift-sdk-id }}" --static-swift-stdlib
55+
56+
# - name: Test
57+
# run: |
58+
# swift build -c ${{ matrix.build_config }} --vv --build-tests --triple wasm32-unknown-wasi --swift-sdk "${{ steps.setup-swiftwasm.outputs.swift-sdk-id }}" --static-swift-stdlib
59+
# wasmtime .build/${{ matrix.build_config }}/SharedActionsTests.wasm
60+
61+
- name: Run
62+
run: |
63+
swift build -c ${{ matrix.build_config }} --swift-sdk "${{ steps.setup-swiftwasm.outputs.swift-sdk-id }}" --static-swift-stdlib --product shared-actions
64+
wasmtime .build/${{ matrix.build_config }}/shared-actions.wasm
65+
66+
- name: Upload failure artifacts
67+
if: failure()
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: ${{ runner.os }}-${{ github.job }}-swift_${{ matrix.swift_version }}-${{ matrix.build_config }}-${{ github.run_id }}
71+
path: |
72+
.build
73+
if-no-files-found: warn
74+
include-hidden-files: true

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ Insprired by:
1010
- https://github.com/rapidsai/shared-actions
1111
- https://github.com/awslabs/aws-sdk-swift/tree/main/.github/workflows
1212
- https://github.com/thebrowsercompany/swift-build/blob/main/.github/workflows/swift-toolchain.yml
13+
- https://github.com/google/flatbuffers/blob/master/.github/workflows/build.yml
14+
- https://github.com/pointfreeco/swift-dependencies/blob/main/.github/workflows/ci.yml
15+
- https://github.com/swiftwasm/carton/blob/main/.github/workflows/swift.yml
16+
17+
18+

0 commit comments

Comments
 (0)