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 b09996f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/tlaplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,29 @@ jobs:
## All history for git diff below to succeed.
fetch-depth: 0

- name: Check if HEAD commit contains TLA changes.
if: ${{ secrets.OPENAI_API_KEY != '' }}
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

- 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 b09996f

Please sign in to comment.