From ced980e6a8c6e68c313e05b57479ea3758979223 Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Wed, 1 Jul 2026 18:34:07 +0800 Subject: [PATCH] feat: update preset validator to validate against older generated presets --- .github/workflows/check_profiles.yml | 108 +++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check_profiles.yml b/.github/workflows/check_profiles.yml index 9a5272a314..9c0a60d741 100644 --- a/.github/workflows/check_profiles.yml +++ b/.github/workflows/check_profiles.yml @@ -63,11 +63,109 @@ jobs: continue-on-error: true working-directory: ${{ github.workspace }} run: | - set +e - curl -LJO https://github.com/OrcaSlicer/OrcaSlicer/releases/download/nightly-builds/orca_custom_preset_tests.zip - unzip -q ./orca_custom_preset_tests.zip -d ${{ github.workspace }}/resources/profiles - ./OrcaSlicer_profile_validator -p ${{ github.workspace }}/resources/profiles -l 2 2>&1 | tee ${{ runner.temp }}/validate_custom.log - exit ${PIPESTATUS[0]} + fixtures_dir="${{ runner.temp }}/profile-fixtures" + output_dir="${{ runner.temp }}/custom-preset-validation" + combined_log="${{ runner.temp }}/validate_custom.log" + summary="${output_dir}/summary.md" + release_url="https://github.com/OrcaSlicer/OrcaSlicer-profile-validator/releases/download/fixture-archive" + + rm -rf "${fixtures_dir}" "${output_dir}" + mkdir -p "${fixtures_dir}" "${output_dir}" + + curl -fsSL -o "${fixtures_dir}/manifest.json" "${release_url}/manifest.json" + + MANIFEST_PATH="${fixtures_dir}/manifest.json" python3 <<'PY' > "${fixtures_dir}/fixtures.tsv" + import json + import os + + with open(os.environ["MANIFEST_PATH"], encoding="utf-8") as fh: + manifest = json.load(fh) + + if isinstance(manifest, dict): + entries = manifest.get("fixtures", []) + else: + entries = manifest + + for entry in entries: + version = entry.get("version", "") + asset = entry.get("asset", "") + sha256 = entry.get("asset_sha256", "") + if not version or not asset: + continue + print(f"{version}\t{asset}\t{sha256}") + PY + + if [ ! -s "${fixtures_dir}/fixtures.tsv" ]; then + echo "No custom preset fixtures found in ${release_url}/manifest.json" | tee "${combined_log}" + exit 1 + fi + + { + echo "## Custom Preset Fixture Validation" + echo "" + echo "| Version | Status | Log |" + echo "| --- | --- | --- |" + } > "${summary}" + + status=0 + failed_logs=() + + while IFS=$'\t' read -r version asset expected_sha256; do + fixture_zip="${fixtures_dir}/${asset}" + asset_url_name="$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "${asset}")" + profile_tree="${output_dir}/profiles-${version}" + log_path="${output_dir}/${version}.log" + + curl -fsSL -o "${fixture_zip}" "${release_url}/${asset_url_name}" + + if [ -n "${expected_sha256}" ] && [ "${expected_sha256}" != "" ]; then + echo "${expected_sha256} ${fixture_zip}" | sha256sum -c - + fi + + rm -rf "${profile_tree}" + mkdir -p "${profile_tree}" + cp -a "${{ github.workspace }}/resources/profiles/." "${profile_tree}/" + rm -rf "${profile_tree}/user" + unzip -q "${fixture_zip}" -d "${profile_tree}" + + set +e + ./OrcaSlicer_profile_validator -p "${profile_tree}" -l 2 > "${log_path}" 2>&1 + result=$? + set -e + + if [ "${result}" -eq 0 ]; then + echo "| ${version} | PASS | ${version}.log |" >> "${summary}" + else + echo "| ${version} | FAIL | ${version}.log |" >> "${summary}" + failed_logs+=("${log_path}") + status=1 + fi + done < "${fixtures_dir}/fixtures.tsv" + + { + cat "${summary}" + if [ "${#failed_logs[@]}" -gt 0 ]; then + echo "" + echo "## Failed Fixture Logs" + for log_path in "${failed_logs[@]}"; do + echo "" + echo "### $(basename "${log_path}" .log)" + echo '```' + head -c 12000 "${log_path}" || echo "No output captured" + echo '```' + done + fi + } | tee "${combined_log}" + + exit "${status}" + + - name: Upload custom preset validation logs + if: ${{ always() }} + uses: actions/upload-artifact@v7 + with: + name: custom-preset-validation-logs + path: ${{ runner.temp }}/custom-preset-validation/ + retention-days: 7 - name: Prepare PR number for comment workflow if: ${{ always() && github.event_name == 'pull_request' }}