|
| 1 | +name: model_signing benchmarks |
| 2 | +on: |
| 3 | + issue_comment: |
| 4 | + types: [created] |
| 5 | + |
| 6 | +permissions: {} |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish-benchmark-container: |
| 10 | + if: ${{ (github.event.issue.pull_request) && (startsWith(github.event.comment.body, '/bench')) }} |
| 11 | + runs-on: [ubuntu-latest] |
| 12 | + permissions: |
| 13 | + packages: write |
| 14 | + outputs: |
| 15 | + head: ${{ steps.config.outputs.head }} |
| 16 | + steps: |
| 17 | + - name: Validate and configure benchmark |
| 18 | + id: config |
| 19 | + env: |
| 20 | + COMMENT_BODY: ${{ github.event.comment.body }} |
| 21 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 22 | + with: |
| 23 | + script: | |
| 24 | + const allowedAssociations = ["COLLABORATOR", "MEMBER", "OWNER"]; |
| 25 | + authorAssociation = '${{ github.event.comment.author_association }}' |
| 26 | + if (!allowedAssociations.includes(authorAssociation)) { |
| 27 | + core.setFailed("You don't have access to run the benchmarks"); |
| 28 | + return |
| 29 | + } |
| 30 | +
|
| 31 | + const response = await github.rest.pulls.get({ |
| 32 | + owner: context.repo.owner, |
| 33 | + repo: context.repo.repo, |
| 34 | + pull_number: context.issue.number, |
| 35 | + }) |
| 36 | +
|
| 37 | + // avoid race condition between comment and fetching PR head sha |
| 38 | + const commentTime = new Date('${{ github.event.comment.created_at }}'); |
| 39 | + const prTime = new Date(response.data.head.repo.pushed_at) |
| 40 | + if (prTime >= commentTime) { |
| 41 | + core.setFailed("The PR may have been updated since the benchmark request, " + |
| 42 | + "please review any changes and relaunch if safe."); |
| 43 | + return |
| 44 | + } |
| 45 | +
|
| 46 | + core.setOutput('head', response.data.head.sha) |
| 47 | +
|
| 48 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 49 | + with: |
| 50 | + ref: ${{ steps.config.outputs.head }} |
| 51 | + |
| 52 | + - name: Build Image |
| 53 | + id: build_image |
| 54 | + uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2.13 |
| 55 | + with: |
| 56 | + containerfiles: | |
| 57 | + ./benchmarks/Containerfile |
| 58 | + image: ghcr.io/sigstore/model-transparency-benchmarks |
| 59 | + tags: "latest ${{ steps.config.outputs.head }}" |
| 60 | + archs: amd64 |
| 61 | + oci: false |
| 62 | + |
| 63 | + - name: Login to GitHub Container Registry |
| 64 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 |
| 65 | + id: registry_login |
| 66 | + with: |
| 67 | + registry: ghcr.io |
| 68 | + username: ${{ github.actor }} |
| 69 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + |
| 71 | + - name: Push To GHCR |
| 72 | + uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2.8 |
| 73 | + id: push |
| 74 | + with: |
| 75 | + image: ${{ steps.build_image.outputs.image }} |
| 76 | + tags: ${{ steps.build_image.outputs.tags }} |
| 77 | + registry: ghcr.io |
| 78 | + submit-cloud-batch: |
| 79 | + needs: publish-benchmark-container |
| 80 | + runs-on: ubuntu-latest |
| 81 | + permissions: |
| 82 | + id-token: 'write' |
| 83 | + env: |
| 84 | + MODEL: deepseek-ai/DeepSeek-R1-Distill-Qwen-14B |
| 85 | + TAG: ${{needs.publish-benchmark-container.outputs.head}} |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 88 | + with: |
| 89 | + ref: ${{needs.publish-benchmark-container.outputs.head}} |
| 90 | + - uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10 |
| 91 | + with: |
| 92 | + workload_identity_provider: projects/306323169285/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider |
| 93 | + service_account: 'model-transparency-gha@sigstore-infra-playground.iam.gserviceaccount.com' |
| 94 | + - run: | |
| 95 | + export OUTPUT_FILE=$(date --utc +%Y%m%d%H%M%S)_$TAG.json |
| 96 | + gcloud batch jobs submit \ |
| 97 | + --job-prefix=bench \ |
| 98 | + --project sigstore-infra-playground \ |
| 99 | + --location us-central1 \ |
| 100 | + --config - <<EOF |
| 101 | + $(envsubst '$TAG','$MODEL','$OUTPUT_FILE' < benchmarks/cloud_batch.json) |
| 102 | + EOF |
0 commit comments