-
-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (133 loc) · 4.46 KB
/
benchmark.yml
File metadata and controls
142 lines (133 loc) · 4.46 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
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:
build-bin:
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
with:
ref: ${{ matrix.commit }}
persist-credentials: false
- name: Cache base ref build
uses: actions/cache@v5
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'
- run: cargo build --bin cpp-linter --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
# 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
with:
persist-credentials: false
- name: Checkout libgit2
uses: actions/checkout@v6
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@1800853f2578f8c34492ec76154caef8e163fbca # v1.17.7
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@920172d92eb04671776f3ba69d605d3b09351c30 # v3.22
- name: Install uv
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1
- 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