From cd515311fd0e83c502e1bd2715f22a3305b59015 Mon Sep 17 00:00:00 2001 From: arty Date: Thu, 9 May 2024 13:08:16 -0700 Subject: [PATCH] Add basic ci --- .github/workflows/build-test.yml | 131 +++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 .github/workflows/build-test.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..b0eb7199 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,131 @@ +# Thanks: clvm_rs' github actions. +name: Build + +on: + push: + branches: + - base + - dev + release: + types: [published] + pull_request: + branches: + - '**' + +permissions: + id-token: write + contents: read + +jobs: + build_and_test: + name: Build code on ${{ matrix.os }} py-${{ matrix.python }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + python: [3.8, 3.9, '3.10', 3.11] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v4 + name: Install Python ${{ matrix.python }} + with: + python-version: ${{ matrix.python }} + + - name: Update pip + run: | + python -m pip install --upgrade pip + + - name: Set up rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Install chia-blockchain for the blockchain tests + run: | + python -m pip install chia-blockchain + + fmt: + runs-on: ubuntu-20.04 + name: cargo fmt + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: rustfmt, clippy + - name: fmt + run: cargo fmt -- --files-with-diff --check + + clippy: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: clippy + override: true + - name: clippy + run: cargo clippy --all -- -D warnings + - uses: giraffate/clippy-action@v1 + with: + reporter: 'github-pr-review' + github_token: ${{ secrets.GITHUB_TOKEN }} + + unit_tests: + runs-on: ubuntu-20.04 + name: Unit tests + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt, clippy + - name: cargo test + run: cargo test --features=sim-tests + + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Run for coverage + run: | + sudo apt-get update + sudo apt-get install lcov -y + rustup component add llvm-tools-preview + cargo install grcov + export RUSTFLAGS="-Cinstrument-coverage" + export LLVM_PROFILE_FILE=$(pwd)/target/clvm_tools_rs-%p-%m.profraw + export CARGO_TARGET_DIR=$(pwd)/target + cargo test --release --workspace + python -m venv venv + source venv/bin/activate + git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch + pip install ./clvm_tools + pip install maturin pytest + maturin develop --release + (cd resources/tests/cmdline/tests && pytest) + grcov . --binary-path target -s . --branch --ignore-not-existing --ignore='*/.cargo/*' --ignore='*/tests/*' -o rust_cov.info + python -c 'with open("rust_cov.info") as f: lines = [l for l in f if not (l.startswith("DA:") and int(l.split(",")[1].strip()) >= 2**63)]; open("lcov.info", "w").writelines(lines)' + - name: Upload to Coveralls + uses: coverallsapp/github-action@v2 + if: always() + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + with: + path-to-lcov: './lcov.info'