-
Notifications
You must be signed in to change notification settings - Fork 6
182 lines (171 loc) · 5.95 KB
/
action.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
176
177
178
179
180
181
182
name: Test all targets
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: write
jobs:
quick-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Check Type
run: cargo fmt -- --check
- name: Check Clippy
run: cargo clippy -- -Dwarnings
- name: Run internal tests
run: cargo test --verbose -- --nocapture
- name: Build
run: cargo build
build:
needs: quick-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Build docs
run: cargo doc
- name: Move documentation
run: mkdir -p pages/doc && mv target/doc/* pages/doc/
- name: Get previous benchmark data
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Fetching gh-pages branch"
git fetch origin gh-pages
echo "Checking out gh-pages branch"
git checkout gh-pages
echo "Copying data file from gh-pages to cache"
mkdir -p pages/dev && cp -r dev/* pages/dev/ || { echo "Failed to copy dev folder" ; exit 1; }
echo "Checking out current previous branch"
git checkout -
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/master' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./pages
cross-compile-bench:
needs: build
if: ${{ github.repository_owner == 'bluerobotics' }}
runs-on: ubuntu-latest
strategy:
matrix:
TARGET: [armv7-unknown-linux-gnueabihf]
steps:
- uses: actions/checkout@master
- name: Cross-compile benchmark
uses: RaulTrombin/actions-rust-cross@add_bench
with:
command: bench
target: ${{ matrix.TARGET }}
args: "--no-run"
- name: List benchmark files
run: |
echo "Available files in target directory:"
find target/${{ matrix.TARGET }}/release -type f -name "bench-*" -not -name "*.d"
- name: Upload benchmark binary
uses: actions/upload-artifact@v3
with:
name: benchmark-binary
# Exclude .d files and only get the actual binary
path: target/${{ matrix.TARGET }}/release/deps/bench-[0-9a-f]*
retention-days: 1
run-bench:
needs: cross-compile-bench
if: ${{ github.repository_owner == 'bluerobotics' }}
runs-on: raspbian-armv7-kernel-5.10.33
steps:
- uses: actions/checkout@master
- name: Download benchmark binary
uses: actions/download-artifact@v3
with:
name: benchmark-binary
path: ./bench-binary
- name: Get previous benchmark data
run: |
echo "Fetching gh-pages branch"
git fetch origin gh-pages
echo "Checking out gh-pages branch"
git checkout gh-pages
if [ ! -d "cache" ]; then
echo "Cache folder does not exist, creating it"
mkdir cache
fi
echo "Copying data file from gh-pages to cache"
cp dev/cache/benchmark-data.json cache/benchmark-data.json || { echo "Failed to copy data file" ; exit 1; }
echo "Checking out current previous branch"
git checkout -
- name: Debug downloaded files
run: |
echo "Files in bench-binary directory:"
ls -la ./bench-binary/
- name: Make benchmark executable
run: |
chmod +x ./bench-binary/*
find ./bench-binary -type f -executable -name "bench-*" -not -name "*.d"
- name: Run benchmark
run: |
BENCH_BINARY=$(find ./bench-binary -type f -executable -name "bench-*" -not -name "*.d" | head -n 1)
echo "Found benchmark binary: $BENCH_BINARY"
if [ -z "$BENCH_BINARY" ]; then
echo "No benchmark binary found!"
exit 1
fi
$BENCH_BINARY --jobs 1 --bench bench -- --output-format bencher | tee output.txt || { echo "Benchmark failed"; exit 1; }
- name: Compare results & store cached results
uses: benchmark-action/[email protected]
with:
tool: 'cargo'
output-file-path: output.txt
summary-always: true
alert-threshold: "130%"
fail-on-alert: true
external-data-json-path: ./cache/benchmark-data.json
skip-fetch-gh-pages: "true"
- name: Update data file
if: ${{ github.ref == 'refs/heads/master' }}
run: |
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
git fetch origin gh-pages
git checkout gh-pages
if [ ! -d "dev/cache" ]; then
echo "Cache folder does not exist, creating it"
mkdir -p dev/cache
fi
cp cache/benchmark-data.json dev/cache/benchmark-data.json
tree cache
git add dev/cache/benchmark-data.json
git commit -m "Update benchmark-data file"
git push origin gh-pages
deploy:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout to repository
uses: actions/checkout@v2
- name: Setup Rust toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
override: true
- name: Install cargo-bump
run: cargo install cargo-bump --force
- name: Modify version with tag
run: cargo bump ${{ github.ref_name }}
- name: Automatic commit for crate version upgrade
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: master
commit_message: "Cargo: Update the crate version to ${{ github.ref_name }}"
- name: Publish to crates.io
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}