Bump crossfire from 2.1.10 to 3.1.16 #259
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Benchmark | |
| on: | |
| push: | |
| branches: [dev, stable] | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| pull-requests: write | |
| jobs: | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Build release binary | |
| run: cargo build --release | |
| - name: Build MassDNS | |
| run: | | |
| git clone --depth 1 https://github.com/blechschmidt/massdns.git /tmp/massdns | |
| cd /tmp/massdns && make | |
| sudo cp /tmp/massdns/bin/massdns /usr/local/bin/massdns | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.x' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Install Python dependencies | |
| run: uv sync | |
| - name: Build Python extension | |
| run: uv run maturin develop --release | |
| - name: Install dnsmasq | |
| run: sudo apt-get update && sudo apt-get install -y dnsmasq | |
| - name: Start test DNS server | |
| run: sudo ./scripts/start-test-dns.sh | |
| - name: Run benchmark | |
| run: uv run python scripts/benchmark.py > benchmark_report.md | |
| - name: Display benchmark results | |
| run: cat benchmark_report.md | |
| - name: Upload benchmark results | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: benchmark-results | |
| path: benchmark_report.md | |
| retention-days: 30 | |
| - name: Stop test DNS server | |
| if: always() | |
| run: sudo ./scripts/stop-test-dns.sh || true | |
| - name: Comment benchmark results on PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| try { | |
| const report = fs.readFileSync('benchmark_report.md', 'utf8'); | |
| // Find existing benchmark comment | |
| const comments = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| per_page: 100, | |
| }); | |
| console.log(`Found ${comments.data.length} comments on this PR`); | |
| const existingComments = comments.data.filter(comment => | |
| comment.body.includes('DNS Resolver Benchmark') && | |
| comment.user.login === 'github-actions[bot]' | |
| ); | |
| console.log(`Found ${existingComments.length} existing benchmark comments`); | |
| if (existingComments.length > 0) { | |
| // Update most recent comment | |
| const sortedComments = existingComments.sort((a, b) => | |
| new Date(b.created_at) - new Date(a.created_at) | |
| ); | |
| const mostRecentComment = sortedComments[0]; | |
| console.log(`Updating benchmark comment: ${mostRecentComment.id}`); | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: mostRecentComment.id, | |
| body: report | |
| }); | |
| // Delete older duplicates | |
| for (let i = 1; i < sortedComments.length; i++) { | |
| try { | |
| await github.rest.issues.deleteComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: sortedComments[i].id | |
| }); | |
| console.log(`Deleted duplicate comment: ${sortedComments[i].id}`); | |
| } catch (error) { | |
| console.error(`Failed to delete comment: ${error.message}`); | |
| } | |
| } | |
| } else { | |
| // Create new comment | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: report | |
| }); | |
| console.log('Created new benchmark comment'); | |
| } | |
| } catch (error) { | |
| console.error('Failed to post benchmark results:', error); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: [ | |
| '## DNS Resolver Benchmark', | |
| '', | |
| '> ⚠️ **Failed to generate benchmark results**', | |
| '> ', | |
| `> Please check the [workflow logs](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) for details.` | |
| ].join('\n') | |
| }); | |
| } | |