-
Notifications
You must be signed in to change notification settings - Fork 2
129 lines (112 loc) · 4.4 KB
/
namui-linux-host-wasm32-wasi-web.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
name: namui-linux-host-wasm32-wasi-web
on:
pull_request:
concurrency:
group: ${{ github.ref }}-namui-linux-host-wasm32-wasi-web
cancel-in-progress: true
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
jobs:
list-projects:
runs-on: ubuntu-latest
outputs:
project-dirs: ${{ steps.project-dirs.outputs.dirs }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Output list of project directories
id: project-dirs
run: cargo run --manifest-path ./github-actions-tools/matrix-output/Cargo.toml wasm32-wasi-web $GITHUB_OUTPUT dirs
run-commands:
runs-on: ubuntu-latest
needs:
- list-projects
strategy:
matrix:
dir: ${{ fromJSON(needs.list-projects.outputs.project-dirs) }}
env:
CARGO_LOCK_PATH: ${{ matrix.dir }}/Cargo.lock
CARGO_VERSION: "" # Should be set in the job
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up cargo
run: |
rustup update
rustup target add wasm32-wasip1-threads
- run: CARGO_VERSION=$(cargo --version | cut -d ' ' -f 2) && echo "CARGO_VERSION=$CARGO_VERSION" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: |
~/.cargo/
${{ matrix.dir }}/target/
key: ${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-${{ matrix.dir }}-${{ hashFiles(env.CARGO_LOCK_PATH) }}
restore-keys: |
${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-${{ matrix.dir }}-
${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/namui/namui-cli/wasi-sdk/
${{ github.workspace }}/namui/namui-cli/emscripten/
${{ github.workspace }}/namui/namui-cli/target/
key: ${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-namui-cli-${{ hashFiles('namui/namui-cli/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-namui-cli-
- name: Install wasi-sdk
run: |
cd namui/namui-cli
cargo build
- name: Run commands
working-directory: ${{ matrix.dir }}
env:
CLANGCC: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang
CLANGCXX: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang++
CC: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang
CXX: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang++
WASI_SDK: ${{ github.workspace }}/namui/namui-cli/wasi-sdk
WASI_SYSROOT: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/share/wasi-sysroot
EMSDK_SYSTEM_INCLUDE: ${{ github.workspace }}/namui/namui-cli/emscripten/system/include
CLANG_PATH: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang
CARGO_TARGET_WASM32_WASIP1_THREADS_LINKER: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/wasm-ld
CARGO_BUILD_TARGET: wasm32-wasip1-threads
run: |
echo "Running commands in ${{ matrix.dir }}"
# Print the environment variables to verify
echo "CLANGCC=$CLANGCC"
echo "CLANGCXX=$CLANGCXX"
echo "CC=$CC"
echo "CXX=$CXX"
echo "WASI_SDK=$WASI_SDK"
echo "WASI_SYSROOT=$WASI_SYSROOT"
echo "EMSDK_SYSTEM_INCLUDE=$EMSDK_SYSTEM_INCLUDE"
echo "CLANG_PATH=$CLANG_PATH"
echo "CARGO_TARGET_WASM32_WASIP1_THREADS_LINKER=$CARGO_TARGET_WASM32_WASIP1_THREADS_LINKER"
echo "cargo check --tests"
cargo check --tests
echo "cargo fmt"
cargo fmt
echo "cargo clippy --tests"
cargo clippy --tests
# Cannot run test on wasi yet.
# echo "cargo test"
# cargo test
post-namui-linux-host-wasm32-wasi-web:
if: always()
runs-on: ubuntu-latest
needs:
- run-commands
steps:
- run: |
echo ${{ join(needs.*.result, ',') }}
any_test_failed=${{ contains(join(needs.*.result, ','), 'failure') }}
echo $any_test_failed
if [[ $any_test_failed == "true" ]]; then
echo "::error::There are failed job"
exit 1
else
echo "Good. No test failed"
fi