-
Notifications
You must be signed in to change notification settings - Fork 45
152 lines (142 loc) · 4.67 KB
/
Copy pathci.yml
File metadata and controls
152 lines (142 loc) · 4.67 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo check
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate coverage
run: cargo llvm-cov --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 }}
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy -- -D warnings
- run: cargo clippy --tests -- -D warnings
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 example.php
- run: php -d zend.assertions=1 example.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
- name: Ensure gh-pages branch exists
run: |
if ! git ls-remote --exit-code --heads origin gh-pages > /dev/null 2>&1; then
# Create an orphan gh-pages branch without leaving the current checkout.
# Build an empty tree and commit it, then push as the new branch.
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 output.txt
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: PHPantom Benchmarks
tool: cargo
output-file-path: output.txt
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
- 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 output.txt
- name: Compare against baseline
if: steps.check-gh-pages.outputs.exists == 'true'
uses: benchmark-action/github-action-benchmark@v1
with:
name: PHPantom Benchmarks
tool: cargo
output-file-path: output.txt
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"