From f25e5a89f00bcecacee4f09901d5cfdc1be341c6 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 22 Jul 2025 20:32:02 +0800 Subject: Add CI to check ir module versioning (#7821) --- .github/workflows/ci.yml | 18 +++++++ .github/workflows/comment-ir-version-check.yml | 73 ++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 .github/workflows/comment-ir-version-check.yml (limited to '.github/workflows') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f831415f..c3444f1b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,6 +145,24 @@ jobs: if: ${{ matrix.os == 'linux' && matrix.config == 'debug' }} run: ./extras/check-ir-stable-names-gh-actions.sh + - name: Check Version Constants + id: check-ir-versions + if: ${{ matrix.os == 'linux' && matrix.config == 'debug' && github.event_name == 'pull_request' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_EVENT_NAME: ${{ github.event_name }} + GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} + GITHUB_BASE_REF: ${{ github.base_ref }} + run: ./extras/check-inst-version-changes.sh + + - name: Upload IR version check results + if: ${{ steps.check-versions.outputs.artifact_created == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: ir-version-check-results + path: ir-version-check-artifact/ + retention-days: 1 + - name: Build Slang if: steps.filter.outputs.should-run == 'true' run: | diff --git a/.github/workflows/comment-ir-version-check.yml b/.github/workflows/comment-ir-version-check.yml new file mode 100644 index 000000000..462e2ec9c --- /dev/null +++ b/.github/workflows/comment-ir-version-check.yml @@ -0,0 +1,73 @@ +name: Comment IR Version Check Results + +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +jobs: + comment: + runs-on: ubuntu-latest + if: github.event.workflow_run.event == 'pull_request' + + steps: + - name: Download artifacts + id: download + uses: actions/github-script@v7 + with: + script: | + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ github.event.workflow_run.id }}, + }); + + const matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "ir-version-check-results" + })[0]; + + if (!matchArtifact) { + console.log('No IR version check artifacts found - nothing to comment'); + return false; + } + + const download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + + const fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/ir-version-check-results.zip', Buffer.from(download.data)); + return true; + + - name: Extract artifacts + if: steps.download.outputs.result == 'true' + run: unzip ir-version-check-results.zip + + - name: Read PR number + if: steps.download.outputs.result == 'true' + id: pr + run: | + echo "number=$(cat pr-number.txt)" >> $GITHUB_OUTPUT + + - name: Find existing comment + if: steps.download.outputs.result == 'true' + id: find-comment + uses: peter-evans/find-comment@v3 + with: + token: ${{ secrets.SLANGBOT_PAT }} + issue-number: ${{ steps.pr.outputs.number }} + body-includes: "" + + - name: Create or update comment + if: steps.download.outputs.result == 'true' + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.SLANGBOT_PAT }} + issue-number: ${{ steps.pr.outputs.number }} + comment-id: ${{ steps.find-comment.outputs.comment-id }} + body-path: comment-body.txt + edit-mode: replace -- cgit v1.2.3