refactor: out-of-tree build - source tree stays read-only#560
Merged
Conversation
Source tree is never written to during builds. All build artifacts go to BUILD_DIR (default /tmp/build-firebird), which is copied from source and worked from. This prevents stale .so files, .deb version mismatches, and source tree pollution. Changes: - build-extension action: copy source to BUILD_DIR, all steps cd $BUILD_DIR - ci.yml: pdo_fbird build + test reference BUILD_DIR - coverage.yml/sanitizers.yml: extension-path references BUILD_DIR - release-linux.yml/release-macos.yml: out-of-tree build pattern - build-precompiled.sh: --build-dir parameter - packaging/debian/build.sh: BUILD_DIR copy, REPO_ROOT repoint, fix find command (-maxdepth 1, ! -name *dbgsym*) to prevent stale .deb selection - packaging/debian/build-matrix.sh: source mounted /src:ro, build in /build (ephemeral --rm container), Sury PPA quoting fix ($distro not $(lsb_release -sc)) Fixes: PHP 8.4 .deb version bug (stale 13.0.0-1 file picked by find instead of freshly built 13.0.1-rc.1-1) Verified: 4/4 PHP versions (8.2-8.5) x bookworm pass with correct version
phpize generates run-tests.php in the directory where it runs. With out-of-tree builds, that's BUILD_DIR, not GITHUB_WORKSPACE. Test steps must cd to BUILD_DIR so both run-tests.php and tests/ are found. Fixes: 'Could not open input file: run-tests.php' in CI/coverage/sanitizers Affected test steps: - ci.yml: Run PHPT tests - coverage.yml: Run PHPT tests (+ cd BUILD_DIR/pdo_fbird for build) - sanitizers.yml: LSan tests + TSan tests (+ cd BUILD_DIR/pdo_fbird for build)
Tests use __DIR__/../vendor/autoload.php which resolves to
GITHUB_WORKSPACE/vendor/ (where composer install runs). With cd BUILD_DIR,
vendor/ was not found. Fix: reference run-tests.php by full path instead of
cd-ing to BUILD_DIR.
Reverts: cd ${BUILD_DIR} in ci.yml/coverage.yml/sanitizers.yml test steps
Replaces: php run-tests.php -> php ${BUILD_DIR}/run-tests.php
Instead of running run-tests.php from BUILD_DIR (which caused path resolution issues with vendor/autoload.php and tests/), copy it to GITHUB_WORKSPACE and run it there. This matches the original in-source build behavior where phpize generates run-tests.php in the source tree. Fixes: event test failures + 40 fewer tests running vs main
Event tests spawn child PHP processes with realpath('modules/firebird.so')
which resolves relative to CWD. With out-of-tree builds, the .so is in
BUILD_DIR/modules/, not CWD. Fix: use getenv('FBIRD_SO') with fallback to
realpath() for backward compatibility.
Set FBIRD_SO in ci.yml, coverage.yml, sanitizers.yml test steps.
Out-of-tree build puts .gcno/.gcda files in BUILD_DIR, not GITHUB_WORKSPACE. Coverage step must cd to BUILD_DIR and use GITHUB_WORKSPACE/coverage/ for output paths. Also: PHP 8.2/FB 4.0 'unbound variable' is a pre-existing transient issue in install-firebird-client (get-latest-firebird.sh), not related to our changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Source tree is never written to during builds. All build artifacts go to
BUILD_DIR(default/tmp/build-firebird), which is copied from source and worked from. This prevents stale.sofiles,.debversion mismatches, and source tree pollution.Changes (9 files, +134/-63)
build-extension/action.ymlBUILD_DIR, all stepscd $BUILD_DIRci.ymlpdo_fbirdbuild + test referenceBUILD_DIRcoverage.yml/sanitizers.ymlextension-pathreferencesBUILD_DIRrelease-linux.yml/release-macos.ymlbuild-precompiled.sh--build-dirparameterpackaging/debian/build.shBUILD_DIRcopy,REPO_ROOTrepoint, fixfindcommandpackaging/debian/build-matrix.sh/src:ro, build in/build(ephemeral), Sury PPA quoting fixBug Fix: PHP 8.4 .deb Version Detection
Root cause:
build.sh:371ranfind "${REPO_ROOT}/.." -name "php*.deb"which inside Docker expands tofind /- searching the entire container filesystem including/src/dist/which contained stale.debfiles from previous test runs (version13.0.0-1).head -n 1picked the stale file alphabetically (13.0.0<13.0.1), so the freshly-built13.0.1-rc.1-1.debwas never selected.Fix: Added
-maxdepth 1(only search parent ofBUILD_DIR) and! -name "*dbgsym*"(exclude debug symbol packages) to allfindcalls.Verification
Source tree verified clean after build (no
.so, nodebian/, no build artifacts).Relates to