diff --git a/.github/workflows/build-project.yaml b/.github/workflows/build-project.yaml index 452e4d6f84..1597b9f057 100644 --- a/.github/workflows/build-project.yaml +++ b/.github/workflows/build-project.yaml @@ -2940,9 +2940,10 @@ jobs: SOLDR_S3_CACHE_ACCESS_KEY: ${{ secrets.SOLDR_S3_CACHE_ACCESS_KEY }} SOLDR_S3_CACHE_SECRET_KEY: ${{ secrets.SOLDR_S3_CACHE_SECRET_KEY }} - # The libobs lib-module cache (#3264): PRs restore master's modules, - # only master pushes save (a PR-ref cache is unreachable by other PRs). + # The libobs lib-module cache (#3264): hosted PRs restore master's modules, + # only master pushes save. Kept trees never use this second cache. - uses: ./.github/actions/cache + if: steps.pcache.outputs.tree == '' with: mode: restore path: ${{ github.workspace }}/.tier2-modcache @@ -3001,7 +3002,9 @@ jobs: # Only the Dell's marker-backed persistent slot bypasses zccache. OBS_TIER2_LAUNCHER: ${{ steps.pcache.outputs.zccache == '' && 'zccache' || '' }} ZCCACHE_CACHE_DIR: ${{ steps.pcache.outputs.zccache || format('{0}/.tier2-zccache', github.workspace) }} - OBS_LIBOBS_MODULE_CACHE_DIR: ${{ github.workspace }}/.tier2-modcache + # A kept tree outperforms the module cache (0/7 Dell hits); avoid its second configure. + OBS_LIBOBS_MODULE_CACHE_DIR: ${{ steps.pcache.outputs.tree == '' && format('{0}/.tier2-modcache', github.workspace) || '' }} + OBS_TIER2_KEEP_CONFIGURE: ${{ steps.pcache.outputs.tree != '' && '1' || '' }} OBS_TIER2_COST_DIR: ${{ github.workspace }}/.tier2-cost OBS_TIER2_MODES: "OFF ON" OBS_TIER2_STAGE: build @@ -3040,7 +3043,7 @@ jobs: - name: Save Tier 2 Module Cache ๐Ÿ’พ uses: ./.github/actions/cache - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && steps.tier2-build.outcome == 'success' + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && steps.tier2-build.outcome == 'success' && steps.pcache.outputs.tree == '' with: mode: save path: ${{ github.workspace }}/.tier2-modcache diff --git a/ci/test_tier2_build_setup.py b/ci/test_tier2_build_setup.py index ccc5dbc1f0..3a8255096e 100644 --- a/ci/test_tier2_build_setup.py +++ b/ci/test_tier2_build_setup.py @@ -31,8 +31,8 @@ def test_launcher_default_override_and_empty(self): source = VALIDATE.read_text() setup = source.split('# Compiler cache:', 1)[1].split('# Read the same canonical', 1)[0] setup = '# Compiler cache:' + setup - configure = source.split(' cmake -S "$SRC" -B "$build" -G Ninja', 1)[1].split(' # -k 0:', 1)[0] - configure = 'cmake -S "$SRC" -B "$build" -G Ninja' + configure + configure = source.split(' # Kept-tree configure:', 1)[1].split(' # -k 0:', 1)[0] + configure = '# Kept-tree configure:' + configure stats = re.search(r'(?:^if [^\n]+\n)?[ \t]*echo "== zccache"\n.*', source, re.M | re.S)[0] for launcher in (None, '', 'ccache'): with self.subTest(launcher=launcher), tempfile.TemporaryDirectory() as directory: @@ -120,12 +120,13 @@ def test_hosted_zccache_path_and_cache_gates_are_preserved(self): def test_module_cost_and_artifact_state_stays_in_workspace(self): job = build_job() build = step(job, "Build Tier 2 (libobs and libobs-c-reference) ๐Ÿงฑ") - self.assertIn("OBS_LIBOBS_MODULE_CACHE_DIR: ${{ github.workspace }}/.tier2-modcache", build) + self.assertIn("OBS_LIBOBS_MODULE_CACHE_DIR: ${{ steps.pcache.outputs.tree == '' && format('{0}/.tier2-modcache', github.workspace) || '' }}", build) + self.assertIn("OBS_TIER2_KEEP_CONFIGURE: ${{ steps.pcache.outputs.tree != '' && '1' || '' }}", build) self.assertIn("OBS_TIER2_COST_DIR: ${{ github.workspace }}/.tier2-cost", build) self.assertIn("path: .tier2-cost", job) self.assertIn("path: ${{ github.workspace }}/.tier2-modcache", job) - for name in ("Save Tier 2 Module Cache ๐Ÿ’พ", "Upload Tier 2 Tree ๐Ÿงพ"): - self.assertNotIn("pcache", step(job, name)) + self.assertIn("steps.pcache.outputs.tree == ''", step(job, "Save Tier 2 Module Cache ๐Ÿ’พ")) + self.assertNotIn("pcache", step(job, "Upload Tier 2 Tree ๐Ÿงพ")) def test_bound_reads_the_container_workspace(self): # The job runs in a container: ${{ github.workspace }} in a run diff --git a/ci/test_tier2_configure.py b/ci/test_tier2_configure.py new file mode 100644 index 0000000000..73dbcd7205 --- /dev/null +++ b/ci/test_tier2_configure.py @@ -0,0 +1,155 @@ +"""Fail-closed reuse of the Dell's configured Ninja tree (Refs #4954).""" +import importlib.util +import os +from pathlib import Path +import subprocess +import tempfile +import unittest +from unittest.mock import patch + +ROOT = Path(__file__).resolve().parent.parent +SPEC = importlib.util.spec_from_file_location('tier2_configure', ROOT / 'ci/tier2_configure.py') + + +class ConfigureTest(unittest.TestCase): + def setUp(self): + self.mod = importlib.util.module_from_spec(SPEC) + SPEC.loader.exec_module(self.mod) + self.temp = tempfile.TemporaryDirectory() + self.addCleanup(self.temp.cleanup) + self.root = Path(self.temp.name) + self.src = self.root / 'src' + self.src.mkdir() + (self.src / 'CMakeLists.txt').write_text('cmake_minimum_required(VERSION 3.24)\nproject(reuse NONE)\nadd_custom_target(probe ALL COMMAND ${CMAKE_COMMAND} -E echo first)\n') + self.build = self.root / 'build' + self.args = ['cmake', '-S', str(self.src), '-B', str(self.build), '-G', 'Ninja', '-DENABLE_UNIT_TESTS=ON', '-DCMAKE_BUILD_TYPE=RelWithDebInfo'] + inventory = patch.object(self.mod, 'installed_packages', return_value='fixture=1') + inventory.start() + self.addCleanup(inventory.stop) + self.env = patch.dict(os.environ, {'OBS_TIER2_KEEP_CONFIGURE': '1', 'OBS_TIER2_LAUNCHER': '', 'OBS_LIBOBS_MODULE_CACHE_DIR': ''}) + self.env.start() + self.addCleanup(self.env.stop) + + def run_configure(self, args=None): + return self.mod.configure(self.build, args or self.args) + + def test_same_args_skip_and_every_argument_change_configures(self): + self.assertTrue(self.run_configure()) + self.assertFalse(self.run_configure()) + for flag in ('-DCMAKE_BUILD_TYPE=Debug', '-DENABLE_UNIT_TESTS=OFF', '-DCMAKE_C_COMPILER_LAUNCHER=ccache', '-DOBS_BUILD_C_REFERENCE=OFF'): + with self.subTest(flag=flag): + self.assertTrue(self.run_configure(self.args + [flag])) + self.assertFalse(self.run_configure(self.args + [flag])) + self.assertNotEqual(self.mod.fingerprint(['cmake', 'a b', 'c']), self.mod.fingerprint(['cmake', 'a', 'b c'])) + + def test_missing_or_modified_tree_and_stamp_configure(self): + self.assertTrue(self.run_configure()) + for name in (self.mod.STAMP, 'CMakeCache.txt', 'build.ninja'): + with self.subTest(name=name): + path = self.build / name + path.rename(path.with_name(name + '.saved')) + self.assertTrue(self.run_configure()) + path.write_text(path.read_text() + '\n# changed\n') + self.assertTrue(self.run_configure()) + + def test_environment_changes_configure(self): + self.run_configure() + for key in ('CC', 'CXX', 'CFLAGS', 'LDFLAGS', 'OBS_TIER2_LAUNCHER', 'OBS_RUST_VERSION', 'CMAKE_PREFIX_PATH', 'PKG_CONFIG_PATH', 'RUSTUP_TOOLCHAIN', 'UV_PYTHON', 'PYTHONPATH', 'VIRTUAL_ENV', 'CPATH'): + with self.subTest(key=key), patch.dict(os.environ, {key: 'changed'}): + self.assertTrue(self.run_configure()) + self.assertFalse(self.run_configure()) + + def test_hosted_always_configures(self): + with patch.dict(os.environ, {'OBS_TIER2_KEEP_CONFIGURE': ''}): + self.assertTrue(self.run_configure()) + self.assertTrue(self.run_configure()) + + def test_failed_configure_invalidates_previous_stamp(self): + self.run_configure() + with self.assertRaises(subprocess.CalledProcessError): + self.run_configure(self.args + ['-G', 'invalid-generator']) + self.assertFalse((self.build / self.mod.STAMP).exists()) + self.assertTrue(self.run_configure()) + + def test_ninja_still_regenerates_when_cmakelists_changes(self): + self.run_configure() + path = self.src / 'CMakeLists.txt' + path.write_text(path.read_text().replace('echo first', 'echo second')) + self.assertFalse(self.run_configure()) + result = subprocess.run(['cmake', '--build', str(self.build)], capture_output=True, text=True, check=True) + self.assertIn('second', result.stdout) + + def test_git_version_changes_configure(self): + subprocess.run(['git', 'init', '-q', str(self.src)], check=True) + def commit(message): + subprocess.run(['git', '-C', str(self.src), '-c', 'user.name=Test', '-c', 'user.email=test@example.com', '-c', 'commit.gpgsign=false', 'commit', '--allow-empty', '-qm', message], check=True) + commit('first') + subprocess.run(['git', '-C', str(self.src), '-c', 'tag.gpgsign=false', 'tag', '33.0.0'], check=True) + self.run_configure() + self.assertFalse(self.run_configure()) + commit('second') + self.assertTrue(self.run_configure()) + + def test_unknown_inventory_and_module_cache_never_skip(self): + self.run_configure() + with patch.object(self.mod, 'installed_packages', side_effect=OSError('unavailable')): + self.assertTrue(self.run_configure()) + self.assertFalse((self.build / self.mod.STAMP).exists()) + with patch.dict(os.environ, {'OBS_LIBOBS_MODULE_CACHE_DIR': '/cache'}): + self.assertTrue(self.run_configure()) + self.assertTrue(self.run_configure()) + + def test_package_and_toolchain_file_changes_configure(self): + toolchain = self.root / 'toolchain.cmake' + toolchain.write_text('# first\n') + args = self.args + ['-DCMAKE_TOOLCHAIN_FILE:FILEPATH=' + str(toolchain)] + self.run_configure(args) + self.assertFalse(self.run_configure(args)) + toolchain.write_text('# second\n') + self.assertTrue(self.run_configure(args)) + with patch.object(self.mod, 'installed_packages', return_value='fixture=2'): + self.assertTrue(self.run_configure(args)) + + def test_multiple_preload_scripts_and_includes_never_skip(self): + first, second, included = [self.root / name for name in ('first.cmake', 'second.cmake', 'included.cmake')] + included.write_text('set(PROBE first CACHE STRING "" FORCE)\n') + first.write_text('include("' + str(included) + '")\n') + second.write_text('# second\n') + args = self.args + ['-C', str(first), '-C' + str(second)] + self.assertTrue(self.run_configure(args)) + self.assertTrue(self.run_configure(args)) + included.write_text('set(PROBE second CACHE STRING "" FORCE)\n') + self.assertTrue(self.run_configure(args)) + self.assertIn('PROBE:STRING=second', (self.build / 'CMakeCache.txt').read_text()) + + def test_suppressed_ninja_regeneration_never_skips(self): + args = self.args + ['-DCMAKE_SUPPRESS_REGENERATION=ON'] + self.assertTrue(self.run_configure(args)) + self.assertTrue(self.run_configure(args)) + + def test_validate_shell_uses_exact_arguments_and_skip_decision(self): + # Run the real shell block and helper against a small CMake project. + (self.src / 'ci').symlink_to(ROOT / 'ci', target_is_directory=True) + binary = self.root / 'bin' + binary.mkdir() + dpkg = binary / 'dpkg-query' + dpkg.write_text('#!/bin/sh\nprintf "fixture=1\\n"\n') + dpkg.chmod(0o755) + source = (ROOT / 'rust/tools/linux-validate/validate.sh').read_text() + setup = source.split('# Compiler cache:', 1)[1].split('# Read the same canonical', 1)[0] + configure = source.split(' # Kept-tree configure:', 1)[1].split(' # -k 0:', 1)[0] + prefix = 'build_number=(); runpath_flags=(); rustc_version=fixture\n' + script = prefix + '# Compiler cache:' + setup + '# Kept-tree configure:' + configure + env = dict(os.environ, SRC=str(self.src), BUILD=str(self.root), build=str(self.build), + PATH=str(binary) + os.pathsep + os.environ['PATH']) + for expected in ('configure required', 'matching kept tree'): + subprocess.run(['bash', '-euo', 'pipefail', '-c', script], env=env, check=True, capture_output=True, text=True) + self.assertIn(expected, self.build.with_suffix('.configure.log').read_text()) + env['OBS_EXTRA_CMAKE_ARGS'] = '-DENABLE_UNIT_TESTS=OFF' + # The later ON in this script still wins, but changed argv must configure. + subprocess.run(['bash', '-euo', 'pipefail', '-c', script], env=env, check=True, capture_output=True, text=True) + self.assertIn('configure required', self.build.with_suffix('.configure.log').read_text()) + + +if __name__ == '__main__': + unittest.main() diff --git a/ci/test_tier2_modcache.py b/ci/test_tier2_modcache.py index e8e50e9a7c..2a3747f7b6 100644 --- a/ci/test_tier2_modcache.py +++ b/ci/test_tier2_modcache.py @@ -38,14 +38,14 @@ def setUp(self): self.text = VALIDATE.read_text(encoding="utf-8") def test_main_configure_clears_the_cache_variable(self): - configure = self.text[self.text.index('cmake -S "$SRC" -B "$build"') :] + configure = self.text[self.text.index('tier2_configure -S "$SRC" -B "$build"') :] configure = configure[: configure.index(".configure.log")] self.assertIn("-DOBS_LIBOBS_MODULE_CACHE=", configure) def test_main_configure_writes_compile_commands(self): # restore keys modules from compile_commands.json; the Tier 2 tree # did not write it and the first CI run failed (#3336). - configure = self.text[self.text.index('cmake -S "$SRC" -B "$build"') :] + configure = self.text[self.text.index('tier2_configure -S "$SRC" -B "$build"') :] configure = configure[: configure.index(".configure.log")] self.assertIn("-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", configure) @@ -106,7 +106,7 @@ def test_saves_only_on_master(self): def test_the_build_step_passes_the_cache_dir(self): build = self.job[self.job.index("id: tier2-build") :] build = build[: build.index("run:")] - self.assertIn("OBS_LIBOBS_MODULE_CACHE_DIR: ${{ github.workspace }}/.tier2-modcache", build) + self.assertIn("OBS_LIBOBS_MODULE_CACHE_DIR: ${{ steps.pcache.outputs.tree == '' && format('{0}/.tier2-modcache', github.workspace) || '' }}", build) if __name__ == "__main__": diff --git a/ci/tier2_configure.py b/ci/tier2_configure.py new file mode 100644 index 0000000000..b71ed5fe86 --- /dev/null +++ b/ci/tier2_configure.py @@ -0,0 +1,158 @@ +#!/usr/bin/env -S uv run --script +"""Configure Tier 2, reusing only an unchanged, complete kept Ninja tree. + +The stamp lives INSIDE tree/, so tier2_kept_tree.py moves it with the cache. +Ninja still owns source/CMake dependency and CONFIGURE_DEPENDS regeneration. +See docs/ci-tooling.md for the conservative input contract and version caveat. +""" +from __future__ import annotations + +import hashlib +import json +import os +from pathlib import Path +import re +import shlex +import shutil +import subprocess +import sys + +STAMP = '.tier2-configure.json' +ENV_NAMES = {'PATH', 'HOME', 'CC', 'CXX', 'CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', + 'DISPLAY', 'LANG', 'LC_ALL', 'TZ', 'SDKROOT', 'MACOSX_DEPLOYMENT_TARGET', + 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH', 'LIBRARY_PATH', 'LD_LIBRARY_PATH', + 'AS', 'AR', 'ASM', 'ASMFLAGS', 'CUDACXX', 'CUDAHOSTCXX', 'CUDAFLAGS', 'VIRTUAL_ENV'} +ENV_PREFIXES = ('CMAKE_', 'PKG_CONFIG', 'OBS_', 'SOLDR_', 'RUST', 'CARGO_', 'CCACHE_', 'ZCCACHE_', 'UV_', 'PYTHON') + + +def digest(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def installed_packages() -> str: + # Tier 2 runs in Ubuntu, including on the NixOS Dell. Unsupported hosts + # conservatively configure; a failed inventory never authorizes reuse. + return subprocess.run(['dpkg-query', '-W', '-f=${Package}=${Version}\\n'], + capture_output=True, check=True, text=True).stdout + + +def option(args: list[str], flag: str) -> str | None: + """Read -S/-B and -DNAME[:TYPE]=value without flattening argv boundaries.""" + value = None + for index, arg in enumerate(args): + if arg == flag and index + 1 < len(args): + value = args[index + 1] + elif flag.startswith('-D') and arg.split('=', 1)[0].split(':', 1)[0] == flag: + value = arg.split('=', 1)[1] if '=' in arg else None + elif flag in ('-S', '-B', '-C') and arg.startswith(flag) and arg != flag: + value = arg[len(flag):] + return value + + +def configure_tools(args: list[str]) -> dict: + tools = {} + commands = [args[0], 'ninja', 'cc', 'c++', 'soldr', 'pkg-config', 'git', 'uv', sys.executable, 'ld', 'ar'] + for name in ('CC', 'CXX'): + if os.environ.get(name): + commands.append(shlex.split(os.environ[name])[0]) + for name in ('CMAKE_C_COMPILER', 'CMAKE_CXX_COMPILER', 'CMAKE_MAKE_PROGRAM', + 'CMAKE_C_COMPILER_LAUNCHER', 'CMAKE_CXX_COMPILER_LAUNCHER'): + value = option(args, '-D' + name) or os.environ.get(name) + if value: + commands.append(value.split(';')[0]) + for command in commands: + resolved = shutil.which(command) + tools[command] = [str(Path(resolved).resolve()), digest(Path(resolved))] if resolved else None + return tools + + +def configure_files(args: list[str]) -> tuple[dict, str | None]: + files = {str(Path(__file__).resolve()): digest(Path(__file__))} + for flag in ('-DCMAKE_TOOLCHAIN_FILE', '-C'): + if path := option(args, flag): + files[path] = digest(Path(path)) + version = None + if src := option(args, '-S'): + root = Path(src) + for name in ('rust-toolchain.toml', '.cargo/config.toml'): + if (root / name).exists(): + files[str(root / name)] = digest(root / name) + if (root / '.git').exists() and option(args, '-DOBS_VERSION_OVERRIDE') is None: + version = subprocess.run(['git', '-C', src, 'describe', '--always', '--tags', + '--match', '[0-9]*.[0-9]*.[0-9]*', '--dirty=-modified'], + check=True, capture_output=True, text=True).stdout.strip() + return files, version + + +def fingerprint(args: list[str]) -> str: + """Hash argv, configure environment, installed tools/packages and git version. + + Do not include HEAD unconditionally: git describe's effective output is the + version input. A source archive or a fixed OBS_VERSION_OVERRIDE needs no git. + """ + # Preload scripts (and their arbitrary includes) and presets are not Ninja + # regeneration dependencies. Preserve configure for these uncommon overrides. + if any(arg.startswith(('-C', '--preset', '--fresh')) for arg in args): + raise ValueError('preload scripts, presets and fresh configure cannot be reused') + env = {key: value for key, value in os.environ.items() + if key in ENV_NAMES or key.startswith(ENV_PREFIXES)} + packages = installed_packages() + files, version = configure_files(args) + tools = configure_tools(args) + payload = {'args': args, 'env': env, 'tools': tools, 'packages': packages, + 'files': files, 'version': version, 'cwd': str(Path.cwd())} + return hashlib.sha256(json.dumps(payload, sort_keys=True).encode()).hexdigest() + + +def tree_state(build: Path) -> dict[str, str]: + """Detect removed or externally modified cache/graph, including failed runs.""" + if not re.search(r'^build build\.ninja[^\n]*: RERUN_CMAKE', (build / 'build.ninja').read_text(), re.M): + raise ValueError('Ninja regeneration is disabled') + state = {name: digest(build / name) for name in ('CMakeCache.txt', 'build.ninja', 'CMakeFiles/rules.ninja')} + for name, value in re.findall(r'^(CMAKE_(?:C_COMPILER|CXX_COMPILER|MAKE_PROGRAM|TOOLCHAIN_FILE)):[^=]+=(.+)$', + (build / 'CMakeCache.txt').read_text(), re.M): + state[name] = digest(Path(value)) + return state + + +def configure(build: Path, args: list[str]) -> bool: + """Return True when configure ran. Failure/uncertainty never authorizes reuse.""" + stamp = build / STAMP + key = None + if os.environ.get('OBS_TIER2_KEEP_CONFIGURE') == '1' and not os.environ.get('OBS_LIBOBS_MODULE_CACHE_DIR'): + try: + key = fingerprint(args) + recorded = json.loads(stamp.read_text()) + if recorded == {'input': key, 'tree': tree_state(build)}: + print('== Tier 2 configure: matching kept tree; Ninja owns regeneration', flush=True) + return False + except (OSError, ValueError, subprocess.SubprocessError) as error: + print(f'== Tier 2 configure: no reusable fingerprint ({type(error).__name__})', flush=True) + # Invalidate BEFORE invoking CMake, including on hosted/module-cache paths. + stamp.unlink(missing_ok=True) + print('== Tier 2 configure: configure required', flush=True) + subprocess.run(args, check=True) + if key is not None: + try: + record = {'input': key, 'tree': tree_state(build)} + temporary = stamp.with_suffix('.tmp') + temporary.write_text(json.dumps(record, sort_keys=True) + '\n') + temporary.replace(stamp) + except (OSError, ValueError): + pass # An unwritable/incomplete tree cannot become a skip next time. + return True + + +def main(argv: list[str]) -> int: + build, separator, *args = argv + if separator != '--' or not args: + raise ValueError('usage: tier2_configure.py BUILD -- cmake ARGS...') + try: + configure(Path(build), args) + except subprocess.CalledProcessError as error: + return error.returncode + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/docs/ci-tooling.md b/docs/ci-tooling.md index 26c625434e..edbcb14050 100644 --- a/docs/ci-tooling.md +++ b/docs/ci-tooling.md @@ -1482,6 +1482,46 @@ by the runner account; the Tier 2 build and Flatpak jobs use `container:`, thoug they are not selected on the trimmed queue path. This change neither registers nor configures a runner. Clear the variable to return to hosted Linux runners. +### Kept Tier 2 configure reuse + +Only the marker-backed kept-tree path sets `OBS_TIER2_KEEP_CONFIGURE=1`. +It disables the libobs module cache, including its restore/save steps: Dell +measurements restored 0/7 modules in five jobs, while enabling the imported +module list required a second configure. Hosted runners keep the existing +configure and module-cache behavior. + +`ci/tier2_configure.py` stores `.tier2-configure.json` inside `tree/`, so the +existing crash-safe kept-tree save/restore carries it with `CMakeCache.txt`. +The SHA-256 input fingerprint covers the complete argument vector (preserving +argument boundaries and order): source/build paths, generator, every `-D`/`-U`, +compilers and launchers, build type, test/reference switches, extra flags and +version/build-number overrides. It also covers the working directory; PATH, +HOME, compiler/linker flags, locale, DISPLAY and SDK variables; every CMAKE_, +PKG_CONFIG, OBS_, SOLDR_, RUST, CARGO_, CCACHE_, ZCCACHE_, UV_ and PYTHON environment input +(including `OBS_TIER2_LAUNCHER` and the existing shell toolchain-version result); resolved +CMake/Ninja/compiler/launcher/soldr/pkg-config/git/uv/Python/linker/archiver +executable paths and contents; +the Ubuntu installed-package/version inventory; explicit toolchain +file contents; and Rust toolchain/Cargo configuration files. + +OBS embeds `git describe --always --tags --match '[0-9]*.[0-9]*.[0-9]*' +--dirty=-modified` during configure. Its output is hashed too unless an explicit +`OBS_VERSION_OVERRIDE` replaces it. A different commit/tag/dirty version must +configure to avoid reporting a stale version: the first configure saving is +therefore limited to unchanged-version retries. Removing the module-cache +configure also benefits changed revisions. The measured 128โ€“133 second Dell +warm configure is an opportunity, not a guaranteed per-commit saving. + +Preload scripts (`-C`, including their arbitrary includes), presets and +`--fresh` conservatively retain explicit configure. +Reuse additionally requires matching contents of the cache, Ninja graph and +rules, the cached compiler/toolchain binaries/files, and an enabled Ninja CMake +regeneration rule. Missing/invalid stamps, trees, probes or any mismatch run +configure. The stamp is invalidated before configure and written atomically +only after success. Module-cache use never permits reuse. CMakeLists/includes +and `CONFIGURE_DEPENDS` changes remain Ninja's responsibility through +`cmake --build`; no build or test result is cached by this decision. + ### Prebaked Dell Tier 2 packages The independent master-push `tier2-image` job publishes the content-addressed diff --git a/rust/tools/linux-validate/validate.sh b/rust/tools/linux-validate/validate.sh index 453ac82f88..05beb3d699 100755 --- a/rust/tools/linux-validate/validate.sh +++ b/rust/tools/linux-validate/validate.sh @@ -204,7 +204,15 @@ if [ "$stage" = test ]; then else uv run --script "$SRC/rust/tools/linux-validate/stale_build.py" "$build" "$rustc_version" "$SRC" echo "== configure + build (libobs and libobs-c-reference)" - cmake -S "$SRC" -B "$build" -G Ninja \ + # Kept-tree configure: opt-in only; hosted always runs the original command. + tier2_configure() { + if [ "${OBS_TIER2_KEEP_CONFIGURE:-}" = 1 ]; then + OBS_TIER2_RUSTC_VERSION="$rustc_version" uv run --no-project "$SRC/ci/tier2_configure.py" "$build" -- cmake "$@" + else + cmake "$@" + fi + } + tier2_configure -S "$SRC" -B "$build" -G Ninja \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DENABLE_UNIT_TESTS=ON -DOBS_BUILD_C_REFERENCE=ON -DOBS_LIBOBS_BACKEND=HYBRID \ "${launcher_args[@]}" \