Skip to content

Commit e742a8d

Browse files
committed
Refactor CI workflow
1 parent e17dd9d commit e742a8d

File tree

3 files changed

+65
-85
lines changed

3 files changed

+65
-85
lines changed

.github/workflows/build.yml

Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,75 +6,69 @@ on:
66
pull_request:
77
branches: main
88

9-
env:
10-
WASI_VERSION: 12
11-
WASI_VERSION_FULL: "12.0"
12-
WABT_VERSION: "1.0.24"
13-
EMCC_VERSION: "1.40.1-fastcomp"
14-
159
jobs:
1610
build:
17-
runs-on: ubuntu-18.04
11+
runs-on: ubuntu-latest
12+
env:
13+
WASI_SDK_VERSION: "21"
14+
WASI_SDK_PATH: /opt/wasi-sdk
15+
WABT_VERSION: "1.0.34"
16+
WABT_PATH: /opt/wabt
17+
BINARYEN_VERSION: "117"
18+
BINARYEN_PATH: /opt/binaryen
1819
steps:
1920
- name: Checkout
20-
uses: actions/checkout@v2
21-
22-
- name: Prepare
23-
id: preparation
24-
run: |
25-
export PWD=$(pwd);
26-
echo "::set-output name=PROJ_ROOT::$PWD";
21+
uses: actions/checkout@v4
22+
- name: Setup Node
23+
uses: actions/setup-node@v4
24+
with:
25+
cache: 'npm'
2726

2827
- name: Install
29-
run: npm install
28+
run: npm ci
3029

31-
- name: Install wasi-sdk
32-
env:
33-
PROJ_ROOT: ${{ steps.preparation.outputs.PROJ_ROOT }}
30+
- name: "Restore WASI SDK"
31+
id: cache-wasi-sdk
32+
uses: actions/cache@v4
33+
with:
34+
path: ${{ env.WASI_SDK_PATH }}
35+
key: ${{ runner.os }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}
36+
- name: "Install WASI SDK"
37+
if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
3438
run: |
35-
cd $PROJ_ROOT;
36-
cd ../;
37-
export WASI_OS="linux"
38-
curl -sL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-${WASI_OS}.tar.gz -O
39-
# check if package downloaded
40-
ls -la
41-
tar xvf wasi-sdk-${WASI_VERSION_FULL}-${WASI_OS}.tar.gz
42-
# print clang version
43-
./wasi-sdk-${WASI_VERSION_FULL}/bin/clang --version
44-
- name: Install wabt
45-
env:
46-
PROJ_ROOT: ${{ steps.preparation.outputs.PROJ_ROOT }}
39+
mkdir ${{ env.WASI_SDK_PATH }} && \
40+
curl -s -S --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ env.WASI_SDK_VERSION }}/wasi-sdk-${{ env.WASI_SDK_VERSION }}.0-linux.tar.gz | \
41+
tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip
42+
- name: "Restore WABT"
43+
id: cache-wabt
44+
uses: actions/cache@v4
45+
with:
46+
path: ${{ env.WABT_PATH }}
47+
key: ${{ runner.os }}-wabt-${{ env.WABT_VERSION }}
48+
- name: "Install WABT"
49+
if: steps.cache-wabt.outputs.cache-hit != 'true'
4750
run: |
48-
cd $PROJ_ROOT;
49-
cd ../;
50-
if [[ "$RUNNER_OS" == "Linux" ]]; then
51-
export WABT_OS="ubuntu";
52-
fi
53-
if [[ "$RUNNER_OS" == "macOS" ]]; then
54-
export WABT_OS="macos";
55-
fi
56-
if [[ "$RUNNER_OS" == "Windows" ]]; then
57-
export WABT_OS="windows";
58-
fi
59-
curl -sL https://github.com/WebAssembly/wabt/releases/download/${WABT_VERSION}/wabt-${WABT_VERSION}-${WABT_OS}.tar.gz -O
60-
# check if package downloaded
61-
ls -la
62-
tar xvf wabt-${WABT_VERSION}-${WABT_OS}.tar.gz
63-
# check if wabt binaries installed
64-
ls -la ./wabt-${WABT_VERSION}/bin/
51+
mkdir ${{ env.WABT_PATH }} && \
52+
curl -s -S --location https://github.com/WebAssembly/wabt/releases/download/${{ env.WABT_VERSION }}/wabt-${{ env.WABT_VERSION }}-ubuntu.tar.gz | \
53+
tar --strip-components 1 --directory ${{ env.WABT_PATH }} --extract --gunzip
54+
- name: "Restore Binaryen"
55+
id: cache-binaryen
56+
uses: actions/cache@v4
57+
with:
58+
path: ${{ env.BINARYEN_PATH }}
59+
key: ${{ runner.os }}-binaryen-${{ env.BINARYEN_VERSION }}
60+
- name: "Install Binaryen"
61+
if: steps.cache-binaryen.outputs.cache-hit != 'true'
62+
run: |
63+
mkdir ${{ env.BINARYEN_PATH }} && \
64+
curl -s -S --location https://github.com/WebAssembly/binaryen/releases/download/version_${{ env.BINARYEN_VERSION }}/binaryen-version_${{ env.BINARYEN_VERSION }}-x86_64-linux.tar.gz | \
65+
tar --strip-components 1 --directory ${{ env.WABT_PATH }} --extract --gunzip
6566
- name: Compile to Wasm & Test Wasm
66-
env:
67-
PROJ_ROOT: ${{ steps.preparation.outputs.PROJ_ROOT }}
6867
run: |
69-
cd $PROJ_ROOT;
7068
rm lib/lexer.wasm;
7169
npm run build-wasm;
7270
npm run build;
7371
# test
7472
npm run test;
7573
- name: Benchmark Wasm
76-
env:
77-
PROJ_ROOT: ${{ steps.preparation.outputs.PROJ_ROOT }}
78-
run: |
79-
cd $PROJ_ROOT;
80-
npm run bench;
74+
run: npm run bench;

.github/workflows/node.js.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
# These flags depend on the system and may be overridden
2+
3+
ifeq ($(WASI_SDK_PATH),)
24
WASM_CC := ../wasi-sdk-12.0/bin/clang
35
WASM_CFLAGS := --sysroot=../wasi-sdk-12.0/share/wasi-sysroot
6+
else
7+
WASM_CC := $(WASI_SDK_PATH)/bin/clang
8+
WASM_CFLAGS := $(WASI_SDK_PATH)/share/wasi-sysroot
9+
endif
10+
411
WASM_LDFLAGS := -nostartfiles
512

13+
ifeq ($(WABT_PATH),)
614
WASM2WAT := ../wabt/bin/wasm2wat
15+
else
16+
WASM2WAT := $(WABT_PATH)/bin/wasm2wat
17+
endif
18+
19+
ifeq ($(BINARYEN_PATH),)
720
WASM_OPT := ../binaryen/bin/wasm-opt
21+
else
22+
WASM_OPT := $(BINARYEN_PATH)/bin/wasm-opt
23+
endif
824

925
# These are project-specific and are expected to be kept intact
1026
WASM_EXTRA_CFLAGS := -I include-wasm/ -Wno-logical-op-parentheses -Wno-parentheses -Oz

0 commit comments

Comments
 (0)