-
-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (157 loc) · 5.3 KB
/
Copy pathbenchmark.yml
File metadata and controls
167 lines (157 loc) · 5.3 KB
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
name: Benchmark
on:
push:
branches: [main]
paths:
- cpp-linter/src/**
- cpp-linter/Cargo.toml
- Cargo.toml
- Cargo.lock
- .github/workflows/benchmark.yml
pull_request:
branches: [main]
paths:
- cpp-linter/src/**
- cpp-linter/Cargo.toml
- Cargo.toml
- Cargo.lock
- .github/workflows/benchmark.yml
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
seed-build-script:
runs-on: ubuntu-latest
name: Pre-seed static binaries' versions
steps:
- env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release download
-R cpp-linter/clang-tools-static-binaries
--pattern versions.json
--output versions.json
- name: Upload versions.json
uses: actions/upload-artifact@v7
with:
name: static-binary-versions
path: versions.json
if-no-files-found: error
build-bin:
needs: [seed-build-script]
name: Build ${{ matrix.name }} binary
runs-on: ubuntu-latest
strategy:
matrix:
include:
- commit: ${{ github.sha }}
name: current
- commit: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
name: previous
env:
BIN: target/release/cpp-linter
steps:
- name: Checkout ${{ matrix.name }}
uses: actions/checkout@v6.0.2
with:
ref: ${{ matrix.commit }}
persist-credentials: false
- name: Cache base ref build
uses: actions/cache@v5.0.5
id: cache
with:
key: bin-cache-${{ hashFiles('cpp-linter/src/**', 'Cargo.toml', 'Cargo.lock', 'cpp-linter/Cargo.toml') }}
path: ${{ env.BIN }}
- name: Validate cached binary
if: steps.cache.outputs.cache-hit == 'true'
id: validate
run: |
chmod +x ${{ env.BIN }}
if ! ${{ env.BIN }} version; then
echo "Cached binary is invalid, rebuilding..."
echo "cache-valid=false" >> "$GITHUB_OUTPUT"
fi
- run: rustup update --no-self-update
if: steps.cache.outputs.cache-hit != 'true' || steps.validate.outputs.cache-valid == 'false'
- name: Restore build script seed
if: steps.cache.outputs.cache-hit != 'true' || steps.validate.outputs.cache-valid == 'false'
uses: actions/download-artifact@v8
with:
name: static-binary-versions
path: clang-tools-manager
- run: cargo build --bin cpp-linter --features bin --release
if: steps.cache.outputs.cache-hit != 'true' || steps.validate.outputs.cache-valid == 'false'
- name: Upload build artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.name }}
path: ${{ env.BIN }}
# build-py-binding:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v6.0.2
# with:
# persist-credentials: false
# - name: Set up Python
# uses: actions/setup-python@v6
# id: setup-python
# with:
# python-version: '3.x'
# - name: Build wheels
# uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
# with:
# target: x86_64
# args: --release --out dist --find-interpreter
# manylinux: auto
# before-script-linux: |
# # NOTE: rust-cross/manylinux docker images are CentOS based
# yum update -y
# yum install -y openssl openssl-devel
# - name: Upload wheels
# uses: actions/upload-artifact@v7
# with:
# name: wheel
# path: dist/cpp_linter-*-cp3*-abi3-*.whl
# if-no-files-found: error
benchmark:
name: Measure Performance Difference
needs: [build-bin] #, build-py-binding]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
with:
persist-credentials: false
- name: Checkout libgit2
uses: actions/checkout@v6.0.2
with:
repository: libgit2/libgit2
ref: v1.8.1
path: benchmark/libgit2
persist-credentials: false
- name: Download built binaries
uses: actions/download-artifact@v8
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@aaa84a43aec4955a42c5ffc65d258961e39f276e # v1.19.1
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Install hyperfine
env:
GITHUB_TOKEN: ${{ github.token }}
run: cargo binstall -y hyperfine
- name: Install nushell
uses: hustcer/setup-nu@92c296ba1ba2ba04cc948ab64ddefe192dc13f0c # v3.23
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Run benchmark script
working-directory: benchmark
shell: nu {0}
run: |-
# let new_py = (
# glob "../wheel/cpp_linter-*-cp3*-abi3-*.whl"
# | first
# | path expand
# )
let prev_bin = "../previous/cpp-linter" | path expand
let curr_bin = "../current/cpp-linter" | path expand
nu benchmark.nu --rust-bin $curr_bin --prev-rust-bin $prev_bin