Skip to content

feat: cleaup

feat: cleaup #20

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
zig-version: [0.15.1]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: ${{ matrix.zig-version }}
- name: Run tests
run: zig build test
benchmark:
name: Benchmark
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
pull-requests: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.15.1
- name: Run benchmark
run: |
echo "Running benchmarks..."
zig build bench -Doptimize=ReleaseFast > benchmark_results.txt 2>&1 || true
echo "Benchmark completed"
continue-on-error: true
- name: Read benchmark results
id: benchmark
run: |
if [ -f benchmark_results.txt ]; then
echo "results<<EOF" >> $GITHUB_OUTPUT
cat benchmark_results.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "results=No benchmark results found" >> $GITHUB_OUTPUT
fi
- name: Comment PR with benchmark results
uses: actions/github-script@v7
with:
script: |
const results = `${{ steps.benchmark.outputs.results }}`;
const comment = `## 🚀 Benchmark Results
<details>
<summary>Click to view benchmark results</summary>
\`\`\`
${results}
\`\`\`
</details>
> Benchmarks run on: \`ubuntu-latest\` with \`ReleaseFast\` optimization
>
> To run benchmarks locally: \`zig build bench -Doptimize=ReleaseFast\`
`;
// Check if we already commented on this PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('🚀 Benchmark Results')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: comment
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}