Skip to content

Commit

Permalink
Run TLAi and upload SARIF report iff git commit contains TLA files
Browse files Browse the repository at this point in the history
[Build]
  • Loading branch information
lemmy committed Mar 26, 2024
1 parent 4c92be7 commit 8d2542e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/tlaplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,28 @@ jobs:
## All history for git diff below to succeed.
fetch-depth: 0

- name: Check if HEAD commit contains TLA changes.
id: git_commit
run: echo "::set-output name=contains_tla::$(git diff --name-only HEAD^ | grep -q '\.tla' && echo 'true' || echo 'false')"

- name: Setup NodeJS
if: step.git_commit.outputs.contains_tla == 'true'
## https://github.com/actions/setup-node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Run GenAIscript on the TLA+ specs that are added in this pull request.
if: step.git_commit.outputs.contains_tla == 'true'
## Identify git diff: $(git diff --name-only HEAD^ | grep '.tla')
## Install genaiscript runtime: https://microsoft.github.io/genaiscript/reference/cli/
## Output LLM response in SARIF format: https://microsoft.github.io/genaiscript/reference/scripts/annotations/ (redirect other output to /dev/null for GH not to also show the annotations)
run: npx --yes genaiscript run scripts/TLAi-linter.genai.js $(git diff --name-only HEAD^ | grep '.tla') --max-tokens 2000 --out-annotations results.sarif > /dev/null
run: npx --yes genaiscript run scripts/TLAi-linter.genai.js $(git diff --name-only HEAD^ | grep '\.tla') --max-tokens 2000 --out-annotations results.sarif > /dev/null

- name: Upload SARIF file
if: (success() || failure()) && step.git_commit.outputs.contains_tla == 'true'
## https://sarifweb.azurewebsites.net
## https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github
if: success() || failure()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif

0 comments on commit 8d2542e

Please sign in to comment.