|
| 1 | +name: Benchmarks |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 18 | +concurrency: |
| 19 | + group: "benchmarks" |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +jobs: |
| 23 | + build-and-benchmark: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v5 |
| 27 | + - name: Setup Pages |
| 28 | + uses: actions/configure-pages@v3 |
| 29 | + - name: Setup necessary dotnet SDKs |
| 30 | + uses: actions/setup-dotnet@v4 |
| 31 | + with: |
| 32 | + global-json-file: global.json |
| 33 | + dotnet-version: | |
| 34 | + 8.x |
| 35 | + 9.x |
| 36 | + - name: Run benchmarks |
| 37 | + run: | |
| 38 | + chmod +x ./build.sh |
| 39 | + ./build.sh Benchmarks |
| 40 | + env: |
| 41 | + CI: true |
| 42 | + CONFIGURATION: Release |
| 43 | + - name: Store benchmark result |
| 44 | + uses: benchmark-action/github-action-benchmark@v1 |
| 45 | + with: |
| 46 | + name: IcedTasks Benchmark |
| 47 | + tool: 'benchmarkdotnet' |
| 48 | + output-file-path: 'BenchmarkDotNet.Artifacts/results/*.json' |
| 49 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + auto-push: false # Changed from true to false |
| 51 | + # Show alert with commit comment on detecting possible performance regression |
| 52 | + alert-threshold: '200%' |
| 53 | + comment-on-alert: true |
| 54 | + fail-on-alert: false |
| 55 | + alert-comment-cc-users: '@TheAngryByrd' |
| 56 | + |
| 57 | + - name: Download latest GitHub Pages artifact |
| 58 | + run: | |
| 59 | + # Get the latest successful run ID from the docs workflow |
| 60 | + RUN_ID=$(gh run list --workflow="Deploy Docs" --status=success --limit=1 --json databaseId --jq '.[0].databaseId') |
| 61 | + |
| 62 | + if [ ! -z "$RUN_ID" ] && [ "$RUN_ID" != "null" ]; then |
| 63 | + echo "Found docs workflow run: $RUN_ID" |
| 64 | + # Download the github-pages artifact from that run |
| 65 | + gh run download $RUN_ID --name github-pages --dir existing-pages |
| 66 | + echo "artifact_downloaded=true" >> $GITHUB_ENV |
| 67 | + else |
| 68 | + echo "No successful docs workflow run found" |
| 69 | + echo "artifact_downloaded=false" >> $GITHUB_ENV |
| 70 | + fi |
| 71 | + env: |
| 72 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + continue-on-error: true |
| 74 | + |
| 75 | + - name: Extract existing pages and add benchmarks |
| 76 | + run: | |
| 77 | + # Create a combined directory for deployment |
| 78 | + mkdir -p combined-site |
| 79 | + |
| 80 | + # If we successfully downloaded existing pages, extract them |
| 81 | + if [ "$artifact_downloaded" = "true" ] && [ -d "existing-pages" ]; then |
| 82 | + echo "Extracting existing pages artifact..." |
| 83 | + # GitHub Pages artifacts are typically tar.gz files |
| 84 | + if [ -f "existing-pages/artifact.tar.gz" ]; then |
| 85 | + cd existing-pages |
| 86 | + tar -xzf artifact.tar.gz |
| 87 | + cd .. |
| 88 | + # Copy existing pages to combined site (skip the tar file itself) |
| 89 | + find existing-pages -type f ! -name "*.tar.gz" -exec cp {} combined-site/ \; |
| 90 | + find existing-pages -type d ! -name "existing-pages" -exec mkdir -p combined-site/{} \; 2>/dev/null || true |
| 91 | + elif [ -f "existing-pages/artifact.tar" ]; then |
| 92 | + cd existing-pages |
| 93 | + tar -xf artifact.tar |
| 94 | + cd .. |
| 95 | + find existing-pages -type f ! -name "*.tar" -exec cp {} combined-site/ \; |
| 96 | + else |
| 97 | + # Just copy all files if no tar found |
| 98 | + cp -r existing-pages/* combined-site/ 2>/dev/null || true |
| 99 | + fi |
| 100 | + echo "Existing pages extracted successfully" |
| 101 | + else |
| 102 | + echo "No existing pages found, creating basic site structure..." |
| 103 | + # Create a basic index if no existing pages |
| 104 | + echo '<html><head><title>IcedTasks</title></head><body><h1>IcedTasks</h1><p><a href="benchmarks/">View Benchmarks</a></p></body></html>' > combined-site/index.html |
| 105 | + fi |
| 106 | + |
| 107 | + # Copy benchmark results to benchmarks subdirectory |
| 108 | + mkdir -p combined-site/benchmarks |
| 109 | + if [ -d "benchmark-data-repository/dpcs/benchmark-data" ]; then |
| 110 | + cp -r benchmark-data-repository/dpcs/benchmark-data/* combined-site/benchmarks/ |
| 111 | + echo "Benchmark data copied to combined-site/benchmarks/" |
| 112 | + fi |
| 113 | + |
| 114 | + # List what we have in combined-site for debugging |
| 115 | + echo "Contents of combined-site:" |
| 116 | + ls -la combined-site/ || true |
| 117 | + echo "Contents of combined-site/benchmarks:" |
| 118 | + ls -la combined-site/benchmarks/ || true |
| 119 | + |
| 120 | + - name: Upload combined pages artifact |
| 121 | + uses: actions/upload-pages-artifact@v3 |
| 122 | + with: |
| 123 | + path: combined-site |
| 124 | + |
| 125 | + # Deployment job |
| 126 | + deploy: |
| 127 | + # Only deploy on pushes to master branch, not on pull requests |
| 128 | + if: github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 129 | + environment: |
| 130 | + name: github-pages |
| 131 | + url: ${{ steps.deployment.outputs.page_url }} |
| 132 | + runs-on: ubuntu-latest |
| 133 | + needs: build-and-benchmark |
| 134 | + steps: |
| 135 | + - name: Deploy to GitHub Pages |
| 136 | + id: deployment |
| 137 | + uses: actions/deploy-pages@v4 |
0 commit comments