Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

0.11.1 retro: downloads retry and cache, release.sh pins What's New and reruns 5xx jobs, merge-queue refuses reverts

islandmed7d8b1804977a
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 933faafe..847e29fc 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -149,8 +149,15 @@ jobs:
CCACHE_MAXSIZE: 500M
CCACHE_DEPEND: 'true' # include files from the compiler's own dependency list (-MD, /showIncludes): no extra preprocessor run
SF_TEST_BUDGET: 150 # seconds per test (tools/test/run.py); software OpenGL is several times slower than the PC's GPU
+ SF_DEPS_CACHE: .deps # downloads: cmake/Fetch.cmake, tools/ci/fetch.sh
steps:
- uses: actions/checkout@v7
+ - name: Downloads (cmake/Fetch.cmake's archives and pinned tools, kept by hash by tools/ci/fetch.sh)
+ uses: actions/cache@v5
+ with:
+ path: .deps
+ key: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cmake/Fetch.cmake', '.github/workflows/ci.yml') }}
+ restore-keys: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-
- uses: actions/setup-python@v7
id: py
with:
@@ -163,19 +170,20 @@ jobs:
- name: ccache (macOS; the release binary, pinned by hash)
if: runner.os == 'macOS'
run: |
- curl -fsSLO https://github.com/ccache/ccache/releases/download/v4.14.2/ccache-4.14.2-darwin.tar.gz
- echo "cf240009630b605b775c7c5c7b7105a3b196c79f31af322c1557969aa28003fc ccache-4.14.2-darwin.tar.gz" | shasum -a 256 -c
- tar xzf ccache-4.14.2-darwin.tar.gz -C "$RUNNER_TEMP"
+ tar xzf "$(tools/ci/fetch.sh https://github.com/ccache/ccache/releases/download/v4.14.2/ccache-4.14.2-darwin.tar.gz \
+ cf240009630b605b775c7c5c7b7105a3b196c79f31af322c1557969aa28003fc)" -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/ccache-4.14.2-darwin" >> "$GITHUB_PATH"
- - name: ccache (Windows; the release binary, pinned by hash, standing in for cl.exe)
+ - name: ccache (Windows; the release binary, pinned by hash)
+ if: runner.os == 'Windows'
+ shell: bash
+ run: |
+ tools/ci/fetch.sh https://github.com/ccache/ccache/releases/download/v4.14.2/ccache-4.14.2-windows-x86_64.zip 6993ce645e53192cec592ee23186200b574ac4c59097ecde8d9cfd681b47ae84
+ tools/ci/fetch.sh https://github.com/pal1000/mesa-dist-win/releases/download/26.2.4/mesa3d-26.2.4-release-msvc.7z 351fc8c8b695878ffb3eaa044b3ead08672a48b1a045e3c3e3975811df0f6695
+ - name: ccache (Windows; unpacked, standing in for cl.exe)
if: runner.os == 'Windows'
shell: pwsh
run: |
- $zip = 'ccache-4.14.2-windows-x86_64.zip'
- Invoke-WebRequest "https://github.com/ccache/ccache/releases/download/v4.14.2/$zip" -OutFile $zip
- if ((Get-FileHash $zip -Algorithm SHA256).Hash -ne '6993CE645E53192CEC592EE23186200B574AC4C59097ECDE8D9CFD681B47AE84') {
- throw 'ccache archive hash mismatch'
- }
+ $zip = '.deps\6993ce645e53192cec592ee23186200b574ac4c59097ecde8d9cfd681b47ae84-ccache-4.14.2-windows-x86_64.zip'
Expand-Archive $zip -DestinationPath $env:RUNNER_TEMP
$dir = "$env:RUNNER_TEMP\ccache-4.14.2-windows-x86_64"
"$dir" >> $env:GITHUB_PATH
@@ -252,13 +260,9 @@ jobs:
if: runner.os == 'Windows'
shell: pwsh
run: |
- # The runner has no GPU driver: Mesa's software OpenGL (pal1000/mesa-dist-win), pinned by hash.
- $url = 'https://github.com/pal1000/mesa-dist-win/releases/download/26.2.4/mesa3d-26.2.4-release-msvc.7z'
- Invoke-WebRequest $url -OutFile mesa.7z
- if ((Get-FileHash mesa.7z -Algorithm SHA256).Hash -ne '351FC8C8B695878FFB3EAA044B3EAD08672A48B1A045E3C3E3975811DF0F6695') {
- throw 'mesa3d archive hash mismatch'
- }
- 7z e mesa.7z x64/opengl32.dll x64/libgallium_wgl.dll -obuild/Release -y | Out-Null
+ # The runner has no GPU driver: Mesa's software OpenGL (pal1000/mesa-dist-win), pinned by hash (fetched with
+ # ccache above, tools/ci/fetch.sh).
+ 7z e .deps\351fc8c8b695878ffb3eaa044b3ead08672a48b1a045e3c3e3975811df0f6695-mesa3d-26.2.4-release-msvc.7z x64/opengl32.dll x64/libgallium_wgl.dll -obuild/Release -y | Out-Null
$env:GALLIUM_DRIVER = 'llvmpipe'
python tools/test/run.py --build build --junit build/ctest.xml -- -C Release -j 4 -I '${{ matrix.shard }},,${{ matrix.shards }}'
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
@@ -292,8 +296,15 @@ jobs:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_MAXSIZE: 300M
CCACHE_DEPEND: 'true'
+ SF_DEPS_CACHE: .deps
steps:
- uses: actions/checkout@v7
+ - name: Downloads (cmake/Fetch.cmake's archives and pinned tools, kept by hash by tools/ci/fetch.sh)
+ uses: actions/cache@v5
+ with:
+ path: .deps
+ key: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cmake/Fetch.cmake', '.github/workflows/ci.yml') }}
+ restore-keys: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
@@ -345,11 +356,17 @@ jobs:
- run: dnf -y install git tar gzip zstd # zstd: actions/cache compresses with it (gzip is several times slower)
- uses: actions/checkout@v7
- run: ./packaging/linux/install-build-deps.sh
+ - name: Downloads (cmake/Fetch.cmake's archives and pinned tools, kept by hash by tools/ci/fetch.sh)
+ uses: actions/cache@v5
+ with:
+ path: .deps
+ key: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cmake/Fetch.cmake', '.github/workflows/ci.yml') }}
+ restore-keys: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-
- name: ccache (the static release binary, pinned by hash)
run: |
- curl -fsSLO https://github.com/ccache/ccache/releases/download/v4.14.2/ccache-4.14.2-linux-x86_64-musl-static.tar.gz
- echo "d540ba01f160addbd3dd5e18eda9bd34005591b095c09ac8ae9d0a1b655e7ef5 ccache-4.14.2-linux-x86_64-musl-static.tar.gz" | sha256sum -c
- tar xzf ccache-4.14.2-linux-x86_64-musl-static.tar.gz -C /opt
+ echo "SF_DEPS_CACHE=$GITHUB_WORKSPACE/.deps" >> "$GITHUB_ENV"
+ tar xzf "$(tools/ci/fetch.sh https://github.com/ccache/ccache/releases/download/v4.14.2/ccache-4.14.2-linux-x86_64-musl-static.tar.gz \
+ d540ba01f160addbd3dd5e18eda9bd34005591b095c09ac8ae9d0a1b655e7ef5)" -C /opt
echo "/opt/ccache-4.14.2-linux-x86_64-musl-static" >> "$GITHUB_PATH"
# (In a container job the github.workspace expression gives the host's path; $GITHUB_WORKSPACE is the container's.)
echo "CCACHE_DIR=$GITHUB_WORKSPACE/.ccache" >> "$GITHUB_ENV"
@@ -362,11 +379,16 @@ jobs:
path: .ccache
key: ccache-ci-${{ matrix.cy }}.${{ github.sha }}
restore-keys: ccache-ci-${{ matrix.cy }}.
- - name: Python 3.13 (python-build-standalone via uv)
+ - name: Python 3.13 (python-build-standalone, pinned by hash)
run: |
- curl -LsSf https://astral.sh/uv/0.9.5/install.sh | sh
- ~/.local/bin/uv venv --python 3.13 /opt/py313
- ~/.local/bin/uv pip install --python /opt/py313/bin/python numpy
+ case $(uname -m) in
+ x86_64) sum=c0ccda275948c79996e46993c2c5476ff5cca606dee530f1dea712179131b348 ;;
+ aarch64) sum=baa3d107d17e4328448e30c3c9c83cca0eb41ca7a37c10982e14d46a5c3db07d ;;
+ esac
+ f=$(tools/ci/fetch.sh "https://github.com/astral-sh/python-build-standalone/releases/download/20251014/cpython-3.13.9%2B20251014-$(uname -m)-unknown-linux-gnu-install_only_stripped.tar.gz" $sum)
+ tar xzf "$f" -C /opt # /opt/python
+ /opt/python/bin/python3.13 -m venv /opt/py313
+ /opt/py313/bin/python -m pip install --retries 8 --timeout 60 numpy
echo "PYTHON313=/opt/py313/bin/python" >> "$GITHUB_ENV"
- name: Build with GCC 14
run: |
diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml
index b2279443..d06e4770 100644
--- a/.github/workflows/packages.yml
+++ b/.github/workflows/packages.yml
@@ -49,6 +49,8 @@ env:
REF: ${{ inputs.ref || github.sha }}
CCACHE_MAXSIZE: 500M
CCACHE_DEPEND: 'true'
+ # Downloads (cmake/Fetch.cmake, tools/ci/fetch.sh, the AppImage tools) go to .deps, cached per job by hash.
+ SF_DEPS_CACHE: .deps
# Saved by branch runs only: never a tag, never a pull request.
SAVE_CACHE: ${{ !startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' }}
# Tests that open real network connections return early here (tests/TestHarness.h networkTestsOff): a runner's
@@ -111,6 +113,12 @@ jobs:
sudo apt-get install -y --no-install-recommends ccache xvfb libgl1-mesa-dri
echo "CCACHE_DIR=$GITHUB_WORKSPACE/.ccache" >> "$GITHUB_ENV"
echo "CCACHE_BASEDIR=$GITHUB_WORKSPACE" >> "$GITHUB_ENV"
+ - name: Downloads (cmake/Fetch.cmake's archives and pinned tools, kept by hash by tools/ci/fetch.sh)
+ uses: actions/cache@v5
+ with:
+ path: .deps
+ key: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cmake/Fetch.cmake', 'packaging/linux/build-appimage.sh', '.github/workflows/packages.yml') }}
+ restore-keys: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-
- uses: actions/cache/restore@v5
with:
path: .ccache
@@ -139,7 +147,7 @@ jobs:
# Named the AppImage way (SculptForge-1.2.3-x86_64.AppImage, no "linux"), with update information so
# AppImageUpdate and similar tools can update it from the newest GitHub release (the .zsync file). The
# AppDir's root gets PNG icons (AppImage managers cannot use the SVG), and appimagetool checks it (#17).
- packaging/linux/build-appimage.sh AppDir "${TAG#v}" ${{ matrix.ld }} build
+ SF_APPIMAGE_TOOLS=.deps/appimage packaging/linux/build-appimage.sh AppDir "${TAG#v}" ${{ matrix.ld }} build
- uses: actions/upload-artifact@v7
with:
name: linux-${{ matrix.arch }}
@@ -166,6 +174,12 @@ jobs:
with: { ref: '${{ env.REF }}' }
- name: flatpak and flatpak-builder
run: sudo apt-get update && sudo apt-get install -y flatpak flatpak-builder xvfb
+ - name: The manifest's sources (flatpak-builder's downloads, checked by their sha256 in the manifest)
+ uses: actions/cache@v5
+ with:
+ path: build-flatpak/state/downloads
+ key: flatpak-src-${{ matrix.arch }}-${{ hashFiles('packaging/flatpak/*.yml') }}
+ restore-keys: flatpak-src-${{ matrix.arch }}-
- uses: actions/cache/restore@v5
with:
path: build-flatpak/state/ccache
@@ -215,16 +229,20 @@ jobs:
# (a beta's tag names its packages without the prerelease: v0.11.0-beta.1 makes SculptForge-0.11.0-*)
run: echo "TAG=${{ inputs.tag }}" | sed "s/^TAG=$/TAG=v$(sed -n 's/^project(SculptForge VERSION \([0-9.]*\).*/\1/p' CMakeLists.txt)/; s/^\(TAG=v[0-9.]*\)-.*/\1/" >> "$GITHUB_ENV"
- run: ./packaging/linux/install-build-deps.sh
+ - name: Downloads (cmake/Fetch.cmake's archives and pinned tools, kept by hash by tools/ci/fetch.sh)
+ uses: actions/cache@v5
+ with:
+ path: .deps
+ key: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cmake/Fetch.cmake', '.github/workflows/packages.yml') }}
+ restore-keys: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-
- name: ccache (the static release binary, pinned by hash)
run: |
f=ccache-4.14.2-linux-${{ matrix.ccarch }}-musl-static.tar.gz
- curl -fsSLO "https://github.com/ccache/ccache/releases/download/v4.14.2/$f"
case ${{ matrix.ccarch }} in
x86_64) sum=d540ba01f160addbd3dd5e18eda9bd34005591b095c09ac8ae9d0a1b655e7ef5 ;;
aarch64) sum=2be524bbccfc7e9ff0085d110da7dc9964de983bd92d29acf3b872e557194945 ;;
esac
- echo "$sum $f" | sha256sum -c
- tar xzf "$f" -C /opt
+ tar xzf "$(tools/ci/fetch.sh "https://github.com/ccache/ccache/releases/download/v4.14.2/$f" $sum)" -C /opt
echo "/opt/${f%.tar.gz}" >> "$GITHUB_PATH"
echo "CCACHE_DIR=$GITHUB_WORKSPACE/.ccache" >> "$GITHUB_ENV"
echo "CCACHE_BASEDIR=$GITHUB_WORKSPACE" >> "$GITHUB_ENV"
@@ -236,11 +254,16 @@ jobs:
restore-keys: |
ccache-pkg-${{ matrix.suffix }}-${{ matrix.arch }}.
ccache-ci-${{ matrix.cy }}.
- - name: Python 3.13
+ - name: Python 3.13 (python-build-standalone, pinned by hash)
run: |
- curl -LsSf https://astral.sh/uv/0.9.5/install.sh | sh
- ~/.local/bin/uv venv --python 3.13 /opt/py313
- ~/.local/bin/uv pip install --python /opt/py313/bin/python numpy
+ case $(uname -m) in
+ x86_64) sum=c0ccda275948c79996e46993c2c5476ff5cca606dee530f1dea712179131b348 ;;
+ aarch64) sum=baa3d107d17e4328448e30c3c9c83cca0eb41ca7a37c10982e14d46a5c3db07d ;;
+ esac
+ f=$(tools/ci/fetch.sh "https://github.com/astral-sh/python-build-standalone/releases/download/20251014/cpython-3.13.9%2B20251014-$(uname -m)-unknown-linux-gnu-install_only_stripped.tar.gz" $sum)
+ tar xzf "$f" -C /opt # /opt/python
+ /opt/python/bin/python3.13 -m venv /opt/py313
+ /opt/py313/bin/python -m pip install --retries 8 --timeout 60 numpy
echo "PYTHON313=/opt/py313/bin/python" >> "$GITHUB_ENV"
- name: Build with GCC 14
run: |
@@ -277,11 +300,16 @@ jobs:
steps:
- uses: actions/checkout@v7
with: { ref: '${{ env.REF }}' }
+ - name: Downloads (cmake/Fetch.cmake's archives and pinned tools, kept by hash by tools/ci/fetch.sh)
+ uses: actions/cache@v5
+ with:
+ path: .deps
+ key: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cmake/Fetch.cmake', '.github/workflows/packages.yml') }}
+ restore-keys: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-
- name: ccache (the release binary, pinned by hash)
run: |
- curl -fsSLO https://github.com/ccache/ccache/releases/download/v4.14.2/ccache-4.14.2-darwin.tar.gz
- echo "cf240009630b605b775c7c5c7b7105a3b196c79f31af322c1557969aa28003fc ccache-4.14.2-darwin.tar.gz" | shasum -a 256 -c
- tar xzf ccache-4.14.2-darwin.tar.gz -C "$RUNNER_TEMP"
+ tar xzf "$(tools/ci/fetch.sh https://github.com/ccache/ccache/releases/download/v4.14.2/ccache-4.14.2-darwin.tar.gz \
+ cf240009630b605b775c7c5c7b7105a3b196c79f31af322c1557969aa28003fc)" -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/ccache-4.14.2-darwin" >> "$GITHUB_PATH"
echo "CCACHE_DIR=$GITHUB_WORKSPACE/.ccache" >> "$GITHUB_ENV"
echo "CCACHE_BASEDIR=$GITHUB_WORKSPACE" >> "$GITHUB_ENV"
@@ -328,14 +356,19 @@ jobs:
steps:
- uses: actions/checkout@v7
with: { ref: '${{ env.REF }}' }
+ - name: Downloads (cmake/Fetch.cmake's archives and pinned tools, kept by hash by tools/ci/fetch.sh)
+ uses: actions/cache@v5
+ with:
+ path: .deps
+ key: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('cmake/Fetch.cmake', '.github/workflows/packages.yml') }}
+ restore-keys: deps-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-
- name: ccache (the release binary, pinned by hash, standing in for cl.exe)
+ shell: bash
+ run: tools/ci/fetch.sh https://github.com/ccache/ccache/releases/download/v4.14.2/ccache-4.14.2-windows-x86_64.zip 6993ce645e53192cec592ee23186200b574ac4c59097ecde8d9cfd681b47ae84
+ - name: ccache (unpacked, as cl.exe)
shell: pwsh
run: |
- $zip = 'ccache-4.14.2-windows-x86_64.zip'
- Invoke-WebRequest "https://github.com/ccache/ccache/releases/download/v4.14.2/$zip" -OutFile $zip
- if ((Get-FileHash $zip -Algorithm SHA256).Hash -ne '6993CE645E53192CEC592EE23186200B574AC4C59097ECDE8D9CFD681B47AE84') {
- throw 'ccache archive hash mismatch'
- }
+ $zip = '.deps\6993ce645e53192cec592ee23186200b574ac4c59097ecde8d9cfd681b47ae84-ccache-4.14.2-windows-x86_64.zip'
Expand-Archive $zip -DestinationPath $env:RUNNER_TEMP
$dir = "$env:RUNNER_TEMP\ccache-4.14.2-windows-x86_64"
"$dir" >> $env:GITHUB_PATH
diff --git a/.gitignore b/.gitignore
index ac4eef39..0a4f65fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ imgui.ini
Testing/
__pycache__/
build-flatpak/
+.deps/
.flatpak-builder/
*.flatpak
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bffd2d19..09af3387 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -623,9 +623,7 @@ include(CPack)
# --- Python module ---
if(SCULPTFORGE_BUILD_PYTHON)
find_package(Python 3.9 REQUIRED COMPONENTS Interpreter Development.Module)
- FetchContent_Declare(pybind11
- URL https://github.com/pybind/pybind11/archive/refs/tags/v3.0.4.tar.gz
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+ sf_fetch_declare(pybind11 DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
FetchContent_MakeAvailable(pybind11)
pybind11_add_module(sculptforge_python MODULE src/python/module.cpp)
set_target_properties(sculptforge_python PROPERTIES OUTPUT_NAME sculptforge)
@@ -763,6 +761,10 @@ if(SCULPTFORGE_BUILD_TESTS)
add_test(NAME release_workflows COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/release/check_workflows.py)
add_test(NAME release_workflows_self_test COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/release/check_workflows.py --self-test)
add_test(NAME release_paperwork COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/release/paperwork_only.py --self-test)
+ # Step bump pins tests/ui/whats_new.sfui to the newest What's New sections (tools/release/pin_whats_new_test.py).
+ add_test(NAME release_pin_whats_new COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/release/pin_whats_new_test.py --self-test)
+ # scripts/merge-queue.sh refuses a merge or squash that throws away the other side's change (tools/ci/no_revert.py).
+ add_test(NAME ci_no_revert COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/ci/no_revert.py --self-test)
# scripts/release.sh's beta (X.Y.Z-beta.N) and its promotion to stable, in a sandbox with stand-ins for gh and curl.
if(UNIX AND NOT APPLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
add_test(NAME release_script_beta COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/tests/release_beta_test.sh)
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index fa8515a1..fbd8af2e 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1,12 +1,10 @@
# Third-party dependencies. Everything is fetched at configure time so a fresh
# checkout builds the same way on Linux, macOS and Windows.
-include(FetchContent)
+include(${CMAKE_CURRENT_LIST_DIR}/Fetch.cmake) # include(FetchContent), the pins, sf_fetch_declare
set(FETCHCONTENT_QUIET ON)
# glm (header-only maths)
-FetchContent_Declare(glm
- URL https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+sf_fetch_declare(glm DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
set(GLM_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLM_BUILD_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(glm)
@@ -23,9 +21,7 @@ if(SDL3_FOUND)
message(STATUS "Using system SDL3 ${SDL3_VERSION}")
else()
message(STATUS "Fetching SDL3")
- FetchContent_Declare(SDL3
- URL https://github.com/libsdl-org/SDL/releases/download/release-3.2.30/SDL3-3.2.30.tar.gz
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+ sf_fetch_declare(SDL3 DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
# Static: release packages then need no separate SDL library (zlib licence allows this).
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
set(SDL_STATIC ON CACHE BOOL "" FORCE)
@@ -35,9 +31,7 @@ else()
endif()
# Dear ImGui (UI) with the SDL3 + OpenGL3 backends
-FetchContent_Declare(imgui
- URL https://github.com/ocornut/imgui/archive/refs/tags/v1.91.9.tar.gz
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+sf_fetch_declare(imgui DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
FetchContent_MakeAvailable(imgui)
add_library(imgui STATIC
diff --git a/cmake/Fetch.cmake b/cmake/Fetch.cmake
new file mode 100644
index 00000000..44c0b3f3
--- /dev/null
+++ b/cmake/Fetch.cmake
@@ -0,0 +1,80 @@
+# Every third-party archive the build fetches, pinned by SHA-256 (the Flatpak manifest pins the same ones), and the
+# one way it fetches them: sf_fetch_declare(<name> [FetchContent_Declare options]).
+# The archive is downloaded once into SF_DEPS_CACHE (environment, relative to the source tree; default
+# <build>/_deps/downloads), retried with backoff (CMake's own download gives up on the first HTTP error: 0.11.1's
+# packages died on GitHub 504s), checked against its hash, and FetchContent then extracts the local copy. CI caches
+# that folder keyed by this file's hash (actions/cache, key deps-<hash of cmake/Fetch.cmake>).
+include(FetchContent)
+
+set(SF_PIN_glm https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
+ 9f3174561fd26904b23f0db5e560971cbf9b3cbda0b280f04d5c379d03bf234c)
+set(SF_PIN_SDL3 https://github.com/libsdl-org/SDL/releases/download/release-3.2.30/SDL3-3.2.30.tar.gz
+ 4c3b09330d866dc52eb65b66259a6684ad387252ca8c57901b3a2b534eb42e3d)
+set(SF_PIN_imgui https://github.com/ocornut/imgui/archive/refs/tags/v1.91.9.tar.gz
+ 3872a5f90df78fced023c1945f4466b654fd74573370b77b17742149763a7a7c)
+set(SF_PIN_mbedtls https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.7/mbedtls-3.6.7.tar.bz2
+ a7e8bcbec0e6f761b4af24f25677626b35f762f68eef79c08677a363212d11f6)
+set(SF_PIN_libdatachannel https://github.com/paullouisageneau/libdatachannel/archive/refs/tags/v0.24.6.tar.gz
+ 22a66aebebd8dae561d8e5181da96f2fcc203e067c5b2186c07b39af913464c0)
+set(SF_PIN_ldc_usrsctp https://github.com/paullouisageneau/usrsctp/archive/fec583d54493f879d2ae44a743423bf8a04371ab.tar.gz
+ e5c114afe73c9a0ec419fab5f5b3f63f3ce57b09b90d06ea85e63dca8aed3e7c)
+set(SF_PIN_ldc_libjuice https://github.com/paullouisageneau/libjuice/archive/b89c792e3612faf2f12cf35bcc56857313a06be3.tar.gz
+ 713b22174e8cb2e06538fa9bac2650bda21b83c86f5128813ab4dcf8f5bea9ed)
+set(SF_PIN_ldc_plog https://github.com/SergiusTheBest/plog/archive/94899e0b926ac1b0f4750bfbd495167b4a6ae9ef.tar.gz
+ 92a08bce559b5f28aa88d3fd9071567414b9f43a83fe2a05a6dd14f1da536072)
+set(SF_PIN_pybind11 https://github.com/pybind/pybind11/archive/refs/tags/v3.0.4.tar.gz
+ 74b6a2c2b4573a400cafb6ecbf60c98df300cd3d0041296b913d02b2cbbb2676)
+
+function(sf_fetch_declare name)
+ if(NOT DEFINED SF_PIN_${name})
+ message(FATAL_ERROR "sf_fetch_declare(${name}): no SF_PIN_${name} (URL and SHA-256) in cmake/Fetch.cmake")
+ endif()
+ list(GET SF_PIN_${name} 0 url)
+ list(GET SF_PIN_${name} 1 sha)
+ string(TOUPPER "${name}" upper)
+ if(FETCHCONTENT_SOURCE_DIR_${upper} OR FETCHCONTENT_FULLY_DISCONNECTED)
+ # A packager's own sources (Flatpak, AUR: offline builds): FetchContent uses those, nothing is downloaded.
+ FetchContent_Declare(${name} URL "${url}" URL_HASH SHA256=${sha} ${ARGN})
+ return()
+ endif()
+ set(dir "$ENV{SF_DEPS_CACHE}")
+ if(dir STREQUAL "")
+ set(dir "${CMAKE_BINARY_DIR}/_deps/downloads")
+ endif()
+ get_filename_component(dir "${dir}" ABSOLUTE BASE_DIR "${CMAKE_SOURCE_DIR}") # CI: SF_DEPS_CACHE=.deps
+ get_filename_component(base "${url}" NAME)
+ set(file "${dir}/${sha}-${base}") # the hash in the name: a changed pin never reuses an old file
+ set(have "")
+ if(EXISTS "${file}")
+ file(SHA256 "${file}" have)
+ endif()
+ if(NOT have STREQUAL sha)
+ file(MAKE_DIRECTORY "${dir}")
+ set(why "")
+ foreach(wait 0 5 15 30 60)
+ if(wait)
+ message(STATUS "${name}: ${why}; retrying in ${wait} s")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${wait})
+ endif()
+ file(DOWNLOAD "${url}" "${file}.part" STATUS st INACTIVITY_TIMEOUT 60 TIMEOUT 600)
+ list(GET st 0 code)
+ if(code EQUAL 0)
+ file(SHA256 "${file}.part" have)
+ if(have STREQUAL sha)
+ file(RENAME "${file}.part" "${file}")
+ break()
+ endif()
+ set(why "SHA-256 ${have}, expected ${sha}")
+ break() # a different file, not a network hiccup: no retry
+ else()
+ list(GET st 1 msg)
+ set(why "download failed (${code}: ${msg})")
+ endif()
+ endforeach()
+ if(NOT have STREQUAL sha)
+ file(REMOVE "${file}.part")
+ message(FATAL_ERROR "${name}: ${url}: ${why}")
+ endif()
+ endif()
+ FetchContent_Declare(${name} URL "${file}" URL_HASH SHA256=${sha} ${ARGN})
+endfunction()
diff --git a/cmake/WebRTC.cmake b/cmake/WebRTC.cmake
index 8add16d1..769d41a3 100644
--- a/cmake/WebRTC.cmake
+++ b/cmake/WebRTC.cmake
@@ -2,24 +2,14 @@
# -DSCULPTFORGE_WEBRTC=OFF builds without it (the phone link then offers capture and AR only).
# libdatachannel (MPL-2.0) with libjuice (MPL-2.0), usrsctp (BSD-3-Clause), plog (MIT) and Mbed TLS (Apache-2.0),
# all static and fetched at configure time like the other dependencies. No media (SRTP) and no WebSocket parts.
-include(FetchContent)
+include(${CMAKE_CURRENT_LIST_DIR}/Fetch.cmake) # include(FetchContent), the pins, sf_fetch_declare
-FetchContent_Declare(mbedtls
- URL https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.7/mbedtls-3.6.7.tar.bz2
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
-FetchContent_Declare(libdatachannel
- URL https://github.com/paullouisageneau/libdatachannel/archive/refs/tags/v0.24.6.tar.gz
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+sf_fetch_declare(mbedtls DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+sf_fetch_declare(libdatachannel DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
# libdatachannel's submodules, at the commits its v0.24.6 tag pins (GitHub archives leave submodules out).
-FetchContent_Declare(ldc_usrsctp
- URL https://github.com/paullouisageneau/usrsctp/archive/fec583d54493f879d2ae44a743423bf8a04371ab.tar.gz
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
-FetchContent_Declare(ldc_libjuice
- URL https://github.com/paullouisageneau/libjuice/archive/b89c792e3612faf2f12cf35bcc56857313a06be3.tar.gz
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
-FetchContent_Declare(ldc_plog
- URL https://github.com/SergiusTheBest/plog/archive/94899e0b926ac1b0f4750bfbd495167b4a6ae9ef.tar.gz
- DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+sf_fetch_declare(ldc_usrsctp DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+sf_fetch_declare(ldc_libjuice DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
+sf_fetch_declare(ldc_plog DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
foreach(dep mbedtls libdatachannel ldc_usrsctp ldc_libjuice ldc_plog)
FetchContent_GetProperties(${dep})
diff --git a/docs/merge-queue.md b/docs/merge-queue.md
index f068b9de..26312206 100644
--- a/docs/merge-queue.md
+++ b/docs/merge-queue.md
@@ -22,6 +22,12 @@ comment and the `queue-failed` label; its author fixes the branch and queues it
`--serial` (update each PR from main, wait for its checks, merge), which isolates the PR that broke it.
`scripts/merge-queue.sh list` shows the queue.
+Every landing (batch, serial, staging) first runs `tools/ci/no_revert.py` on its merges: a merge or squash that
+throws a side's change away whole (the result keeps the other side's file or the old one, though that side's commit
+still applies to it) is refused with the files listed, as 0.11.1's quick-remesh merge nearly reverted main's newer
+fix. Redo it keeping both sides; a deliberate revert lands with `SF_ALLOW_REVERT=<its commit>`.
+`scripts/merge-queue.sh no-revert BASE..TIP` checks a range by hand.
+
The merger's own batch (branches merged without pull requests, `~/Work/.sf/merge-batch.sh`) lands the same way with
`scripts/merge-queue.sh staging --with ~/Work/.sf/t1.sh HEAD`. The batch goes to the branch `staging`, the full CI runs
there while the PC runs the whole suite, and main fast-forwards when both pass. Either way, CI's run on main finds the
diff --git a/docs/releasing.md b/docs/releasing.md
index b12cd5d0..abfa0011 100644
--- a/docs/releasing.md
+++ b/docs/releasing.md
@@ -22,14 +22,15 @@ the gates, what each step does, and how to recover.
2. **Version and words**:
- written by people, on main before the release: one note fragment per branch, `changes/<branch>.md`
(changes/README.md: the What's New bullet, CHANGELOG entry and section, highlight, #testers bullets); in
- docs/guide/whats-new.md `## Version X.Y.Z`, with tests/ui/whats_new.sfui expecting it, its ```features block
+ docs/guide/whats-new.md `## Version X.Y.Z` and its ```features block
(date: unreleased, a tagline, highlights and cards: the app's What's New window, the guide, and the home page's
card and lede come from it). The 3-5 feed highlights are the version's `highlight:` lines (What's New and
fragments), or `HIGHLIGHTS=file` to override;
- set by step `bump`: the fragments go into CHANGELOG `[Unreleased]` and What's New and are deleted
(tools/release/assemble_notes.py); the version in CMakeLists.txt, CITATION.cff (with date-released), packaging/rez/package.py
and the metainfo `<release>`; CHANGELOG `[Unreleased]` becomes `## [X.Y.Z] - date` under a new empty
- `[Unreleased]`; website/guide is rebuilt. Don't bump version files by hand.
+ `[Unreleased]`; tests/ui/whats_new.sfui is pinned to the newest three sections (tools/release/pin_whats_new_test.py);
+ website/guide is rebuilt. Don't bump version files by hand.
Step `check` verifies all of this, plus what the steps after the tag need (PKGBUILD format, the Homebrew tap, the
Omarchy PR is open, the home page's version text), so nothing stops after the tag for a reason known before it.
@@ -209,8 +210,10 @@ private, in one private repository per studio.
## When a step fails
-The script stops with a line starting `fix:` and the command to resume (`--from <step>`). Fix that one thing, then
-resume. Every step checks what is already done first, so re-running is always safe. Fix problems as they come;
+The script stops with a line starting `fix:` and the exact command to resume (`--from <step> --yes`, with this run's
+HIGHLIGHTS and BUILD_DIR). Fix that one thing, then resume. A CI or Packages run that failed on an HTTP 5xx download
+is rerun once by step `ci` before it stops (the downloads themselves retry and are cached: cmake/Fetch.cmake,
+tools/ci/fetch.sh). Every step checks what is already done first, so re-running is always safe. Fix problems as they come;
don't pile them up for later.
| failure | do |
diff --git a/packaging/flatpak/build.sh b/packaging/flatpak/build.sh
index 311ff873..de35c2dd 100755
--- a/packaging/flatpak/build.sh
+++ b/packaging/flatpak/build.sh
@@ -17,12 +17,20 @@ version=$(sed -n 's/^project(SculptForge VERSION \([0-9.]*\).*/\1/p' "$root/CMak
arch=$(flatpak --default-arch)
work=$root/build-flatpak
-flatpak --user remote-add --if-not-exists flathub "$flathub"
# --disable-rofiles-fuse: CI runners and containers often have no FUSE.
# SF_FLATPAK_CCACHE=1: compile through the SDK's ccache, kept in $work/state/ccache (CI restores and saves that folder).
ccache=
[ "${SF_FLATPAK_CCACHE:-}" = 1 ] && ccache=--ccache
-flatpak-builder --user --install-deps-from=flathub --force-clean --disable-rofiles-fuse --default-branch=stable $ccache \
+# The runtime, SDK and the manifest's sources first, retried with backoff (a GitHub 504 on one archive failed 0.11.1's
+# Flatpak); the downloads stay in $work/state/downloads (CI caches it), so the build itself downloads nothing.
+for wait in 0 15 60 120 x; do
+ [ "$wait" != x ] || { echo "flatpak-builder: the downloads failed 4 times" >&2; exit 1; }
+ sleep "$wait"
+ flatpak --user remote-add --if-not-exists flathub "$flathub" &&
+ flatpak-builder --user --install-deps-from=flathub --download-only --force-clean --disable-rofiles-fuse \
+ --state-dir="$work/state" "$work/app" "$here/$id.yml" && break
+done
+flatpak-builder --user --install-deps-from=flathub --disable-download --force-clean --disable-rofiles-fuse --default-branch=stable $ccache \
--state-dir="$work/state" --repo="$work/repo" "$work/app" "$here/$id.yml"
bundle="$out/SculptForge-$version-$arch.flatpak"
flatpak build-bundle --runtime-repo="$flathub" "$work/repo" "$bundle" "$id" stable
diff --git a/packaging/flatpak/org.sculptforge.SculptForge.yml b/packaging/flatpak/org.sculptforge.SculptForge.yml
index 5558135d..a9552727 100644
--- a/packaging/flatpak/org.sculptforge.SculptForge.yml
+++ b/packaging/flatpak/org.sculptforge.SculptForge.yml
@@ -65,6 +65,7 @@ modules:
- website/gallery
- .flatpak-builder
- build-flatpak
+ - .deps # CI's download cache (cmake/Fetch.cmake)
- repo
- type: archive
url: https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
diff --git a/packaging/linux/build-appimage.sh b/packaging/linux/build-appimage.sh
index 222f1d80..b422b084 100755
--- a/packaging/linux/build-appimage.sh
+++ b/packaging/linux/build-appimage.sh
@@ -5,7 +5,10 @@
#
# ARCH is x86_64 or aarch64. Writes OUTDIR/SculptForge-VERSION-ARCH.AppImage and its .zsync (update information
# for AppImageUpdate and similar tools: the newest GitHub release). LINUXDEPLOY and APPIMAGETOOL may name tools
-# already downloaded; otherwise the continuous builds are fetched.
+# already downloaded. Otherwise they are fetched with retries into SF_APPIMAGE_TOOLS (CI caches that folder; default
+# a temporary one): appimagetool and the AppImage runtime it embeds at tagged releases, pinned by SHA-256 (given with
+# --runtime-file, so appimagetool downloads nothing itself: 0.11.1's arm64 AppImage died on a GitHub 504 there),
+# linuxdeploy its continuous build.
#
# linuxdeploy bundles the libraries. The AppDir's root then gets real PNG icons, not links to the SVG that
# linuxdeploy picks: AppImage managers (AppManager, Gear Lever) and thumbnailers read the root icon and .DirIcon
@@ -19,16 +22,38 @@ mkdir -p "$4"
OUTDIR=$(cd "$4" && pwd)
SRC=$(cd "$(dirname "$0")/../.." && pwd)
ID=org.sculptforge.SculptForge
-TOOLS=$(mktemp -d)
-trap 'rm -rf "$TOOLS"' EXIT
+if [ -n "${SF_APPIMAGE_TOOLS:-}" ]; then
+ mkdir -p "$SF_APPIMAGE_TOOLS"
+ TOOLS=$(cd "$SF_APPIMAGE_TOOLS" && pwd)
+else
+ TOOLS=$(mktemp -d)
+ trap 'rm -rf "$TOOLS"' EXIT
+fi
-fetch() { # tool name, URL
- curl -fsSLo "$TOOLS/$1" "$2"
- chmod +x "$TOOLS/$1"
- echo "$TOOLS/$1"
+sha256() { sha256sum "$1" | cut -d' ' -f1; }
+fetch() { # file name, URL [, SHA-256]: a kept copy when it is there (and matches), else downloaded with retries
+ f=$TOOLS/$1
+ if [ ! -s "$f" ] || { [ -n "${3:-}" ] && [ "$(sha256 "$f")" != "$3" ]; }; then
+ curl -fsSL --retry 6 --retry-delay 15 --retry-all-errors --connect-timeout 30 -o "$f.part" "$2" || { echo "can't download $2" >&2; exit 1; }
+ if [ -n "${3:-}" ] && [ "$(sha256 "$f.part")" != "$3" ]; then
+ echo "$2: SHA-256 $(sha256 "$f.part"), expected $3" >&2
+ exit 1
+ fi
+ mv "$f.part" "$f"
+ fi
+ chmod +x "$f"
+ echo "$f"
}
-LINUXDEPLOY=${LINUXDEPLOY:-$(fetch linuxdeploy "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-$ARCH.AppImage")}
-APPIMAGETOOL=${APPIMAGETOOL:-$(fetch appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$ARCH.AppImage")}
+case $ARCH in
+ x86_64) tool_sum=ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3cb384eb0
+ runtime_sum=2fca8b443c92510f1483a883f60061ad09b46b978b2631c807cd873a47ec260d ;;
+ aarch64) tool_sum=f0837e7448a0c1e4e650a93bb3e85802546e60654ef287576f46c71c126a9158
+ runtime_sum=00cbdfcf917cc6c0ff6d3347d59e0ca1f7f45a6df1a428a0d6d8a78664d87444 ;;
+ *) echo "unknown ARCH $ARCH (x86_64 or aarch64)" >&2; exit 2 ;;
+esac
+LINUXDEPLOY=${LINUXDEPLOY:-$(fetch linuxdeploy-$ARCH "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-$ARCH.AppImage")}
+APPIMAGETOOL=${APPIMAGETOOL:-$(fetch appimagetool-1.9.1-$ARCH "https://github.com/AppImage/appimagetool/releases/download/1.9.1/appimagetool-$ARCH.AppImage" $tool_sum)}
+RUNTIME=$(fetch runtime-20251108-$ARCH "https://github.com/AppImage/type2-runtime/releases/download/20251108/runtime-$ARCH" $runtime_sum)
# 1. Libraries, AppRun, the root .desktop file (no AppImage yet).
"$LINUXDEPLOY" --appimage-extract-and-run --appdir "$APPDIR" \
@@ -49,7 +74,7 @@ done
# 3. The AppImage. appimagetool checks the AppDir first (.DirIcon, the .desktop file) and stops on a problem.
cd "$OUTDIR"
OUT="SculptForge-$VERSION-$ARCH.AppImage"
-ARCH=$ARCH VERSION=$VERSION "$APPIMAGETOOL" --appimage-extract-and-run \
+ARCH=$ARCH VERSION=$VERSION "$APPIMAGETOOL" --appimage-extract-and-run --runtime-file "$RUNTIME" \
-u "gh-releases-zsync|islandmed|SculptForge|latest|SculptForge-*-$ARCH.AppImage.zsync" "$APPDIR" "$OUT"
[ -f "$OUT" ] && [ -f "$OUT.zsync" ] || { echo "appimagetool made no $OUT (and .zsync)" >&2; exit 1; }
echo "$OUTDIR/$OUT"
diff --git a/packaging/upstream.json b/packaging/upstream.json
index a1fddcc7..f087bf4f 100644
--- a/packaging/upstream.json
+++ b/packaging/upstream.json
@@ -23,9 +23,9 @@
{"name": "Godot", "version": "4.7", "track": "minor", "source": {"kind": "github", "repo": "godotengine/godot", "tag": "^(\\d+(?:\\.\\d+)*)-stable$"},
"notes": "https://godotengine.org/releases/{major}.{minor}/"},
{"name": "SDL3", "version": "3.2", "track": "minor", "source": {"kind": "github", "repo": "libsdl-org/SDL", "tag": "^release-(3\\.\\d+\\.\\d+)$"},
- "why": "Pinned in cmake/Dependencies.cmake (3.2.30)."},
+ "why": "Pinned in cmake/Fetch.cmake (3.2.30)."},
{"name": "Dear ImGui", "version": "1.91.9", "source": {"kind": "github", "repo": "ocornut/imgui"},
- "why": "Pinned in cmake/Dependencies.cmake."},
+ "why": "Pinned in cmake/Fetch.cmake."},
{"name": "Python", "version": "3.13", "track": "minor", "source": {"kind": "endoflife", "product": "python"},
"notes": "https://docs.python.org/{major}.{minor}/whatsnew/{major}.{minor}.html",
"why": "The module follows the VFX Reference Platform's Python; test it on the new version, switch when the platform does."}
diff --git a/scripts/merge-queue.sh b/scripts/merge-queue.sh
index 31453d5b..f0b684e4 100755
--- a/scripts/merge-queue.sh
+++ b/scripts/merge-queue.sh
@@ -9,6 +9,10 @@
# scripts/merge-queue.sh add <pr>... queue pull requests (label "queue"); any session may do this
# scripts/merge-queue.sh list the queue, oldest first, with each PR's check state
# scripts/merge-queue.sh run [--serial] land the queue (the coordinator, in the background)
+# scripts/merge-queue.sh no-revert BASE..TIP | --merge C | --squash RESULT BRANCH
+# the check every landing runs (tools/ci/no_revert.py): no merge or squash
+# may throw away a side's change whole (0.11.1's quick-remesh near-revert);
+# a deliberate revert lands with SF_ALLOW_REVERT=<its commit>
# scripts/merge-queue.sh staging [--with CMD] [REF] the merger's batch (T2, docs/testing-flow.md): REF (default HEAD,
# main merged into it) goes to the branch `staging`, the full CI runs there
# while CMD runs here (e.g. '~/Work/.sf/pc.sh .', T1), and when both pass main
@@ -83,6 +87,12 @@ run_serial() {
drop "$pr" "Its checks failed on top of main."
continue
fi
+ git fetch -q origin main "pull/$pr/head"
+ if ! out=$(python3 tools/ci/no_revert.py origin/main..FETCH_HEAD); then
+ echo "$out" | sed 's/^/ /'
+ drop "$pr" "A merge in it throws away changes from main (tools/ci/no_revert.py): $(echo "$out" | head -3 | tr '\n' ' ')"
+ continue
+ fi
gh pr merge "$pr" -R "$REPO" --merge --delete-branch >/dev/null
echo " merged #$pr"
done
@@ -107,7 +117,13 @@ run_batch() {
head=$(gh pr view "$pr" -R "$REPO" --json headRefName -q .headRefName)
git fetch -q origin "$head"
if git -C "$wt" merge -q --no-ff --no-edit -m "Merge $head (#$pr)" FETCH_HEAD >/dev/null 2>&1; then
- merged+=("$pr")
+ if out=$(cd "$wt" && python3 tools/ci/no_revert.py "$base..HEAD"); then
+ merged+=("$pr")
+ else
+ git -C "$wt" reset -q --hard HEAD~1
+ echo "$out" | sed 's/^/ /'
+ drop "$pr" "It throws away changes from main (tools/ci/no_revert.py): $(echo "$out" | head -3 | tr '\n' ' ')"
+ fi
else
git -C "$wt" merge --abort
drop "$pr" "It conflicts with main or with a PR ahead of it in the queue."
@@ -149,6 +165,8 @@ land_staging() { # land_staging [--with CMD] [REF]
git merge-base --is-ancestor origin/main "$sha" ||
die "$ref does not contain origin/main: merge origin/main into it first (main must fast-forward to the tested commit)"
[ "$sha" != "$(git rev-parse origin/main)" ] || { echo "main is already at ${sha:0:8}"; return 0; }
+ python3 tools/ci/no_revert.py "origin/main..$sha" ||
+ die "a merge in the batch throws away changes from the other side (above): redo it keeping both, or SF_ALLOW_REVERT=<commit> for a deliberate revert"
t0=$(date +%s)
say "staging ${sha:0:8} ($(git log -1 --format=%s "$sha" | cut -c1-60)) on main $(git rev-parse --short origin/main)"
git push -q --force origin "$sha:refs/heads/staging"
@@ -173,6 +191,10 @@ land_staging() { # land_staging [--with CMD] [REF]
}
case ${1:-} in
+no-revert)
+ shift
+ python3 tools/ci/no_revert.py "$@"
+ ;;
staging)
shift
land_staging "$@"
@@ -196,7 +218,7 @@ run)
if [ "${2:-}" = --serial ]; then run_serial; else run_batch; fi
;;
*)
- sed -n '5,23p' "$0" | sed 's/^# \{0,1\}//'
+ sed -n '5,27p' "$0" | sed 's/^# \{0,1\}//'
exit 2
;;
esac
diff --git a/scripts/release.sh b/scripts/release.sh
index 2c2b3370..633770f2 100755
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -44,11 +44,17 @@ STEPS=(bump check ci tag release site aur brew omarchy replies status)
red() { printf '\033[1;31m%s\033[0m\n' "$*" >&2; }
say() { printf '\033[1m== %s\033[0m\n' "$*"; }
ok() { printf ' ok: %s\n' "$*"; }
+# resume STEP: the exact command that continues at STEP, with this run's HIGHLIGHTS, BUILD_DIR and --yes (a stopped
+# release is one the owner already said ship it for; without --yes, step tag would stop again at "not confirmed").
+resume() {
+ printf '%s%sscripts/release.sh %s --from %s --yes' "${HIGHLIGHTS_GIVEN:+HIGHLIGHTS=$HIGHLIGHTS_GIVEN }" \
+ "${BUILD_DIR:+BUILD_DIR=$BUILD_DIR }" "$V" "$1"
+}
# die "what is wrong" "the exact fix"
die() {
red "STOPPED at step '$CURRENT': $1"
printf ' fix: %s\n' "$2" >&2
- printf ' then: scripts/release.sh %s --from %s\n' "$V" "$CURRENT" >&2
+ printf ' then: %s\n' "$(resume "$CURRENT")" >&2
exit 1
}
sha256() { if command -v sha256sum >/dev/null; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi; }
@@ -84,6 +90,7 @@ TODAY=$(date +%F)
CURRENT=setup
# HIGHLIGHTS may be relative to where the script was started; the script works from the top of the checkout.
case ${HIGHLIGHTS:-} in ''|/*) ;; *) HIGHLIGHTS=$PWD/$HIGHLIGHTS ;; esac
+HIGHLIGHTS_GIVEN=${HIGHLIGHTS:-} # preflight may fill HIGHLIGHTS with a file of its own; resume names only this one
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
cd "$(git rev-parse --show-toplevel)"
@@ -101,7 +108,7 @@ push_main() {
}
release_ready() {
gh release view "$T" -R "$RELEASE_REPO" --json assets -q '.assets[].name' > "$work/assets" 2>/dev/null ||
- die "no GitHub release $T yet" "run the earlier steps: scripts/release.sh $V --from tag"
+ die "no GitHub release $T yet" "run the earlier steps: $(resume tag)"
grep -qx SHA256SUMS.txt "$work/assets" || die "release $T has no SHA256SUMS.txt (unfinished)" "re-run the Release workflow: gh workflow run release.yml -R $REPO -f tag=$T"
# One-click update (src/core/SelfUpdate.h): once the app has a key, every release must carry the signature.
if grep -q 'kUpdatePublicKeyHex = "[0-9a-f]\{64\}"' src/core/SelfUpdate.h 2>/dev/null; then
@@ -123,10 +130,14 @@ tarball_sha() {
die "can't download the $T source tarball" "check that the tag is pushed: git ls-remote origin $T"
sha256 "$work/src.tar.gz"
}
+# server_error < log: the log shows an HTTP 5xx answer (curl, git, uv, flatpak-builder, FetchContent phrasings).
+server_error() {
+ grep -Eiq '(HTTP/[0-9.]+|HTTP status code|status code:?|error:|returned error:|response code) ?5[0-9]{2}\b|\b50[234] (Gateway Time-?out|Bad Gateway|Service Unavailable)\b'
+}
# Successful run of a workflow on a push to main for a commit; waits for one in progress. The third argument is how
# many 10-second tries a just-pushed commit's run gets to appear (default 1).
wait_run() {
- local wf=$1 sha=$2 tries=${3:-1} id="" status conclusion
+ local wf=$1 sha=$2 tries=${3:-1} id="" status conclusion rerun_done=""
while :; do
id=$(gh run list -R "$REPO" -w "$wf" -c "$sha" -e push -b main -L 1 --json databaseId -q '.[0].databaseId')
tries=$((tries - 1))
@@ -140,6 +151,15 @@ wait_run() {
gh run watch "$id" -R "$REPO" --exit-status >/dev/null || true
fi
conclusion=$(gh run view "$id" -R "$REPO" --json conclusion -q .conclusion)
+ # A job that died on a GitHub/CDN 5xx while downloading (0.11.1: seven 504s in Packages) is rerun once, then judged.
+ if [ "$conclusion" = failure ] && [ -z "$rerun_done" ] && gh run view "$id" -R "$REPO" --log-failed 2>/dev/null | server_error; then
+ echo " $wf run $id failed on an HTTP 5xx download: rerunning its failed jobs once" >&2
+ rerun_done=1
+ gh run rerun "$id" --failed -R "$REPO" >/dev/null 2>&1 || true
+ sleep 10
+ gh run watch "$id" -R "$REPO" --exit-status >/dev/null 2>&1 || true
+ conclusion=$(gh run view "$id" -R "$REPO" --json conclusion -q .conclusion)
+ fi
[ "$conclusion" = success ] ||
die "$wf run $id on $sha: $conclusion (https://github.com/$REPO/actions/runs/$id)" \
"fix it on a branch, merge to main, then start again from step check (or re-run the run if it was a runner hiccup: gh run rerun $id --failed -R $REPO)"
@@ -193,13 +213,13 @@ highlights_ok() {
[ "$n" -ge 3 ] && [ "$n" -le 5 ]
}
highlights_fix="write 3-5 one-line highlights (what users get) to a file and run again with HIGHLIGHTS=that-file"
-# The words people write for What's New: the guide section and the UI test that expects it.
+# The words people write for What's New: the guide section and (after step bump wrote it) the UI test's pin to it.
words_ok() {
python3 tools/release/assemble_notes.py --check >/dev/null || die "a note fragment in changes/ doesn't parse: $(python3 tools/release/assemble_notes.py --check 2>&1)" "fix it (changes/README.md has the format), commit, push main"
grep -q "^## Version ${BASE//./\\.}\$" docs/guide/whats-new.md || grep -qs '^whats_new:' changes/*.md ||
die "docs/guide/whats-new.md has no '## Version $BASE'" "write that section at the top (Help > What's New shows it), commit, push main"
- grep -qF "expect_text \"Version $BASE\"" tests/ui/whats_new.sfui ||
- die "tests/ui/whats_new.sfui doesn't check Version $BASE" "update its first expect_text lines to the new section (the version and one line from it), commit, push main"
+ [ "${1:-}" = bump ] || python3 tools/release/pin_whats_new_test.py "$BASE" --check >/dev/null ||
+ die "tests/ui/whats_new.sfui isn't pinned to $BASE's What's New" "run step bump (it pins it): $(resume bump)"
}
# UI scale / DPI (#87): the Windows manifest still asks for per-monitor DPI v2, and the "dpi" UI tests (100-200 %, a
# display-scale event) pass on main's build. BUILD_DIR (default build) is the coordinator's tree, already built for
@@ -210,7 +230,7 @@ dpi_ok() {
grep -q '<dpiAwareness[^>]*>PerMonitorV2' packaging/windows/sculptforge.manifest 2>/dev/null &&
grep -q 'packaging/windows/sculptforge.manifest' CMakeLists.txt ||
die "the Windows build no longer declares per-monitor DPI v2" "restore packaging/windows/sculptforge.manifest and its target_sources line in CMakeLists.txt (git log -p -- packaging/windows)"
- [ -f "$b/CTestTestfile.cmake" ] || die "no build tree at $b for the DPI UI tests" "cmake -S . -B $b -DCMAKE_BUILD_TYPE=Release, or BUILD_DIR=<your build> scripts/release.sh $V --from check"
+ [ -f "$b/CTestTestfile.cmake" ] || die "no build tree at $b for the DPI UI tests" "cmake -S . -B $b -DCMAKE_BUILD_TYPE=Release, or run again with BUILD_DIR=<your build>"
"${heavy[@]}" cmake --build "$b" --target sculptforge -j3 >/dev/null || die "the app doesn't build in $b" "cmake --build $b --target sculptforge and fix the error"
SDL_APP_ID=sculptforge-agent "${heavy[@]}" ctest --test-dir "$b" -L dpi --output-on-failure >"$b/release-dpi.log" 2>&1 ||
die "the UI scale / DPI tests fail (ctest -L dpi; log: $b/release-dpi.log)" "fix them on a branch, merge to main, run again from step check"
@@ -236,7 +256,7 @@ preflight() {
command -v sha256sum >/dev/null || command -v shasum >/dev/null || die "no sha256sum or shasum" "install coreutils"
auth=$(gh auth status 2>&1 || true)
grep -q "account $AUTHOR_NAME" <<<"$auth" || die "gh is not logged in as $AUTHOR_NAME" "gh auth login (or gh auth switch -u $AUTHOR_NAME)"
- words_ok
+ words_ok "$mode"
grep -q '^set(SCULPTFORGE_PRERELEASE "[a-z0-9.]*")$' CMakeLists.txt ||
die "CMakeLists.txt lost its set(SCULPTFORGE_PRERELEASE \"\") line that step bump sets" "restore it under project() (git log -p CMakeLists.txt), commit"
python3 -c 'import json, sys; json.load(open(sys.argv[1]))' website/latest.json 2>/dev/null || die "website/latest.json is not valid JSON" "fix it, commit"
@@ -303,6 +323,9 @@ step_bump() {
# Note fragments (changes/<branch>.md) into CHANGELOG [Unreleased] and What's New X.Y.Z; the fragments go.
out=$(python3 tools/release/assemble_notes.py "$BASE" --apply 2>&1) || die "$out" "fix that fragment in changes/, commit, push main"
grep -q 'written' <<<"$out" && echo "$out" | sed 's/^/ notes: /'
+ # The What's New UI test checks the guide's newest three sections: pinned here to this version's.
+ out=$(python3 tools/release/pin_whats_new_test.py "$BASE" 2>&1) || die "$out" "fix docs/guide/whats-new.md (its newest section must be '## Version $BASE'), commit, push main"
+ [ -n "$out" ] && echo " pinned: $out"
out=$(python3 - "$BASE" "$TODAY" "$PRE" <<'PY'
import re, sys
v, today, pre = sys.argv[1:]
@@ -378,7 +401,7 @@ PY
python3 tools/guide/build_site.py >/dev/null # the guide, and the home page's What's New area for $V (not a beta's)
[ -n "$PRE" ] || card_ok || die "website/index.html has no 'new in $V' card after build_site.py" "$card_fix"
git add CMakeLists.txt CITATION.cff packaging/rez/package.py packaging/linux/org.sculptforge.SculptForge.metainfo.xml CHANGELOG.md website/index.html docs/guide/whats-new.md
- git add -A changes
+ git add -A changes tests/ui/whats_new.sfui
git add -A website/guide
if git diff --cached --quiet; then
ok "every version file already says $V and the guide is built"
@@ -408,7 +431,7 @@ step_check() {
[ -z "$(git status --porcelain -- website/guide website/index.html)" ] ||
die "website/guide is not rebuilt from docs/guide, or the home page changed (a beta leaves it alone)" "$bump"
if git rev-parse -q --verify "refs/tags/$T" >/dev/null && [ "$(git rev-list -n1 "$T")" != "$(git rev-parse HEAD)" ]; then
- die "$T already tags $(git rev-list -n1 "$T"), not main's $(git rev-parse --short HEAD)" "if that is the beta, continue: scripts/release.sh $V --from release; if not, use the next number ($BASE-${PRE%.*}.$((${PRE##*.} + 1)))"
+ die "$T already tags $(git rev-list -n1 "$T"), not main's $(git rev-parse --short HEAD)" "if that is the beta, continue: $(resume release); if not, use the next number ($BASE-${PRE%.*}.$((${PRE##*.} + 1)))"
fi
ok "CMakeLists.txt says $BASE $PRE and the guide is built at $(git rev-parse --short HEAD)"
dpi_ok
@@ -422,7 +445,7 @@ step_check() {
python3 tools/guide/build_site.py >/dev/null
[ -z "$(git status --porcelain -- website/guide)" ] || die "website/guide is not rebuilt from docs/guide" "$bump"
if git rev-parse -q --verify "refs/tags/$T" >/dev/null && [ "$(git rev-list -n1 "$T")" != "$(git rev-parse HEAD)" ]; then
- die "$T already tags $(git rev-list -n1 "$T"), not main's $(git rev-parse --short HEAD)" "if that is the release, continue: scripts/release.sh $V --from release; if not, pick the next version"
+ die "$T already tags $(git rev-list -n1 "$T"), not main's $(git rev-parse --short HEAD)" "if that is the release, continue: $(resume release); if not, pick the next version"
fi
ok "version files, CHANGELOG, What's New, metainfo and guide say $V at $(git rev-parse --short HEAD)"
dpi_ok
diff --git a/tests/release_beta_test.sh b/tests/release_beta_test.sh
index eb5aa39d..96ea97b3 100755
--- a/tests/release_beta_test.sh
+++ b/tests/release_beta_test.sh
@@ -25,7 +25,8 @@ git sparse-checkout set --no-cone /.github/workflows/ /CMakeLists.txt /CHANGELOG
/scripts/ /changes/ /tests/ui/whats_new.sfui
git checkout -q -B main "$(git -C "$ROOT" rev-parse HEAD)"
# This checkout's uncommitted changes (the tree being tested), then one commit on main.
-(cd "$ROOT" && git diff --name-only HEAD -- .github/workflows CMakeLists.txt CHANGELOG.md packaging docs tools website scripts changes tests/ui/whats_new.sfui) |
+paths=(.github/workflows CMakeLists.txt CHANGELOG.md packaging docs tools website scripts changes tests/ui/whats_new.sfui)
+(cd "$ROOT" && git diff --name-only HEAD -- "${paths[@]}" && git ls-files --others --exclude-standard -- "${paths[@]}") |
while read -r f; do
if [ -e "$ROOT/$f" ]; then mkdir -p "$(dirname "$f")" && cp "$ROOT/$f" "$f"; else rm -f "$f"; fi
done
@@ -43,7 +44,6 @@ testers:
- Windows, 150% scaling: open the beta test feature and try it.
---
EOF
-echo '# expect_text "Version 9.0.0"' >> tests/ui/whats_new.sfui # words_ok wants the UI test to check the version
git add -A . && git commit -q -m "sandbox"
git init -q --bare "$S/origin.git"
git remote set-url origin "$S/origin.git"
@@ -106,6 +106,13 @@ grep -q '^## Version 9.0.0$' docs/guide/whats-new.md || fail "beta bump: no What
[ ! -e changes/beta-test.md ] || fail "beta bump: the fragment is still there"
grep -q 'open the beta test feature' release-testers-9.0.0-beta.1.md || fail "beta bump: no testers checklist"
[ "$(git rev-parse HEAD)" = "$(git -C "$S/origin.git" rev-parse main)" ] || fail "beta bump: main not pushed"
+grep -qx 'env SF_GUIDE_VERSION 9.0.0' tests/ui/whats_new.sfui && grep -qx 'expect_text "Version 9.0.0"' tests/ui/whats_new.sfui ||
+ fail "beta bump didn't pin tests/ui/whats_new.sfui to 9.0.0"
+# Every STOPPED message ends with the exact command that resumes, --yes included.
+echo "# uncommitted" >> tests/ui/whats_new.sfui
+scripts/release.sh 9.0.0-beta.1 --only check >"$S/out.log" 2>&1 && fail "check passed with uncommitted changes"
+grep -q "then: BUILD_DIR=$BUILD_DIR scripts/release.sh 9.0.0-beta.1 --from check --yes$" "$S/out.log" || fail "STOPPED without the resume command: $(cat "$S/out.log")"
+git checkout -q -- tests/ui/whats_new.sfui
quiet scripts/release.sh 9.0.0-beta.1 --only check
grep -q 'CMakeLists.txt says 9.0.0 beta.1' "$S/out.log" || fail "beta check: $(cat "$S/out.log")"
diff --git a/tools/ci/fetch.sh b/tools/ci/fetch.sh
new file mode 100755
index 00000000..d42968d7
--- /dev/null
+++ b/tools/ci/fetch.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+# SculptForge - open source digital sculpting
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# tools/ci/fetch.sh URL SHA256 prints the path of a checked local copy of URL
+#
+# CI's downloads of tools (ccache, uv): kept in SF_DEPS_CACHE (default .deps, the folder each job caches with
+# actions/cache, key deps-...; cmake/Fetch.cmake keeps the build's own archives there too), named by their hash, and
+# downloaded with retries and backoff when missing: 0.11.1's packages died on GitHub 504s.
+set -euo pipefail
+[ $# -eq 2 ] || { echo "usage: $0 URL SHA256" >&2; exit 2; }
+url=$1 sum=$2
+dir=${SF_DEPS_CACHE:-.deps}
+mkdir -p "$dir"
+f=$dir/$sum-${url##*/}
+sha() { if command -v sha256sum >/dev/null; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi; }
+if [ ! -f "$f" ] || [ "$(sha "$f")" != "$sum" ]; then
+ # curl's own retries back off 1-16 s; a longer outage gets two more rounds, 30 s and 90 s later.
+ for wait in 0 30 90 x; do
+ [ "$wait" != x ] || { echo "can't download $url" >&2; exit 1; }
+ sleep "$wait"
+ curl -fsSL --retry 5 --retry-all-errors --connect-timeout 30 -o "$f.part" "$url" && break
+ done
+ got=$(sha "$f.part")
+ [ "$got" = "$sum" ] || { rm -f "$f.part"; echo "$url: SHA-256 $got, expected $sum" >&2; exit 1; }
+ mv "$f.part" "$f"
+fi
+echo "$f"
diff --git a/tools/ci/no_revert.py b/tools/ci/no_revert.py
new file mode 100755
index 00000000..a969383b
--- /dev/null
+++ b/tools/ci/no_revert.py
@@ -0,0 +1,222 @@
+#!/usr/bin/env python3
+# SculptForge - open source digital sculpting
+# SPDX-License-Identifier: GPL-3.0-or-later
+"""Refuses a merge or squash that quietly undoes what landed on the other side (scripts/merge-queue.sh runs it).
+
+ tools/ci/no_revert.py BASE..TIP every merge commit in the range
+ tools/ci/no_revert.py --merge COMMIT one merge commit
+ tools/ci/no_revert.py --squash RESULT BRANCH RESULT (one commit on main) squashes BRANCH
+ tools/ci/no_revert.py --self-test
+
+A merge X of A and B (merge base M) must keep both sides' changes: no file A changed since M may come out of X as it
+was at M or as B has it (the same for B). Conflict resolutions that take one side's file wholesale, or a
+squash made from a branch that started before main moved, undo the other side instead (0.11.1: the quick-remesh
+merge nearly reverted main's newer micro-renderer fix). Five or more changed lines thrown away that way (branch notes
+and the generated guide don't count) fail the check, listed per file. A deliberate revert passes with SF_ALLOW_REVERT=<its commit>.
+Exit 0 ok, 1 refused, 2 usage or git error.
+"""
+import os
+import re
+import subprocess
+import sys
+import tempfile
+
+LIMIT = 5
+# Branch notes (merge-batch.sh removes them on purpose) and generated files.
+SKIP = re.compile(r"^(REPORT|BRIEF|REPLY|REPLIES|STRIPE|TESTERS)[^/]*$|^website/guide/")
+
+
+def git(*args, cwd=None):
+ return subprocess.run(["git", *args], cwd=cwd, check=True, capture_output=True, text=True).stdout
+
+
+def tree(commit, cwd=None):
+ """{path: blob} of a commit."""
+ out = {}
+ for line in git("ls-tree", "-r", "-z", commit, cwd=cwd).split("\0"):
+ if line:
+ meta, path = line.split("\t", 1)
+ out[path] = meta.split()[2]
+ return out
+
+
+def size(a, b, path, cwd=None):
+ """Lines changed in path from a to b (numstat; a binary file counts as 1000)."""
+ out = git("diff", "--numstat", "--no-renames", a, b, "--", path, cwd=cwd).split()
+ return 1000 if out[:1] == ["-"] else int(out[0]) + int(out[1]) if out else 0
+
+
+def undone(bases, side, other, result, cwd=None):
+ """{path: lines}: files where side has commits of its own (not in other) whose change result throws away whole:
+ result has other's file, or the file as it was at a merge base, or none. A conflict resolved by taking one side's
+ file, or a squash of a branch's files onto a main that moved, looks like this; a resolution that combines the
+ two doesn't. Files renamed between side and result are left out (their changes went with them)."""
+ ts, to, tr = (tree(c, cwd) for c in (side, other, result))
+ old = [tree(b, cwd) for b in bases]
+ renamed = {l.split("\t")[1] for l in git("diff", "-M", "--name-status", side, result, cwd=cwd).splitlines()
+ if l.startswith("R")}
+ found = {}
+ for p in set(ts) | set().union(*old):
+ if SKIP.search(p) or p in renamed or tr.get(p) == ts.get(p):
+ continue
+ if tr.get(p) != to.get(p) and all(tr.get(p) != t.get(p) for t in old):
+ continue # result has a version of its own: a combined resolution
+ # side's own commits on the file (not in other) whose change result lacks: the patch applies to result's file
+ # forward and not in reverse (a rebased or cherry-picked copy of it on the other side is no loss)
+ n = sum(lost(c, p, result, cwd) for c in git("rev-list", "--no-merges", f"{other}..{side}", "--", p, cwd=cwd).split())
+ if n:
+ found[p] = n
+ return found
+
+
+def lost(commit, path, result, cwd=None):
+ """Lines of commit's change to path that result doesn't have (0 when result has it, or it can't be told)."""
+ patch = git("diff", "--no-color", "--no-renames", "--full-index", "--binary", commit + "^", commit, "--", path, cwd=cwd)
+ if not patch:
+ return 0
+ with tempfile.TemporaryDirectory() as d:
+ env = dict(os.environ, GIT_INDEX_FILE=os.path.join(d, "index"))
+ subprocess.run(["git", "read-tree", result], cwd=cwd, env=env, check=True, capture_output=True)
+ check = lambda *a: subprocess.run(["git", "apply", "--cached", "--check", *a], cwd=cwd, env=env, input=patch,
+ capture_output=True, text=True).returncode == 0
+ if check("-R") or not check():
+ return 0
+ return size(commit + "^", commit, path, cwd)
+
+
+def report(what, found):
+ n = sum(found.values())
+ if n < LIMIT:
+ return 0
+ print(f"{what}: throws away {n} changed lines in {len(found)} file(s) (the result has the other side's or the old file):")
+ for p, k in sorted(found.items(), key=lambda kv: -kv[1])[:12]:
+ print(f" {p}: {k}")
+ return n
+
+
+def check_merge(commit, cwd=None):
+ sha = git("rev-parse", commit, cwd=cwd).strip()
+ parents = git("rev-list", "--parents", "-n1", sha, cwd=cwd).split()[1:]
+ if len(parents) < 2:
+ return 0
+ bad = 0
+ bases = git("merge-base", "--all", parents[0], parents[1], cwd=cwd).split()
+ subject = git("log", "-1", "--format=%h %s", sha, cwd=cwd).strip()
+ for i, (side, other) in enumerate(((parents[0], parents[1]), (parents[1], parents[0]))):
+ name = git("log", "-1", "--format=%h", side, cwd=cwd).strip()
+ bad += report(f"merge {subject[:70]}: parent {i + 1} ({name})", undone(bases, side, other, sha, cwd))
+ return bad and sha
+
+
+def check_squash(result, branch, cwd=None):
+ sha = git("rev-parse", result, cwd=cwd).strip()
+ parent = git("rev-parse", sha + "~1", cwd=cwd).strip()
+ bases = git("merge-base", "--all", parent, branch, cwd=cwd).split()
+ subject = git("log", "-1", "--format=%h %s", sha, cwd=cwd).strip()
+ return report(f"squash {subject[:70]} of {branch}: main", undone(bases, parent, branch, sha, cwd)) and sha
+
+
+def allowed(sha):
+ ok = os.environ.get("SF_ALLOW_REVERT", "")
+ return bool(ok) and sha.startswith(ok) and len(ok) >= 7
+
+
+def run(argv, cwd=None):
+ if len(argv) == 1 and ".." in argv[0]:
+ refused = []
+ for c in git("rev-list", "--merges", argv[0], cwd=cwd).split():
+ sha = check_merge(c, cwd)
+ if sha and not allowed(sha):
+ refused.append(sha)
+ elif len(argv) == 2 and argv[0] == "--merge":
+ sha = check_merge(argv[1], cwd)
+ refused = [sha] if sha and not allowed(sha) else []
+ elif len(argv) == 3 and argv[0] == "--squash":
+ sha = check_squash(argv[1], argv[2], cwd)
+ refused = [sha] if sha and not allowed(sha) else []
+ else:
+ print(__doc__)
+ return 2
+ for sha in refused:
+ print(f"refused: {sha[:10]}. Redo it keeping both sides; a deliberate revert: SF_ALLOW_REVERT={sha[:10]}")
+ return 1 if refused else 0
+
+
+def self_test():
+ with tempfile.TemporaryDirectory() as d:
+ g = lambda *a: git("-c", "user.name=t", "-c", "[email protected]", "-c", "commit.gpgsign=false", *a, cwd=d)
+ g("init", "-q", "-b", "main")
+
+ def write(name, lines):
+ with open(os.path.join(d, name), "w") as f:
+ f.write("".join(l + "\n" for l in lines))
+
+ old = [f"int old_{i} = {i};" for i in range(10)]
+ write("a.cpp", old)
+ write("b.cpp", ["int b = 1;"])
+ g("add", "-A"); g("commit", "-qm", "base")
+ g("branch", "feat")
+ # main moves on: a fix of 8 lines in a.cpp
+ fix = old[:2] + [f"int fixed_{i} = {i};" for i in range(8)]
+ write("a.cpp", fix)
+ g("commit", "-qam", "main: the fix")
+ # the branch: its own feature in b.cpp, plus an unrelated small edit in a.cpp
+ g("checkout", "-q", "feat")
+ write("b.cpp", ["int b = 1;", "int feature_one = 1;", "int feature_two = 2;"])
+ write("REPORT.md", ["READY abc1234 notes for the coordinator"])
+ g("add", "-A"); g("commit", "-qm", "feat")
+ feat = g("rev-parse", "HEAD").strip()
+ # 1. a clean merge keeps both: passes, even though the notes go afterwards
+ g("checkout", "-q", "main")
+ g("merge", "-q", "--no-ff", "-m", "Merge feat", "feat")
+ g("rm", "-q", "REPORT.md"); g("commit", "-qm", "Remove branch notes")
+ assert run(["HEAD~3..HEAD"], d) == 0, "a clean merge was refused"
+ # 2. a merge whose "resolution" took the branch's a.cpp: refused, and passes when allowed by its sha
+ g("reset", "-q", "--hard", "HEAD~2")
+ g("merge", "-q", "--no-ff", "--no-commit", "feat")
+ write("a.cpp", old)
+ g("add", "-A"); g("commit", "-qm", "Merge feat (bad resolution)")
+ bad = g("rev-parse", "HEAD").strip()
+ assert run(["--merge", "HEAD"], d) == 1, "a merge that reverted main's fix passed"
+ assert run(["HEAD~2..HEAD"], d) == 1, "the range check missed the bad merge"
+ os.environ["SF_ALLOW_REVERT"] = bad[:10]
+ try:
+ assert run(["HEAD~2..HEAD"], d) == 0, "SF_ALLOW_REVERT didn't allow that merge"
+ finally:
+ del os.environ["SF_ALLOW_REVERT"]
+ # 3. a squash made from the branch's whole tree on top of the moved main: refused; one from its diff: passes
+ g("reset", "-q", "--hard", "HEAD~1")
+ g("checkout", "-q", feat, "--", ".")
+ g("commit", "-qm", "Squash feat (from the branch's files)")
+ assert run(["--squash", "HEAD", "feat"], d) == 1, "a squash that reverted main's fix passed"
+ g("reset", "-q", "--hard", "HEAD~1")
+ g("merge", "-q", "--squash", "feat"); g("commit", "-qm", "Squash feat")
+ assert run(["--squash", "HEAD", "feat"], d) == 0, "a clean squash was refused"
+ # 4. main deleted lines; a merge that brings them back is refused too
+ g("checkout", "-q", "-b", "feat2", "HEAD~1")
+ write("c.cpp", ["int c = 3;"]); g("add", "-A"); g("commit", "-qm", "feat2")
+ g("checkout", "-q", "main")
+ write("a.cpp", fix[:2]); g("commit", "-qam", "main deletes the fixed lines")
+ g("merge", "-q", "--no-ff", "--no-commit", "feat2")
+ write("a.cpp", fix); g("add", "-A"); g("commit", "-qm", "Merge feat2 (brings deleted lines back)")
+ assert run(["--merge", "HEAD"], d) == 1, "a merge that restored main's deleted lines passed"
+ print("no_revert self-test: ok")
+
+
+if __name__ == "__main__":
+ if sys.argv[1:] == ["--self-test"]:
+ import contextlib, io
+ with contextlib.redirect_stdout(io.StringIO()) as quiet:
+ try:
+ self_test()
+ except AssertionError:
+ sys.stdout = sys.__stdout__
+ print(quiet.getvalue())
+ raise
+ print("no_revert self-test: ok")
+ sys.exit(0)
+ try:
+ sys.exit(run(sys.argv[1:]))
+ except subprocess.CalledProcessError as e:
+ print(f"git {' '.join(e.cmd[1:])}: {e.stderr.strip()}")
+ sys.exit(2)
diff --git a/tools/release/pin_whats_new_test.py b/tools/release/pin_whats_new_test.py
new file mode 100755
index 00000000..62171e95
--- /dev/null
+++ b/tools/release/pin_whats_new_test.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python3
+# SculptForge - open source digital sculpting
+# SPDX-License-Identifier: GPL-3.0-or-later
+"""Pins tests/ui/whats_new.sfui's guide check to the newest What's New section (release.sh step bump runs it).
+
+ tools/release/pin_whats_new_test.py X.Y.Z [--check] write (or only check) the pin
+ tools/release/pin_whats_new_test.py --self-test
+
+The guide chapter shows the last three versions in full, so the test expects the newest three '## Version' lines of
+docs/guide/whats-new.md and each one's tagline, with SF_GUIDE_VERSION at X.Y.Z. The release never stops at
+"whats_new.sfui doesn't check Version X" again: the bump writes it.
+"""
+import re
+import sys
+
+WHATS_NEW = "docs/guide/whats-new.md"
+TEST = "tests/ui/whats_new.sfui"
+
+
+def sections(md):
+ """[(version, tagline or None)], newest first."""
+ out = []
+ for m in re.finditer(r"^## Version (\S+)\n(.*?)(?=^## |\Z)", md, re.M | re.S):
+ t = re.search(r"^tagline: (.+)$", m.group(2), re.M)
+ out.append((m.group(1), t.group(1).strip() if t else None))
+ return out
+
+
+def visible(text):
+ """The part of a tagline the test can quote: up to the first quote or Markdown mark (sfui words have no escapes)."""
+ text = re.split(r'["*_`\[]', text)[0].strip()
+ return text if len(text) >= 12 else None
+
+
+def pin(test, md, version):
+ secs = sections(md)[:3]
+ if not secs or secs[0][0] != version:
+ raise ValueError(f"{WHATS_NEW}: the newest section is not '## Version {version}'")
+ lines = []
+ for v, tag in secs:
+ lines.append(f'expect_text "Version {v}"')
+ if tag and visible(tag):
+ lines.append(f'expect_text "{visible(tag)}"')
+ test = re.sub(r"^env SF_GUIDE_VERSION .*$", f"env SF_GUIDE_VERSION {version}", test, count=1, flags=re.M)
+ test = re.sub(r"pinned to [0-9][0-9.a-z-]* \(SF_GUIDE_VERSION\), so it checks [0-9][0-9.a-z-]*'s",
+ f"pinned to {version} (SF_GUIDE_VERSION), so it checks {version}'s", test, count=1)
+ m = re.search(r"^expect_guide whats-new\.md\n((?:expect_text .*\n)*)", test, re.M)
+ if not m:
+ raise ValueError(f"{TEST}: no 'expect_guide whats-new.md' followed by its expect_text lines")
+ return test[:m.start(1)] + "".join(l + "\n" for l in lines) + test[m.end(1):]
+
+
+def self_test():
+ md = ("# What's new\n\n## Version 2.0.0\n\n```features\ndate: unreleased\ntagline: Faster \"things\" here, now.\n```\n"
+ "- x\n\n## Version 1.9.0\n\n```features\ntagline: Plain words for the old one.\n```\n\n## Version 1.8.0\n\n"
+ "- no block\n\n## Version 1.7.0\n\ntagline: too old\n")
+ test = ("# chapter pinned to 1.9.0 (SF_GUIDE_VERSION), so it checks 1.9.0's section.\nenv SF_GUIDE_VERSION 1.9.0\n"
+ "expect_guide whats-new.md\nexpect_text \"Version 1.9.0\"\nexpect_text \"old\"\nexpect_value n == 6\n")
+ out = pin(test, md, "2.0.0")
+ assert "env SF_GUIDE_VERSION 2.0.0\n" in out and "checks 2.0.0's" in out, out
+ assert 'expect_text "Version 2.0.0"\n' in out and 'expect_text "Version 1.8.0"\n' in out, out
+ assert "Version 1.7.0" not in out and '"old"' not in out, out
+ assert 'expect_text "Plain words for the old one."\n' in out, out
+ assert 'expect_text "Faster' not in out, out # "Faster " is too short to be a useful check
+ assert out.endswith("expect_value n == 6\n"), out
+ assert pin(out, md, "2.0.0") == out # idempotent
+ try:
+ pin(test, md, "2.1.0")
+ raise AssertionError("pinned to a version that has no section")
+ except ValueError:
+ pass
+ print("pin_whats_new_test self-test: ok")
+
+
+def main(argv):
+ if argv[1:] == ["--self-test"]:
+ self_test()
+ return 0
+ if len(argv) < 2:
+ print(__doc__)
+ return 2
+ version, check = argv[1], "--check" in argv[2:]
+ test = open(TEST, encoding="utf-8").read()
+ try:
+ new = pin(test, open(WHATS_NEW, encoding="utf-8").read(), version)
+ except ValueError as e:
+ print(e)
+ return 1
+ if new == test:
+ return 0
+ if check:
+ print(f"{TEST} is not pinned to {version}: tools/release/pin_whats_new_test.py {version}")
+ return 1
+ open(TEST, "w", encoding="utf-8").write(new)
+ print(TEST)
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))
diff --git a/tools/test/impacted.py b/tools/test/impacted.py
index 5ad8f9fc..9234c3f0 100644
--- a/tools/test/impacted.py
+++ b/tools/test/impacted.py
@@ -40,8 +40,10 @@ HAND_MAP = [
("changes/*", "release_notes release_notes_fragments"),
("CHANGELOG.md", "release_notes"),
("scripts/release.sh", "release_script_beta"),
+ ("scripts/merge-queue.sh", "ci_no_revert"),
+ ("tests/ui/whats_new.sfui", "release_pin_whats_new release_script_beta"),
("tests/release_beta_test.sh", "release_script_beta"),
- ("tools/release/*", "release_notes release_notes_fragments release_script_beta"),
+ ("tools/release/*", "release_notes release_notes_fragments release_script_beta release_pin_whats_new"),
("packaging/windows/*", "ui_windows_dpi_2560 ui_windows_dpi_2160 ui_ui_scale_900"),
("addons/blender/*", "blender_exchange blender_addon_package blender_addon"),
("integrations/maya/*", "maya_shelf_script ui_maya_bridge"),