-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (69 loc) · 2.25 KB
/
Copy pathenv-safe.yml
File metadata and controls
80 lines (69 loc) · 2.25 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
# This workflow demonstrates how to use the `setup-wasi-sdk` action alongside another toolchain.
# By default, the `add-to-path` input is set to `true`, overriding the runner `PATH`, `CC`, and
# other variables. Here we demonstrate using the action outputs along with a step ID to access the
# installed tools, without modifying the environment.
name: environment-safe
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
merge_group:
permissions: {}
jobs:
env:
name: Example
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./
id: wasi-sdk
with:
add-to-path: 'false'
- name: Check output variables
shell: bash
env:
CLANG_PATH: ${{ steps.wasi-sdk.outputs.clang-path }}
SDK_PATH: ${{ steps.wasi-sdk.outputs.wasi-sdk-path }}
SDK_VERSION: ${{ steps.wasi-sdk.outputs.wasi-sdk-version }}
SYSROOT_PATH: ${{ steps.wasi-sdk.outputs.sysroot-path }}
run: |
echo "wasi-sdk-path: $SDK_PATH"
echo "wasi-sdk-version: $SDK_VERSION"
echo "clang-path: $CLANG_PATH"
echo "sysroot-path: $SYSROOT_PATH"
- name: Check Clang version
env:
CLANG_PATH: ${{ steps.wasi-sdk.outputs.clang-path }}
run: '"$CLANG_PATH" --version'
- name: Create test C program
shell: bash
run: |
cat > hello.c << 'EOF'
#include <stdio.h>
int main() {
printf("Hello, WebAssembly!\n");
return 0;
}
EOF
# Note how we must also set the sysroot path manually which would otherwise be set up for us
# in the `CC` environment variable.
- name: Build WebAssembly module
shell: bash
env:
CLANG_PATH: ${{ steps.wasi-sdk.outputs.clang-path }}
SYSROOT_PATH: ${{ steps.wasi-sdk.outputs.sysroot-path }}
run: |
"$CLANG_PATH" \
--sysroot="$SYSROOT_PATH" \
hello.c -o hello.wasm
ls -la hello.wasm
file hello.wasm