mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
# Description of Changes This PR removes workflow-specific cache suffixes from Python dependency caching in several CI workflows. Previously, the following workflows appended their own `cache-suffix` even though they use the same Python dependency files: - `ai-engine.yml` - `check-generated-models.yml` - `pre_commit.yml` - `sync_files_v2.yml` All of these workflows use the same cache dependency inputs: - `engine/pyproject.toml` - `engine/uv.lock` The workflow-specific suffixes caused separate cache entries to be created for effectively identical dependency sets. This resulted in unnecessary cache duplication and reduced cache reuse between workflows. By removing the suffixes, these workflows can now share the same cache when their dependency inputs and other cache key components match. This change reduces redundant cache storage, improves cache hit potential across CI workflows, and avoids repeatedly creating equivalent caches under different names. No functional application behavior is changed. The modification only affects CI cache key generation and reuse. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have run `task check` to verify linters, typechecks, and tests pass - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing) for more details. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
129 lines
4.8 KiB
YAML
129 lines
4.8 KiB
YAML
name: AI Engine CI
|
|
|
|
# Runs the engine quality gate (lint, type-check, format-check, tests). Called
|
|
# from build.yml on PRs and merge_group; also runs directly on push to main as
|
|
# a post-merge safety net. Freshness of the generated tool_models.py is checked
|
|
# by the shared check-generated-models workflow.
|
|
on:
|
|
workflow_call:
|
|
push:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
engine:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
steps:
|
|
- name: Harden the runner (Audit all outbound calls)
|
|
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
|
with:
|
|
enable-cache: true
|
|
cache-dependency-glob: |
|
|
engine/pyproject.toml
|
|
engine/uv.lock
|
|
|
|
- name: Install Task
|
|
uses: go-task/setup-task@01a4adf9db2d14c1de7a560f09170b6e0df736aa # v2.1.0
|
|
|
|
- name: Quality-check engine
|
|
id: engine-check
|
|
run: task engine:check
|
|
continue-on-error: true
|
|
|
|
- name: Comment on engine 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.engine-check.outcome == 'failure' && github.event_name == 'pull_request'
|
|
continue-on-error: true
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
with:
|
|
script: |
|
|
const marker = '<!-- engine-check -->';
|
|
const body = [
|
|
marker,
|
|
'### Engine Check Failed',
|
|
'',
|
|
'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.',
|
|
].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 engine check failed
|
|
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: Build engine production image
|
|
if: always()
|
|
run: docker build --file engine/Dockerfile --tag stirling-pdf-engine:ci .
|
|
|
|
- name: Build engine development image
|
|
if: always()
|
|
run: docker build --file engine/Dockerfile.dev --tag stirling-pdf-engine-dev:ci .
|
|
|
|
- name: Remove engine check comment on success
|
|
if: steps.engine-check.outcome == 'success' && github.event_name == 'pull_request'
|
|
continue-on-error: true
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
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,
|
|
});
|
|
}
|