-
Notifications
You must be signed in to change notification settings - Fork 5
130 lines (119 loc) · 3.59 KB
/
build-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# 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.9, '3.10', 3.11, 3.12]
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
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 --features=sim-tests,simulator -- -D warnings
cargo check --features=sim-tests,simulator --tests
- 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: |
python -m pip install chia-blockchain==2.3.0
# Try tests without sim-tests to ensure we're tracking build failures in that
# configuration. Also it's a lot shorter.
cargo test
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
python -m venv venv
source venv/bin/activate
pip install chia-blockchain
cargo test --release --workspace --features=sim-tests
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'