@@ -14,7 +14,7 @@ permissions:
1414jobs :
1515 cleanup_old_runs :
1616 if : github.event.schedule == '0 13 * * *'
17- runs-on : ubuntu-20.04
17+ runs-on : ubuntu-latest
1818 permissions :
1919 actions : write
2020 env :
3333
3434 run_command :
3535 if : github.event.issue.pull_request != '' && contains(github.event.comment.body, '/run')
36- runs-on : ubuntu-20.04
36+ runs-on : ubuntu-latest
3737 steps :
3838 - name : Extract command to run
3939 uses : actions/github-script@v3
@@ -76,30 +76,80 @@ jobs:
7676 if : steps.command-extractor.outputs.result == 'fantomas'
7777 id : fantomas
7878 run : dotnet fantomas . -r
79- - name : Process fantomas command
79+ - name : Process xlf command
8080 if : steps.command-extractor.outputs.result == 'xlf'
8181 id : xlf
8282 run : dotnet build src/Compiler /t:UpdateXlf
83+ - name : Post ilverify start comment
84+ if : steps.command-extractor.outputs.result == 'ilverify'
85+ uses : actions/github-script@v3
86+ with :
87+ script : |
88+ const body = `Started to run ilverify baseline update`;
89+ await github.issues.createComment({
90+ issue_number: context.issue.number,
91+ owner: context.repo.owner,
92+ repo: context.repo.repo,
93+ body: body
94+ });
95+
96+ - name : Process ilverify command (Update ILVerify baselines)
97+ if : steps.command-extractor.outputs.result == 'ilverify'
98+ id : ilverify
99+ env :
100+ TEST_UPDATE_BSL : 1
101+ run : |
102+ # Run the ilverify script with TEST_UPDATE_BSL=1
103+ pwsh tests/ILVerify/ilverify.ps1
104+
105+ # Calculate the changes per file
106+ echo "Checking for changes in baseline files..."
107+ FILES_CHANGED=0
108+ CHANGES_OUTPUT=""
109+
110+ for file in tests/ILVerify/*.bsl; do
111+ if git diff --quiet "$file"; then
112+ continue
113+ else
114+ FILES_CHANGED=$((FILES_CHANGED + 1))
115+ LINES_CHANGED=$(git diff --numstat "$file" | awk '{print $1 + $2}')
116+ CHANGES_OUTPUT="${CHANGES_OUTPUT}${file}: ${LINES_CHANGED} lines changed\n"
117+ fi
118+ done
119+
120+ if [ "$FILES_CHANGED" -eq 0 ]; then
121+ echo "result=The ilverify command ran and did not modify any baseline." >> $GITHUB_OUTPUT
122+ else
123+ echo -e "result=The ilverify command ran and triggered the following number of changes per file:\n${CHANGES_OUTPUT}" >> $GITHUB_OUTPUT
124+ fi
83125 - name : Commit and push changes
84- if : steps.fantomas.outcome == 'success' || steps.xlf.outcome == 'success'
126+ if : steps.fantomas.outcome == 'success' || steps.xlf.outcome == 'success' || steps.ilverify.outcome == 'success'
85127 run : |
128+ # Only commit if there are actual changes
129+ if git diff --quiet; then
130+ echo "No changes to commit, skipping."
131+ exit 0
132+ fi
133+
86134 git config --local user.name "github-actions[bot]"
87135 git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
88136 git commit -a -m 'Automated command ran: ${{ steps.command-extractor.outputs.result }}
89137
90138 Co-authored-by: ${{ github.event.comment.user.login }} <${{ github.event.comment.user.id }}+${{ github.event.comment.user.login }}@users.noreply.github.com>'
91139 git push
92140 - name : Post command comment
93- if : steps.fantomas.outcome == 'success' || steps.xlf.outcome == 'success'
141+ if : steps.fantomas.outcome == 'success' || steps.xlf.outcome == 'success' || steps.ilverify.outcome == 'success'
94142 uses : actions/github-script@v3
95143 with :
96144 script : |
97145 // Probably, there's more universal way of getting outputs, but my gh-actions-fu is not that good.
98146 var output = ""
99147 if ("${{steps.command-extractor.outputs.result}}" == 'fantomas') {
100148 output = "${{steps.fantomas.outputs.result}}"
101- } else if("${{steps.command-extractor.outputs.result}}" == 'xlf') {
149+ } else if ("${{steps.command-extractor.outputs.result}}" == 'xlf') {
102150 output = "${{steps.xlf.outputs.result}}"
151+ } else if ("${{steps.command-extractor.outputs.result}}" == 'ilverify') {
152+ output = "${{steps.ilverify.outputs.result}}"
103153 }
104154 const body = `Ran ${{ steps.command-extractor.outputs.result }}: https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.GITHUB_RUN_ID}\n${output}`;
105155 await github.issues.createComment({
0 commit comments