mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-10 22:12:49 +00:00
Merge branch 'main' into feature/protobuf_config_and_dynamic_ui
This commit is contained in:
65
.github/workflows/check_profiles.yml
vendored
65
.github/workflows/check_profiles.yml
vendored
@@ -34,46 +34,6 @@ jobs:
|
||||
python3 ./scripts/orca_extra_profile_check.py 2>&1 | tee ${{ runner.temp }}/extra_json_check.log
|
||||
exit ${PIPESTATUS[0]}
|
||||
|
||||
- name: Check profile indentation
|
||||
id: indentation_check
|
||||
continue-on-error: true
|
||||
run: |
|
||||
set +e
|
||||
python3 - <<'PY' 2>&1 | tee ${{ runner.temp }}/indentation_check.log
|
||||
import re
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
profiles_root = Path("resources/profiles")
|
||||
invalid_files = []
|
||||
|
||||
for file_path in sorted(profiles_root.rglob("*.json")):
|
||||
try:
|
||||
for line_number, line in enumerate(file_path.read_text(encoding="utf-8").splitlines(), start=1):
|
||||
if not line.strip():
|
||||
continue
|
||||
leading_ws = re.match(r"^[ \t]*", line).group(0)
|
||||
if " " in leading_ws:
|
||||
invalid_files.append((file_path, line_number))
|
||||
break
|
||||
except Exception as exc:
|
||||
print(f"[ERROR] Unable to read {file_path}: {exc}")
|
||||
invalid_files.append((file_path, 0))
|
||||
|
||||
if invalid_files:
|
||||
for path, line in invalid_files:
|
||||
if line > 0:
|
||||
print(f"[ERROR] Space indentation found in {path}:{line}")
|
||||
else:
|
||||
print(f"[ERROR] Could not validate indentation in {path}")
|
||||
print("Use tab indentation in profile JSON files (1 tab per indentation level).")
|
||||
print("Tip: run python3 ./scripts/orca_filament_lib.py --fix --force to normalize formatting.")
|
||||
sys.exit(1)
|
||||
|
||||
print("All profile JSON files use tab-only indentation.")
|
||||
PY
|
||||
exit ${PIPESTATUS[0]}
|
||||
|
||||
# download
|
||||
- name: Download
|
||||
working-directory: ${{ github.workspace }}
|
||||
@@ -101,12 +61,18 @@ jobs:
|
||||
./OrcaSlicer_profile_validator -p ${{ github.workspace }}/resources/profiles -l 2 2>&1 | tee ${{ runner.temp }}/validate_custom.log
|
||||
exit ${PIPESTATUS[0]}
|
||||
|
||||
- name: Prepare comment artifact
|
||||
if: ${{ always() && github.event_name == 'pull_request' && (steps.extra_json_check.outcome == 'failure' || steps.indentation_check.outcome == 'failure' || steps.validate_system.outcome == 'failure' || steps.validate_custom.outcome == 'failure') }}
|
||||
- name: Prepare PR number for comment workflow
|
||||
if: ${{ always() && github.event_name == 'pull_request' }}
|
||||
run: |
|
||||
mkdir -p ${{ runner.temp }}/profile-check-results
|
||||
echo "${{ github.event.pull_request.number }}" > ${{ runner.temp }}/profile-check-results/pr_number.txt
|
||||
|
||||
- name: Prepare comment artifact
|
||||
if: ${{ always() && github.event_name == 'pull_request' && (steps.extra_json_check.outcome == 'failure' || steps.validate_system.outcome == 'failure' || steps.validate_custom.outcome == 'failure') }}
|
||||
run: |
|
||||
{
|
||||
# Marker matched by check_profiles_comment.yml to delete prior comments.
|
||||
echo "<!-- profile-validation-comment -->"
|
||||
echo "## :x: Profile Validation Errors"
|
||||
echo ""
|
||||
|
||||
@@ -119,15 +85,6 @@ jobs:
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${{ steps.indentation_check.outcome }}" = "failure" ]; then
|
||||
echo "### Indentation Check Failed"
|
||||
echo ""
|
||||
echo '```'
|
||||
head -c 30000 ${{ runner.temp }}/indentation_check.log || echo "No output captured"
|
||||
echo '```'
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${{ steps.validate_system.outcome }}" = "failure" ]; then
|
||||
echo "### System Profile Validation Failed"
|
||||
echo ""
|
||||
@@ -150,10 +107,8 @@ jobs:
|
||||
echo "*Please fix the above errors and push a new commit.*"
|
||||
} > ${{ runner.temp }}/profile-check-results/pr_comment.md
|
||||
|
||||
echo "${{ github.event.pull_request.number }}" > ${{ runner.temp }}/profile-check-results/pr_number.txt
|
||||
|
||||
- name: Upload comment artifact
|
||||
if: ${{ always() && github.event_name == 'pull_request' && (steps.extra_json_check.outcome == 'failure' || steps.indentation_check.outcome == 'failure' || steps.validate_system.outcome == 'failure' || steps.validate_custom.outcome == 'failure') }}
|
||||
if: ${{ always() && github.event_name == 'pull_request' }}
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: profile-check-results
|
||||
@@ -161,7 +116,7 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
- name: Fail if any check failed
|
||||
if: ${{ always() && (steps.extra_json_check.outcome == 'failure' || steps.indentation_check.outcome == 'failure' || steps.validate_system.outcome == 'failure' || steps.validate_custom.outcome == 'failure') }}
|
||||
if: ${{ always() && (steps.extra_json_check.outcome == 'failure' || steps.validate_system.outcome == 'failure' || steps.validate_custom.outcome == 'failure') }}
|
||||
run: |
|
||||
echo "One or more profile checks failed. See above for details."
|
||||
exit 1
|
||||
|
||||
30
.github/workflows/check_profiles_comment.yml
vendored
30
.github/workflows/check_profiles_comment.yml
vendored
@@ -10,12 +10,19 @@ on:
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
# Needed to delete outdated bot comments via the issues/comments endpoint.
|
||||
issues: write
|
||||
|
||||
# Serialize handlers per source branch so parallel runs don't race delete-and-post.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
post_comment:
|
||||
name: Post PR comment
|
||||
runs-on: ubuntu-24.04
|
||||
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' }}
|
||||
if: ${{ github.event.workflow_run.event == 'pull_request' && (github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure') }}
|
||||
steps:
|
||||
- name: Download artifact
|
||||
id: download
|
||||
@@ -26,14 +33,14 @@ jobs:
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ github.token }}
|
||||
|
||||
- name: Post comment on PR
|
||||
- name: Update PR comment
|
||||
if: ${{ steps.download.outcome == 'success' }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
run: |
|
||||
if [ ! -f pr_number.txt ] || [ ! -f pr_comment.md ]; then
|
||||
echo "No comment artifact found, skipping."
|
||||
if [ ! -f pr_number.txt ]; then
|
||||
echo "No pr_number.txt in artifact, skipping."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -43,4 +50,17 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gh pr comment "$PR_NUMBER" --body-file pr_comment.md
|
||||
# Delete prior comments matching the marker (from check_profiles.yml) or the legacy heading.
|
||||
OLD_IDS=$(gh api --paginate "repos/${GH_REPO}/issues/${PR_NUMBER}/comments" \
|
||||
--jq '.[] | select(.user.login == "github-actions[bot]") | select((.body | startswith("<!-- profile-validation-comment -->")) or (.body | startswith("## :x: Profile Validation Errors"))) | .id')
|
||||
for comment_id in $OLD_IDS; do
|
||||
echo "Deleting outdated profile-validation comment ${comment_id}"
|
||||
gh api -X DELETE "repos/${GH_REPO}/issues/comments/${comment_id}" || true
|
||||
done
|
||||
|
||||
# Post a new comment only when validation failed (pr_comment.md present).
|
||||
if [ -f pr_comment.md ]; then
|
||||
gh pr comment "$PR_NUMBER" --body-file pr_comment.md
|
||||
else
|
||||
echo "Validation succeeded; cleaned up prior comments without posting."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user