Skip to content
Draft
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
50 changes: 17 additions & 33 deletions .github/workflows/root-ci-config/build_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def main():
build_utils.print_warning(f'Failed to download: {err}')
args.incremental = False

git_pull("src", args.repository, args.base_ref)
if not args.source_dir:
git_pull("src", args.repository, args.base_ref)

benchmark: bool = 'rootbench' in options_dict and options_dict['rootbench'] == "ON"
if benchmark:
Expand All @@ -173,7 +174,10 @@ def main():
# Delete all the .gcda files produced by an artifact.
build_utils.remove_file_match_ext(WORKDIR, "gcda")

build(options, args.buildtype)
if args.source_dir:
build(options, build_type=args.buildtype, source_dir=args.source_dir)
else:
build(options, build_type=args.buildtype)

# Done before anything else touches the build tree, and reported only at the
# very end so that a spurious rebuild does not cost us the test results.
Expand Down Expand Up @@ -244,6 +248,7 @@ def parse_args():
parser.add_argument("--pull_repository", default="", help="Url to the pull request incoming repository")
parser.add_argument("--head_ref", default=None, help="Ref to feature branch; it may contain a :<dst> part")
parser.add_argument("--head_sha", default=None, help="Sha of commit that triggered the event")
parser.add_argument("--source_dir", default=None, help="Don't check out. Just use the source dir provided here.")
parser.add_argument("--binaries", default="false", help="Whether to create binary artifacts")
parser.add_argument("--architecture", default=None, help="Windows only, target arch")
parser.add_argument("--repository", default="https://github.com/root-project/root.git",
Expand All @@ -259,7 +264,7 @@ def parse_args():
args.binaries = args.binaries.lower() in ('yes', 'true', '1', 'on')
args.upload_artifacts = args.upload_artifacts.lower() in ('yes', 'true', '1', 'on')

if not args.base_ref:
if not args.base_ref and not args.source_dir:
die(os.EX_USAGE, "base_ref not specified")

if not args.platform_config: # If nothing special, we take the standard platform configuration, called as the platform
Expand Down Expand Up @@ -402,7 +407,6 @@ def archive_and_upload(archive_name, prefix):
os.chdir(WORKDIR)

with tarfile.open(f"{WORKDIR}/{new_archive}", "x:gz", compresslevel=COMPRESSIONLEVEL) as targz:
targz.add("src")
targz.add("build")

try:
Expand All @@ -422,8 +426,11 @@ def archive_and_upload(archive_name, prefix):


@github_log_group("Configure")
def cmake_configure(options, buildtype):
srcdir = os.path.join(WORKDIR, "src")
def cmake_configure(options, **kwargs):
if "source_dir" in kwargs:
srcdir = kwargs["source_dir"]
else:
srcdir = os.path.join(WORKDIR, "src")
builddir = os.path.join(WORKDIR, "build")

# Add a private option to make the CI build faster by not changing the
Expand All @@ -432,31 +439,13 @@ def cmake_configure(options, buildtype):
options = f"{options} -DROOT_COMPILEDATA_IGNORE_BUILD_NODE_CHANGES=ON"

result = subprocess_with_log(f"""
cmake -S '{srcdir}' -B '{builddir}' -DCMAKE_BUILD_TYPE={buildtype} {options}
cmake --fresh -S '{srcdir}' -B '{builddir}' -DCMAKE_BUILD_TYPE={kwargs["build_type"]} {options}
""")

if result != 0:
die(result, "Failed cmake generation step")


@github_log_group("Dump existing configuration")
def cmake_dump_config():
# Print CMake cached config
srcdir = os.path.join(WORKDIR, "src")
builddir = os.path.join(WORKDIR, "build")
result = subprocess_with_log(f"""
cmake -S '{srcdir}' -B '{builddir}' -N -L
""")

if result != 0:
die(result, "Failed cmake cache print step")


@github_log_group("Dump requested build configuration")
def dump_requested_config(options):
print(f"\nBUILD OPTIONS: {options}")


def cmake_build_command(buildtype) -> str:
generator_flags = "-- '-verbosity:minimal' '-consoleloggerparameters:summary'" if WINDOWS else ""
parallel_jobs = "4" if WINDOWS else str(os.cpu_count())
Expand Down Expand Up @@ -501,22 +490,17 @@ def rebuild() -> int:
return not touched


def build(options, buildtype):
def build(options, **kwargs):
if not os.path.isdir(os.path.join(WORKDIR, "build")):
builddir = os.path.join(WORKDIR, "build")
result = subprocess_with_log(f"mkdir {builddir}")

if result != 0:
die(result, "Failed to create build directory")

if not os.path.exists(os.path.join(WORKDIR, "build", "CMakeCache.txt")):
cmake_configure(options, buildtype)
else:
cmake_dump_config()

dump_requested_config(options)
cmake_configure(options, **kwargs)

cmake_build(buildtype)
cmake_build(kwargs["build_type"])


@github_log_group("Create binary packages")
Expand Down
22 changes: 13 additions & 9 deletions .github/workflows/root-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
- self-hosted
- ${{ matrix.platform }}

name: |

Check failure on line 136 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 @@ -152,8 +152,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 155 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 156 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 @@ -185,7 +185,7 @@
- name: Nightlies and push to branch
if: github.event_name == 'schedule' || github.event_name == 'push'
env:
OVERRIDES: ${{ github.event_name == 'push' && format('{0} {1} {2}', '--overrides', env.GLOBAL_OVERRIDES, join( matrix.overrides, ' ')) || '' }}

Check failure on line 188 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}
BASE_REF: ${{ github.event_name == 'push' && github.ref_name || inputs.ref_name }}
run: |
[ -d "${VIRTUAL_ENV_DIR}" ] && source ${VIRTUAL_ENV_DIR}/bin/activate
Expand Down Expand Up @@ -498,10 +498,18 @@
echo ROOT_OBJECT_AUTO_REGISTRATION=0 >> $GITHUB_ENV;
fi

