-
Notifications
You must be signed in to change notification settings - Fork 14
114 lines (104 loc) · 3.59 KB
/
ci.yaml
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
name: CI
on:
push:
branches:
- master
# Run on any PR
pull_request:
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo fmt --all -- --check
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo test
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy -- -D warnings
fuzz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo fuzz
uses: taiki-e/install-action@v2
with:
tool: cargo-fuzz
- name: Smoke-test fuzz targets
run: |
cargo fuzz build --sanitizer none
for target in $(cargo fuzz list) ; do
cargo fuzz run --sanitizer none $target -- -max_total_time=10
done
binary-size:
runs-on: ubuntu-latest
permissions:
actions: read
pull-requests: write
steps:
- uses: dtolnay/rust-toolchain@nightly
- uses: actions/cache@v3
id: cache-cargo
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./example/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: rustup target add thumbv7em-none-eabihf
if: steps.cache-cargo.outputs.cache-hit != 'true'
- run: rustup component add rust-src llvm-tools
if: steps.cache-cargo.outputs.cache-hit != 'true'
- run: cargo install cargo-binutils
if: steps.cache-cargo.outputs.cache-hit != 'true'
- name: Check out the repo with the full git history
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Build new binary
working-directory: ./example
run: |
echo 'RESULT<<EOF' >> $GITHUB_OUTPUT
cargo size --release | sed 's/\\n/\n/g; s/\\t/ /; s/\\\(.\)/\1/g' >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
id: new-size
- name: Save binary
run: |
mv ./example/target/thumbv7em-none-eabihf/release/example ./example/target/thumbv7em-none-eabihf/release/original.elf
- name: If it's a PR checkout the base commit
if: ${{ github.event.pull_request }}
run: git checkout ${{ github.event.pull_request.base.sha }}
- name: Rebuild with the base commit
if: ${{ github.event.pull_request }}
working-directory: ./example
run: cargo build --release
- name: Run Bloaty to compare both output files
if: ${{ github.event.pull_request }}
id: bloaty-comparison
uses: carlosperate/bloaty-action@v1
with:
bloaty-args: ./example/target/thumbv7em-none-eabihf/release/original.elf -- ./example/target/thumbv7em-none-eabihf/release/example
output-to-summary: true
- name: Add a PR comment with the bloaty diff
if: ${{ github.event.pull_request }}
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## PR build size\n ```${{ join(steps.new-size.outputs.*, '\n') }}```\n ### Diff\n```\n${{ steps.bloaty-comparison.outputs.bloaty-output-encoded }}```\n'
})