Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/root-ci-config/build_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ def main():
head_ref_dst = head_ref_dst or "__tmp"

rebase("src", "origin", base_head_sha, head_ref_dst, args.head_sha)
elif args.sha:
# Builds triggered by a push to a branch must build exactly the pushed
# commit: git_pull() picks up wherever the branch points to when this
# job starts, which may already be a later commit.
checkout_commit("src", args.repository, args.sha)

testing: bool = options_dict['testing'] == "ON"

Expand Down Expand Up @@ -332,6 +337,29 @@ def git_pull(directory: str, repository: str, branch: str):
die(returncode, f"Failed to pull {branch}")


@github_log_group("Checkout pushed commit")
def checkout_commit(directory: str, repository: str, sha: str):
"""Reset the checkout to exactly the commit that triggered the build.

The commit normally arrives with the fetch of its branch in git_pull();
if it is missing (e.g. the branch was force-pushed in the meantime), it
is fetched explicitly.
"""
targetdir = os.path.join(WORKDIR, directory)
returncode = subprocess_with_log(f"""
cd '{targetdir}'
git reset --hard {sha}
""")
if returncode != 0:
returncode = subprocess_with_log(f"""
cd '{targetdir}'
git fetch {repository} {sha}
git reset --hard {sha}
""")
if returncode != 0:
die(returncode, f"Failed to check out commit {sha}")


@github_log_group("Download previous build artifacts")
def download_artifacts(obj_prefix: str):
try:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/root-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
matrix:
# Specify platform + optional build option overrides
# Build options: https://root.cern/install/build_from_source/#all-build-options
platform: [mac26, mac27, mac-beta]

Check failure on line 123 in .github/workflows/root-ci.yml

View workflow job for this annotation

GitHub Actions / lint-action-files

label "mac27" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2025", "windows-2025-vs2026", "windows-2022", "windows-11-arm", "ubuntu-slim", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-24.04-arm", "ubuntu-22.04", "ubuntu-22.04-arm", "macos-latest", "macos-latest-xlarge", "macos-latest-large", "macos-26-intel", "macos-26-xlarge", "macos-26-large", "macos-26", "macos-15-intel", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xlarge", "macos-14-large", "macos-14", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows", "mac14", "mac15", "mac26", "mac-beta", "cpu", "latest", "preview". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file
arch: [ARM64]
include:
- platform: mac15
Expand All @@ -132,7 +132,7 @@
- self-hosted
- ${{ matrix.platform }}

name: |

Check failure on line 135 in .github/workflows/root-ci.yml

View workflow job for this annotation

GitHub Actions / lint-action-files

property "overrides" is not defined in object type {arch: string; is_special: bool; platform: string}
${{ matrix.platform }} ${{ matrix.arch }}
${{ (github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' && join( matrix.overrides, ', ' )) || '' }}

Expand All @@ -151,8 +151,8 @@
if: github.event_name == 'pull_request'
env:
GITHUB_PR_ORIGIN: ${{ github.event.pull_request.head.repo.clone_url }}
OVERRIDES: ${{ join( matrix.overrides, ' ') }}

Check failure on line 154 in .github/workflows/root-ci.yml

View workflow job for this annotation

GitHub Actions / lint-action-files

property "overrides" is not defined in object type {arch: string; is_special: bool; platform: string}
run: |

Check failure on line 155 in .github/workflows/root-ci.yml

View workflow job for this annotation

GitHub Actions / lint-action-files

"github.event.pull_request.head.ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details
[ -d "${VIRTUAL_ENV_DIR}" ] && source ${VIRTUAL_ENV_DIR}/bin/activate
echo "Python is now $(which python3) $(python3 --version)"
src/.github/workflows/root-ci-config/build_root.py \
Expand Down Expand Up @@ -186,6 +186,9 @@
env:
OVERRIDES: ${{ github.event_name == 'push' && format('{0} {1} {2}', '--overrides', env.GLOBAL_OVERRIDES, join( matrix.overrides, ' ')) || '' }}
BASE_REF: ${{ github.event_name == 'push' && github.ref_name || inputs.ref_name }}
# For pushes, build exactly the pushed commit, not wherever the
# branch happens to be when the job starts (issue #14061).
SHA: ${{ github.event_name == 'push' && format('--sha {0}', github.sha) || '' }}
run: |
[ -d "${VIRTUAL_ENV_DIR}" ] && source ${VIRTUAL_ENV_DIR}/bin/activate
echo "Python is now $(which python3) $(python3 --version)"
Expand All @@ -196,6 +199,7 @@
--upload_artifacts false \
--binaries ${{ github.event_name == 'schedule' }} \
--base_ref ${BASE_REF} \
${SHA} \
--repository ${{ github.server_url }}/${{ github.repository }} \
${OVERRIDES}

Expand Down Expand Up @@ -344,6 +348,7 @@
--platform windows10
--incremental false
--base_ref ${{ github.ref_name }}
--sha ${{ github.sha }}
--binaries ${{ startsWith(github.ref, 'refs/tags/') }}
--repository ${{ github.server_url }}/${{ github.repository }}
--architecture ${{ matrix.target_arch }}"
Expand Down Expand Up @@ -581,6 +586,7 @@
--platform_config ${{ matrix.platform_config }}
--incremental false
--base_ref ${{ github.ref_name }}
--sha ${{ github.sha }}
--binaries ${{ startsWith(github.ref, 'refs/tags/') }}
--repository ${{ github.server_url }}/${{ github.repository }}
--overrides ${GLOBAL_OVERRIDES} ${OVERRIDES}
Expand Down
Loading