- name: Checkout
uses: actions/checkout@v6
- name: Checkout root build scripts
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref_name }}
sparse-checkout: .github/workflows/
show-progress: false

- name: Checkout root
uses: actions/checkout@v7
with:
path: src/
show-progress: false

- name: Dump GitHub context
env:
Expand Down Expand Up @@ -538,11 +546,7 @@
--dockeropts \"$CONTAINER_OPTIONS\"
--incremental $INCREMENTAL
--base_ref ${{ github.base_ref }}
--sha ${{ github.sha }}
--pull_repository ${{ github.event.pull_request.head.repo.clone_url }}
--head_ref refs/pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}
--head_sha ${{ github.event.pull_request.head.sha }}
--repository ${{ github.server_url }}/${{ github.repository }}
--source_dir ${GITHUB_WORKSPACE}/src
--overrides ${GLOBAL_OVERRIDES} ${OVERRIDES}
"

Expand Down Expand Up @@ -611,13 +615,13 @@

- name: Check headers
if: steps.install.outcome == 'success'
run: bash test/PostInstall/check-headers.sh ${{ env.INSTALL_DIR }}/include/
run: bash ${GITHUB_WORKSPACE}/src/test/PostInstall/check-headers.sh ${{ env.INSTALL_DIR }}/include/

- name: Build post-install test project
id: postInstall
if: steps.install.outcome == 'success'
run: |
cmake -S test/PostInstall/ -B ${{ env.POST_INSTALL_DIR }} -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }};
cmake -S ${GITHUB_WORKSPACE}/src/test/PostInstall/ -B ${{ env.POST_INSTALL_DIR }} -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }};
cmake --build ${{ env.POST_INSTALL_DIR }};

- name: CTest in post-install test project
Expand Down
Loading