Skip to content

Commit

Permalink
Build WAT tools
Browse files Browse the repository at this point in the history
  • Loading branch information
tolauwae committed Dec 8, 2024
1 parent 453e7c5 commit b485714
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,50 @@ name: Tests
on: [ push ]

jobs:
build:
name: Build WAT tools
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Get WABT commit ID
working-directory: tests/unit/artifacts/wabt
run: echo "WABT_VERSION=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Cache wabt
uses: actions/cache@v4
id: cache-wabt
with:
key: ${{ runner.os }}-wabt-${{ env.WABT_VERSION }}
path: tests/unit/artifacts/wabt
restore-keys: |
${{ runner.os }}-wabt-
- name: Build WABT # Build latest version
if: steps.cache-wabt.outputs.cache-hit == false
working-directory: tests/unit/artifacts/wabt
run: |
mkdir build; cd build
cmake ..
cmake --build .
- name: Verify wat2wasm
run: |
echo "WABT=$(readlink -f ./tests/unit/artifacts/wabt/build)" >> $GITHUB_ENV
./tests/unit/artifacts/wabt/build/wat2wasm --version
- name: Upload built tools
uses: actions/upload-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: tests/unit/artifacts/wabt/build

unit:
name: Unit tests
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
if: github.event.pull_request.draft == false
Expand All @@ -16,12 +57,22 @@ jobs:
- name: Prebuild files
run: npm run test:prebuild

- name: Download WAT tools
uses: actions/download-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: .tools

- name: Add .tools to PATH
run: echo "$GITHUB_WORKSPACE/.tools" >> $GITHUB_PATH

- name: Run ava unit tests
run: npm run test:ava

coverage:
name: Code coverage
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: true
if: github.event.pull_request.draft == false
Expand All @@ -33,6 +84,15 @@ jobs:
- name: Prebuild files
run: npm run test:prebuild

- name: Download WAT tools
uses: actions/download-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: .tools

- name: Add .tools to PATH
run: echo "$GITHUB_WORKSPACE/.tools" >> $GITHUB_PATH

- name: Run c8 coverage
run: |
echo "LINE_COVERAGE=$(npm run coverage:test:ava | grep -E '^\s*Lines\s*:\s*[0-9]+(\.[0-9]+)?%' | awk '{print $3}' | tr -d '%')" >> $GITHUB_ENV
Expand Down
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "WABT"]
path = WABT
url = [email protected]:TOPLLab/wabt.git
url = [email protected]:TOPLLab/wabt.git
[submodule "tests/unit/artifacts/wabt"]
path = tests/unit/artifacts/wabt
url = [email protected]:TOPLLab/wabt.git
1 change: 1 addition & 0 deletions tests/unit/artifacts/wabt
Submodule wabt added at 09d542

0 comments on commit b485714

Please sign in to comment.