forked from trustwallet/wallet-core
-
Notifications
You must be signed in to change notification settings - Fork 1
175 lines (152 loc) · 4.9 KB
/
linux-ci-rust.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Linux CI Rust
on:
push:
branches: [ dev, master ]
pull_request:
branches: [ dev, master ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Check formatting, clippy warnings, run tests and check code coverage.
build-and-test:
permissions:
contents: read
checks: write
runs-on: ubuntu-latest
if: false
steps:
- uses: actions/checkout@v3
- name: Install system dependencies
run: |
tools/install-sys-dependencies-linux
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
key: "build-and-test"
workspaces: |
rust
- name: Install Rust dependencies
run: |
tools/install-rust-dependencies dev
- name: Check code formatting
run: |
cargo fmt --check
working-directory: rust
- name: Check Clippy warnings
run: |
cargo clippy -- -D warnings
working-directory: rust
- name: Run tests
run: |
cargo llvm-cov nextest --profile ci --no-fail-fast --lcov --output-path coverage.info
working-directory: rust
- name: Rust Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
continue-on-error: true
with:
name: Rust Tests
path: |
rust/target/nextest/ci/junit.xml
reporter: java-junit
- name: Gather and check Rust code coverage
run: |
tools/check-coverage rust/coverage.stats rust/coverage.info
# Run Rust tests in WASM.
test-wasm:
runs-on: ubuntu-latest
if: false
steps:
- uses: actions/checkout@v3
- name: Install system dependencies
run: |
tools/install-sys-dependencies-linux
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
key: "test-wasm"
workspaces: |
rust
- name: Install Rust dependencies
run: |
tools/install-rust-dependencies
- name: Install emsdk
run: tools/install-wasm-dependencies
- name: Run tests in WASM
run: tools/rust-test wasm
upload-binary-sizes:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
# TODO remove this step
- name: Install toolchain
run: |
rustup target add armv7-linux-androideabi
- name: Build binaries
run: |
cargo build --target armv7-linux-androideabi --release
working-directory: rust-test
- name: Generate release report
run: |
./tools/release-size measure-rust > release-report.json
- name: Upload release report
uses: actions/upload-artifact@v2
with:
name: release_report
path: release-report.json
check-binary-sizes:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
# TODO remove this step
- name: Install toolchain
run: |
rustup target add armv7-linux-androideabi
- name: Build binaries
run: |
cargo build --target armv7-linux-androideabi --release
working-directory: rust-test
- name: Generate release report
run: |
./tools/release-size measure-rust > release-report.json
- name: Download previous release report
id: download_prev_report
uses: dawidd6/action-download-artifact@v3
with:
commit: ${{github.event.pull_request.base.sha}}
path: previous
if_no_artifact_found: warn
# Same artifact name as at the "Upload release report" step.
name: release_report
- name: Craft Comment Body
if: steps.download_prev_report.outputs.found_artifact == 'true'
id: craft_body
run: |
before_report=./previous/release-report.json
after_report=./release-report.json
markdown_diff=$(./tools/release-size compare $before_report $after_report)
echo "markdown_body=$markdown_diff" >> $GITHUB_OUTPUT
- name: Create or Update Comment
uses: edumserrano/find-create-or-update-comment@v2
if: steps.download_prev_report.outputs.found_artifact == 'true'
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "Binary size comparison"
comment-author: 'github-actions[bot]'
edit-mode: replace
body: |
## Binary size comparison
${{ steps.craft_body.outputs.markdown_body }}