reproducible build for wasm #146
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install RIME dependencies | |
run: | | |
sudo apt install -y ninja-build \ | |
clang-format \ | |
libboost-dev \ | |
libboost-filesystem-dev \ | |
libboost-regex-dev \ | |
libboost-system-dev \ | |
libyaml-cpp-dev \ | |
libleveldb-dev \ | |
libmarisa-dev \ | |
libopencc-dev | |
- name: Use Node.js latest | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18.x | |
- name: Install node dependencies | |
run: | | |
npm i -g pnpm | |
pnpm i | |
- name: Get submodules | |
run: | | |
pnpm run submodule | |
- name: Get font | |
run: | | |
pnpm run font | |
- name: Run lint | |
run: | | |
pnpm run lint | |
- name: Install emsdk | |
run: | | |
git clone https://github.com/emscripten-core/emsdk.git | |
cd emsdk | |
./emsdk install latest | |
./emsdk activate latest | |
- name: Build wasm | |
run: | | |
. emsdk/emsdk_env.sh | |
pnpm run native | |
pnpm run schema | |
pnpm run lib | |
pnpm run wasm | |
- name: Check wasm reproducibility | |
run: | | |
pnpm run checksum | |
- name: Build | |
run: | | |
pnpm run build | |
- name: Tar files | |
run: tar --exclude=build/librime_native/bin/build -cvf artifact.tar build/librime_native/bin dist | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifact.tar | |
path: artifact.tar | |
test: | |
needs: build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
browser: [chromium, firefox] # webkit | |
include: | |
- os: macos-latest | |
browser: webkit | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js latest | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18.x | |
- name: Install node dependencies | |
run: | | |
npm i -g pnpm | |
pnpm i | |
npx playwright install | |
npx playwright install-deps ${{ matrix.browser }} | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact.tar | |
- name: Untar files | |
run: tar -xvf artifact.tar | |
- name: Test | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
npx playwright test --browser ${{ matrix.browser }} test/ | |
- name: Test device | |
if: ${{ matrix.os == 'macos-latest' }} | |
run: | | |
npx playwright test --browser ${{ matrix.browser }} test-device/ | |
release: | |
needs: test | |
if: ${{ github.ref == 'refs/heads/master' }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact.tar | |
- name: Untar files | |
run: tar -xvf artifact.tar | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mv dist my-rime-dist | |
zip -r my-rime-dist.zip my-rime-dist | |
gh release upload latest my-rime-dist.zip --clobber |