From 5ca3ac41dddc9f43011d9af398d392960ae7b806 Mon Sep 17 00:00:00 2001 From: Grzegorz Placzek Date: Mon, 30 Sep 2024 13:40:15 +0200 Subject: [PATCH] [#66069] Update github CI --- .github/workflows/build.yml | 84 +++++++++++-------------------------- 1 file changed, 24 insertions(+), 60 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1cbb783..e15d045 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,75 +1,39 @@ name: build library -on: [push, pull_request] +on: + push: + branches: + - '**' + pull_request: + workflow_call: jobs: build-library: runs-on: ubuntu-latest + container: + image: rust:1.81-slim-bookworm 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 - 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 + apt-get update + apt-get install -y libclang-dev clang cmake wget ninja-build nodejs npm + (cd /opt && wget -q "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-linux.tar.gz" && tar xvf wasi-sdk-16.0-linux.tar.gz) + echo "WASI_SDK_PATH=/opt/wasi-sdk-16.0" >> "$GITHUB_ENV" rustup target add wasm32-wasi + rustup component add rustfmt clippy + - name: Checkout sources + uses: actions/checkout@v3 + - name: Build + run: CC=${WASI_SDK_PATH}/bin/clang cargo build --target wasm32-wasi --release --features hterm - name: Run C linter - run: | - cd c_lib - TIDY_OUT=${TMPDIR:-/tmp}/clang-tidy-log.out - ${WASI_SDK_PATH}/bin/clang-tidy *.[ch] -- -I third_party > ${TIDY_OUT} - cat ${TIDY_OUT} - if [ -s ${TIDY_OUT} ]; then - echo "There were clang-tidy warnings. Please fix." - exit 1 - fi + run: cd c_lib && ${WASI_SDK_PATH}/bin/clang-tidy *.[ch] --warnings-as-errors='*' -- -I third_party - name: Run C formater run: | cd c_lib - ${WASI_SDK_PATH}/bin/clang-format --style="{BasedOnStyle: llvm, IndentWidth: 4}" *.[ch] -i - if [ -n "$(git status --porcelain --untracked-files='no')" ]; then - git status --porcelain --untracked-files="no" - echo "There were not well formated C files. Please fix." - exit 1 - fi - - name: Run Rust linter - run: | - source $HOME/.cargo/env - CLIPPY_OUT=${TMPDIR:-/tmp}/cargo-clippy-log.out - cargo clippy --target wasm32-wasi --features hterm --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." - exit 1 - fi + ${WASI_SDK_PATH}/bin/clang-format --style='{BasedOnStyle: llvm, IndentWidth: 4}' *.[ch] --Werror --dry-run + - name: Run rust linter + run: CC=${WASI_SDK_PATH}/bin/clang cargo clippy --target wasm32-wasi -- -Dwarnings + - name: Run rust linter with hterm feature + run: CC=${WASI_SDK_PATH}/bin/clang cargo clippy --target wasm32-wasi --features hterm -- -Dwarnings - 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 "There were not well formated Rust files. Please fix." - 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 - ./configure --target=wasm32-wasi --disable-docs --set target.wasm32-wasi.wasi-root=${WASI_SDK_PATH}/share/wasi-sysroot --enable-lld --tools=cargo - ./x.py build --target wasm32-wasi,x86_64-unknown-linux-gnu --stage 1 - source $HOME/.cargo/env - rustup toolchain link wasi_extended "$(pwd)/build/host/stage1" - cargo --version - - name: Build - run: | - source $HOME/.cargo/env - export CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot" - cargo +wasi_extended build --target wasm32-wasi --release --features hterm - + run: cargo fmt --check