-
Notifications
You must be signed in to change notification settings - Fork 36
243 lines (234 loc) · 8.47 KB
/
ci.yml
File metadata and controls
243 lines (234 loc) · 8.47 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
shared-key: build
- name: Install mold linker
run: sudo apt-get install -y mold
- name: Configure mold
run: |
mkdir -p .cargo
echo '[target.x86_64-unknown-linux-gnu]' >> .cargo/config.toml
echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold"]' >> .cargo/config.toml
- run: cargo fmt --check
- run: cargo clippy -- -D warnings
- run: cargo clippy --tests -- -D warnings
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: coverage
- name: Install mold linker
run: sudo apt-get install -y mold
- name: Configure mold
run: |
mkdir -p .cargo
echo '[target.x86_64-unknown-linux-gnu]' >> .cargo/config.toml
echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold"]' >> .cargo/config.toml
- name: Install cargo-llvm-cov and cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov,cargo-nextest
- name: Run tests with coverage
run: cargo llvm-cov nextest --lcov --output-path lcov.info
- name: Upload to Codecov
uses: codecov/codecov-action@v5
with:
files: lcov.info
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
php-lint:
name: PHP Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
ini-values: zend.assertions=1
- run: php -l examples/demo.php
- run: php -d zend.assertions=1 examples/demo.php
- run: php -l examples/laravel/app/Demo.php
benchmark:
name: Benchmark
runs-on: ubuntu-latest
permissions:
contents: write
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: build
- name: Ensure gh-pages branch exists
run: |
if ! git ls-remote --exit-code --heads origin gh-pages > /dev/null 2>&1; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
empty_tree="$(git hash-object -t tree /dev/null)"
commit="$(git commit-tree "$empty_tree" -m 'Initial gh-pages branch')"
git push origin "$commit:refs/heads/gh-pages"
fi
- name: Run benchmarks
run: cargo bench --bench completion -- --output-format bencher | tee raw_output.txt
- name: Convert to milliseconds
run: python3 benches/format_bench_output.py < raw_output.txt > output.json
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: PHPantom Benchmarks
tool: customSmallerIsBetter
output-file-path: output.json
gh-pages-branch: gh-pages
benchmark-data-dir-path: dev/bench
auto-push: true
github-token: ${{ secrets.GITHUB_TOKEN }}
benchmark-pr:
name: Benchmark (PR comparison)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: build
- name: Check gh-pages branch exists
id: check-gh-pages
run: |
if git ls-remote --exit-code --heads origin gh-pages > /dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "⚠️ gh-pages branch does not exist yet — skipping PR benchmark comparison"
fi
- name: Run benchmarks
if: steps.check-gh-pages.outputs.exists == 'true'
run: cargo bench --bench completion -- --output-format bencher | tee raw_output.txt
- name: Convert to milliseconds
if: steps.check-gh-pages.outputs.exists == 'true'
run: python3 benches/format_bench_output.py < raw_output.txt > output.json
- name: Compare against baseline
if: steps.check-gh-pages.outputs.exists == 'true'
uses: benchmark-action/github-action-benchmark@v1
with:
name: PHPantom Benchmarks
tool: customSmallerIsBetter
output-file-path: output.json
gh-pages-branch: gh-pages
benchmark-data-dir-path: dev/bench
auto-push: false
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-on-alert: true
alert-threshold: "130%"
fail-on-alert: true
alert-comment-cc-users: "@AJenbo"
memory-benchmark:
name: Memory Benchmark
runs-on: ubuntu-latest
needs: benchmark
permissions:
contents: write
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: build
- uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
tools: composer
- name: Install mold linker
run: sudo apt-get install -y mold
- name: Configure mold
run: |
mkdir -p .cargo
echo '[target.x86_64-unknown-linux-gnu]' >> .cargo/config.toml
echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold"]' >> .cargo/config.toml
- name: Build release binary
run: cargo build --release
- name: Measure memory usage
run: python3 benches/memory_usage.py --binary target/release/phpantom_lsp | tee memory_output.json
- name: Store memory benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: PHPantom Memory Usage
tool: customSmallerIsBetter
output-file-path: memory_output.json
gh-pages-branch: gh-pages
benchmark-data-dir-path: dev/memory
auto-push: true
github-token: ${{ secrets.GITHUB_TOKEN }}
memory-benchmark-pr:
name: Memory Benchmark (PR comparison)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: build
- uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
tools: composer
- name: Install mold linker
run: sudo apt-get install -y mold
- name: Configure mold
run: |
mkdir -p .cargo
echo '[target.x86_64-unknown-linux-gnu]' >> .cargo/config.toml
echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold"]' >> .cargo/config.toml
- name: Build release binary
run: cargo build --release
- name: Check gh-pages branch exists
id: check-gh-pages
run: |
if git ls-remote --exit-code --heads origin gh-pages > /dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "⚠️ gh-pages branch does not exist yet — skipping memory benchmark comparison"
fi
- name: Measure memory usage
if: steps.check-gh-pages.outputs.exists == 'true'
run: python3 benches/memory_usage.py --binary target/release/phpantom_lsp | tee memory_output.json
- name: Compare against baseline
if: steps.check-gh-pages.outputs.exists == 'true'
uses: benchmark-action/github-action-benchmark@v1
with:
name: PHPantom Memory Usage
tool: customSmallerIsBetter
output-file-path: memory_output.json
gh-pages-branch: gh-pages
benchmark-data-dir-path: dev/memory
auto-push: false
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-on-alert: true
alert-threshold: "130%"
fail-on-alert: true
alert-comment-cc-users: "@AJenbo"