mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
Auto-delete CI linting comments on success (#6465)
# Description of Changes Set CI backend & engine comments to auto-delete once the CI has passed. Also redesign the engine CI to call `task engine:check` like it should have been, and make it post a comment when the tool models need to be updated. Also makes the comment wording more consistent between the three languages.
This commit is contained in:
+123
-26
@@ -1,8 +1,9 @@
|
|||||||
name: AI Engine CI
|
name: AI Engine CI
|
||||||
|
|
||||||
# Validates the Python AI engine: regenerates tool models, runs fixers,
|
# Validates the Python AI engine: regenerates tool models and runs the
|
||||||
# lint, type-check, and tests. Called from build.yml on PRs and merge_group;
|
# engine quality gate (lint, type-check, format-check, tests). Called from
|
||||||
# also runs directly on push to main as a post-merge safety net.
|
# build.yml on PRs and merge_group; also runs directly on push to main as
|
||||||
|
# a post-merge safety net.
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
push:
|
push:
|
||||||
@@ -51,27 +52,95 @@ jobs:
|
|||||||
run: task engine:tool-models
|
run: task engine:tool-models
|
||||||
|
|
||||||
- name: Verify tool models are up to date
|
- name: Verify tool models are up to date
|
||||||
|
id: tool-models-check
|
||||||
|
continue-on-error: true
|
||||||
|
run: git diff --exit-code engine/src/stirling/models/tool_models.py
|
||||||
|
|
||||||
|
- name: Comment on tool models check failure
|
||||||
|
# Only post a comment on PRs. github-script's PR helpers need an
|
||||||
|
# issue/PR number, which doesn't exist on merge_group runs.
|
||||||
|
if: steps.tool-models-check.outcome == 'failure' && github.event_name == 'pull_request'
|
||||||
|
continue-on-error: true
|
||||||
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const marker = '<!-- tool-models-check -->';
|
||||||
|
const body = [
|
||||||
|
marker,
|
||||||
|
'### Tool Models Check Failed',
|
||||||
|
'',
|
||||||
|
'The generated `engine/src/stirling/models/tool_models.py` is out of date with the Java OpenAPI spec and will need to be regenerated before it can be merged in.',
|
||||||
|
'',
|
||||||
|
'Run `task engine:tool-models` to regenerate, then commit the updated file.',
|
||||||
|
].join('\n');
|
||||||
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
});
|
||||||
|
const existing = comments.find(c => c.body.includes(marker));
|
||||||
|
if (existing) {
|
||||||
|
await github.rest.issues.updateComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
comment_id: existing.id,
|
||||||
|
body,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
body,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Fail if tool models check failed
|
||||||
|
if: steps.tool-models-check.outcome == 'failure'
|
||||||
run: |
|
run: |
|
||||||
if ! git diff --exit-code engine/src/stirling/models/tool_models.py; then
|
echo "============================================"
|
||||||
echo "tool_models.py is out of date."
|
echo " Tool Models Check Failed"
|
||||||
echo "Run 'task engine:tool-models' locally and commit the updated file."
|
echo "============================================"
|
||||||
|
echo ""
|
||||||
|
echo "The generated engine/src/stirling/models/tool_models.py"
|
||||||
|
echo "is out of date with the Java OpenAPI spec and will"
|
||||||
|
echo "need to be regenerated before it can be merged in."
|
||||||
|
echo ""
|
||||||
|
echo "Run 'task engine:tool-models' to regenerate, then"
|
||||||
|
echo "commit the updated file."
|
||||||
|
echo "============================================"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Run fixers
|
- name: Remove tool models check comment on success
|
||||||
run: task engine:fix
|
if: steps.tool-models-check.outcome == 'success' && github.event_name == 'pull_request'
|
||||||
|
continue-on-error: true
|
||||||
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const marker = '<!-- tool-models-check -->';
|
||||||
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
});
|
||||||
|
const existing = comments.find(c => c.body.includes(marker));
|
||||||
|
if (existing) {
|
||||||
|
await github.rest.issues.deleteComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
comment_id: existing.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
- name: Verify fixes are committed
|
- name: Quality-check engine
|
||||||
id: fixer_changes
|
id: engine-check
|
||||||
run: |
|
run: task engine:check
|
||||||
if ! git diff --quiet; then
|
continue-on-error: true
|
||||||
git --no-pager diff --stat
|
|
||||||
echo "::error::There are issues with your Python code that will need to be fixed before they can be merged in. Run 'task engine:fix' to auto-fix what can be fixed automatically, then run 'task engine:check' to see what still needs fixing manually."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Comment on fixer failures
|
- name: Comment on engine check failure
|
||||||
if: steps.fixer_changes.outcome == 'failure' && github.event_name == 'pull_request'
|
# Only post a comment on PRs. github-script's PR helpers need an
|
||||||
|
# issue/PR number, which doesn't exist on merge_group runs.
|
||||||
|
if: steps.engine-check.outcome == 'failure' && github.event_name == 'pull_request'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
with:
|
with:
|
||||||
@@ -107,11 +176,39 @@ jobs:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Run linting
|
- name: Fail if engine check failed
|
||||||
run: task engine:lint
|
if: steps.engine-check.outcome == 'failure'
|
||||||
|
run: |
|
||||||
|
echo "============================================"
|
||||||
|
echo " Engine Check Failed"
|
||||||
|
echo "============================================"
|
||||||
|
echo ""
|
||||||
|
echo "There are issues with your Python code that"
|
||||||
|
echo "will need to be fixed before they can be merged in."
|
||||||
|
echo ""
|
||||||
|
echo "Run 'task engine:fix' to auto-fix what can be"
|
||||||
|
echo "fixed automatically, then run 'task engine:check'"
|
||||||
|
echo "to see what still needs fixing manually."
|
||||||
|
echo "============================================"
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Run type checking
|
- name: Remove engine check comment on success
|
||||||
run: task engine:typecheck
|
if: steps.engine-check.outcome == 'success' && github.event_name == 'pull_request'
|
||||||
|
continue-on-error: true
|
||||||
- name: Run tests
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
run: task engine:test
|
with:
|
||||||
|
script: |
|
||||||
|
const marker = '<!-- engine-check -->';
|
||||||
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
});
|
||||||
|
const existing = comments.find(c => c.body.includes(marker));
|
||||||
|
if (existing) {
|
||||||
|
await github.rest.issues.deleteComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
comment_id: existing.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
||||||
|
|
||||||
- name: Comment on Java formatting failure
|
- name: Comment on backend format check failure
|
||||||
# Only post a comment on PRs. github-script's PR helpers need an
|
# Only post a comment on PRs. github-script's PR helpers need an
|
||||||
# issue/PR number, which doesn't exist on merge_group runs.
|
# issue/PR number, which doesn't exist on merge_group runs.
|
||||||
if: steps.spotless-check.outcome == 'failure' && github.event_name == 'pull_request'
|
if: steps.spotless-check.outcome == 'failure' && github.event_name == 'pull_request'
|
||||||
@@ -78,15 +78,11 @@ jobs:
|
|||||||
const marker = '<!-- java-formatting-check -->';
|
const marker = '<!-- java-formatting-check -->';
|
||||||
const body = [
|
const body = [
|
||||||
marker,
|
marker,
|
||||||
'### Java Formatting Check Failed',
|
'### Backend Format Check Failed',
|
||||||
'',
|
'',
|
||||||
'Your code has formatting issues. Run the following command to fix them:',
|
'There are formatting issues in your Java code that will need to be fixed before they can be merged in.',
|
||||||
'',
|
'',
|
||||||
'```bash',
|
'Run `task backend:format` to auto-fix, then commit and push the changes.',
|
||||||
'task backend:format',
|
|
||||||
'```',
|
|
||||||
'',
|
|
||||||
'Then commit and push the changes.',
|
|
||||||
].join('\n');
|
].join('\n');
|
||||||
const { data: comments } = await github.rest.issues.listComments({
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
@@ -110,22 +106,43 @@ jobs:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Fail if Java formatting issues found
|
- name: Fail if backend format check failed
|
||||||
if: steps.spotless-check.outcome == 'failure'
|
if: steps.spotless-check.outcome == 'failure'
|
||||||
run: |
|
run: |
|
||||||
echo "============================================"
|
echo "============================================"
|
||||||
echo " Java Formatting Check Failed"
|
echo " Backend Format Check Failed"
|
||||||
echo "============================================"
|
echo "============================================"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Your code has formatting issues."
|
echo "There are formatting issues in your Java code"
|
||||||
echo "Run the following command to fix them:"
|
echo "that will need to be fixed before they can be"
|
||||||
|
echo "merged in."
|
||||||
echo ""
|
echo ""
|
||||||
echo " task backend:format"
|
echo "Run 'task backend:format' to auto-fix, then"
|
||||||
echo ""
|
echo "commit and push the changes."
|
||||||
echo "Then commit and push the changes."
|
|
||||||
echo "============================================"
|
echo "============================================"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
|
- name: Remove backend format check comment on success
|
||||||
|
if: steps.spotless-check.outcome == 'success' && github.event_name == 'pull_request'
|
||||||
|
continue-on-error: true
|
||||||
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const marker = '<!-- java-formatting-check -->';
|
||||||
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
});
|
||||||
|
const existing = comments.find(c => c.body.includes(marker));
|
||||||
|
if (existing) {
|
||||||
|
await github.rest.issues.deleteComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
comment_id: existing.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
- name: Build with Gradle and spring security ${{ matrix.spring-security }}
|
- name: Build with Gradle and spring security ${{ matrix.spring-security }}
|
||||||
run: task backend:build:ci
|
run: task backend:build:ci
|
||||||
env:
|
env:
|
||||||
|
|||||||
Reference in New Issue
Block a user