Benchmark WebSocket Libraries #292
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 WebSocket Libraries | |
| on: | |
| workflow_dispatch: # Allow manual trigger | |
| schedule: | |
| - cron: '40 2 * * *' | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: write | |
| attestations: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 'stable' | |
| - name: Install dependencies and update libraries | |
| run: | | |
| go mod download | |
| go get -u ./... | |
| go mod tidy | |
| - name: Run Benchmark | |
| run: go run ./benchmark/... | |
| # The benchmark main.go will fetch latest versions and save results to benchmark_history.json | |
| - name: Generate Performance Graph | |
| run: go run ./cmd/generate_graph | |
| # Assumes cmd/generate_graph/main.go reads benchmark_history.json and outputs benchmark_performance.png | |
| - name: Update README Table | |
| run: go run ./cmd/update_readme | |
| # Assumes cmd/update_readme/main.go reads benchmark_history.json and updates README.md | |
| - name: Update results | |
| run: | | |
| mkdir -p results | |
| cp benchmark/benchmark_history.json results/ | |
| cp benchmark_performance.png results/ | |
| cp go.mod results/ | |
| cp go.sum results/ | |
| cp README.md results/ | |
| - name: Upload build artifact | |
| id: upload | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: results/* | |
| name: results.zip | |
| - uses: actions/attest-build-provenance@v2 | |
| with: | |
| subject-name: results.zip | |
| subject-digest: sha256:${{ steps.upload.outputs.artifact-digest }} | |
| - name: Commit changes | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "chore: Update benchmark results, graph, and README" | |
| file_pattern: "README.md benchmark/benchmark_history.json benchmark_performance.png go.mod go.sum" # Updated graph filename | |
| commit_user_name: "github-actions[bot]" | |
| commit_user_email: "github-actions[bot]@users.noreply.github.com" | |
| commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>" |