[#58314]: Apply lints #23
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 library | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
workflow_call: | |
jobs: | |
build-library: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libclang-dev clang cmake wget ninja-build | |
wget -q https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-linux.tar.gz | |
wget -q https://raw.githubusercontent.com/antmicro/wasi_ext_lib/main/canonicalize.patch | |
tar xvf wasi-sdk-16.0-linux.tar.gz | |
echo "WASI_SDK_PATH=$(pwd)/wasi-sdk-16.0" >> "$GITHUB_ENV" | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y > /dev/null 2> /dev/null | |
source $HOME/.cargo/env | |
rustup target add wasm32-wasi | |
- name: Run Rust linter | |
run: | | |
source $HOME/.cargo/env | |
CLIPPY_OUT=${TMPDIR:-/tmp}/cargo-clippy-log.out | |
cargo clippy --quiet 2> ${CLIPPY_OUT} | |
cargo clippy --target wasm32-wasi --quiet 2>> ${CLIPPY_OUT} | |
cat ${CLIPPY_OUT} | |
if [ -s ${CLIPPY_OUT} ]; then | |
echo "There were cargo-clippy warnings. Please fix it." | |
exit 1 | |
fi | |
- name: Run Rust formater | |
run: | | |
source $HOME/.cargo/env | |
cargo fmt | |
if [ -n "$(git status --porcelain --untracked-files='no')" ]; then | |
git status --porcelain --untracked-files="no" | |
echo "The rust sources are not formatted properly. Please fix it." | |
exit 1 | |
fi | |
- name: Setup Rust toolchain | |
run: | | |
git clone https://github.com/rust-lang/rust.git -b beta | |
cd rust | |
git apply ../canonicalize.patch | |
mkdir tmp | |
cd tmp | |
sudo ../src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh | |
cd .. | |
./configure --target=wasm32-wasi --disable-docs --set target.wasm32-wasi.wasi-root=/wasm32-wasi --enable-lld --tools=cargo | |
./x.py build --target x86_64-unknown-linux-gnu,wasm32-wasi --stage 2 | |
source $HOME/.cargo/env | |
rustup toolchain link stage2 "$(pwd)/build/x86_64-unknown-linux-gnu/stage2" | |
cargo --version | |
- name: Build native | |
run: | | |
source $HOME/.cargo/env | |
export CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot" | |
cargo +stage2 build --release | |
- name: Build wasm32-wasi | |
run: | | |
source $HOME/.cargo/env | |
export CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot" | |
cargo +stage2 build --target wasm32-wasi --release | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wash | |
path: ./target/wasm32-wasi/release/wash.wasm |