|
| 1 | +# Thanks: clvm_rs' github actions. |
| 2 | +name: Build |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - base |
| 8 | + - dev |
| 9 | + release: |
| 10 | + types: [published] |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - '**' |
| 14 | + |
| 15 | +permissions: |
| 16 | + id-token: write |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + build_and_test: |
| 21 | + name: Build code on ${{ matrix.os }} py-${{ matrix.python }} |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + os: [macos-latest, ubuntu-latest, windows-latest] |
| 27 | + python: [3.8, 3.9, '3.10', 3.11] |
| 28 | + |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v3 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + |
| 34 | + - uses: actions/setup-python@v4 |
| 35 | + name: Install Python ${{ matrix.python }} |
| 36 | + with: |
| 37 | + python-version: ${{ matrix.python }} |
| 38 | + |
| 39 | + - name: Update pip |
| 40 | + run: | |
| 41 | + python -m pip install --upgrade pip |
| 42 | +
|
| 43 | + - name: Set up rust |
| 44 | + uses: actions-rs/toolchain@v1 |
| 45 | + with: |
| 46 | + toolchain: stable |
| 47 | + |
| 48 | + - name: Install chia-blockchain for the blockchain tests |
| 49 | + run: | |
| 50 | + python -m pip install chia-blockchain |
| 51 | +
|
| 52 | + fmt: |
| 53 | + runs-on: ubuntu-20.04 |
| 54 | + name: cargo fmt |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v3 |
| 57 | + with: |
| 58 | + fetch-depth: 1 |
| 59 | + - name: Install rust |
| 60 | + uses: actions-rs/toolchain@v1 |
| 61 | + with: |
| 62 | + toolchain: stable |
| 63 | + override: true |
| 64 | + components: rustfmt, clippy |
| 65 | + - name: fmt |
| 66 | + run: cargo fmt -- --files-with-diff --check |
| 67 | + |
| 68 | + clippy: |
| 69 | + runs-on: ubuntu-20.04 |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v3 |
| 72 | + - uses: actions-rs/toolchain@v1 |
| 73 | + with: |
| 74 | + toolchain: stable |
| 75 | + components: clippy |
| 76 | + override: true |
| 77 | + - name: clippy |
| 78 | + run: cargo clippy --all -- -D warnings |
| 79 | + - uses: giraffate/clippy-action@v1 |
| 80 | + with: |
| 81 | + reporter: 'github-pr-review' |
| 82 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + |
| 84 | + unit_tests: |
| 85 | + runs-on: ubuntu-20.04 |
| 86 | + name: Unit tests |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v3 |
| 89 | + with: |
| 90 | + fetch-depth: 1 |
| 91 | + - name: Install rust |
| 92 | + uses: actions-rs/toolchain@v1 |
| 93 | + with: |
| 94 | + toolchain: stable |
| 95 | + components: rustfmt, clippy |
| 96 | + - name: cargo test |
| 97 | + run: cargo test --features=sim-tests |
| 98 | + |
| 99 | + coverage: |
| 100 | + runs-on: ubuntu-latest |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@v3 |
| 103 | + - uses: actions-rs/toolchain@v1 |
| 104 | + with: |
| 105 | + toolchain: stable |
| 106 | + - name: Run for coverage |
| 107 | + run: | |
| 108 | + sudo apt-get update |
| 109 | + sudo apt-get install lcov -y |
| 110 | + rustup component add llvm-tools-preview |
| 111 | + cargo install grcov |
| 112 | + export RUSTFLAGS="-Cinstrument-coverage" |
| 113 | + export LLVM_PROFILE_FILE=$(pwd)/target/clvm_tools_rs-%p-%m.profraw |
| 114 | + export CARGO_TARGET_DIR=$(pwd)/target |
| 115 | + cargo test --release --workspace |
| 116 | + python -m venv venv |
| 117 | + source venv/bin/activate |
| 118 | + git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch |
| 119 | + pip install ./clvm_tools |
| 120 | + pip install maturin pytest |
| 121 | + maturin develop --release |
| 122 | + (cd resources/tests/cmdline/tests && pytest) |
| 123 | + grcov . --binary-path target -s . --branch --ignore-not-existing --ignore='*/.cargo/*' --ignore='*/tests/*' -o rust_cov.info |
| 124 | + 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)' |
| 125 | + - name: Upload to Coveralls |
| 126 | + uses: coverallsapp/github-action@v2 |
| 127 | + if: always() |
| 128 | + env: |
| 129 | + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} |
| 130 | + with: |
| 131 | + path-to-lcov: './lcov.info' |
0 commit comments