diff --git a/.github/workflows/dev-nightly-tests.yml b/.github/workflows/dev-nightly-tests.yml index a373b0e5..22bc2472 100644 --- a/.github/workflows/dev-nightly-tests.yml +++ b/.github/workflows/dev-nightly-tests.yml @@ -26,20 +26,6 @@ jobs: with: ref: dev - - name: Install build tools (Linux) - if: runner.os == 'Linux' - shell: bash - run: | - sudo apt update && sudo apt install -y automake libtool autogen mcpp - sudo apt install -y openjdk-21-jdk - sudo apt install -y gcc-multilib - sudo apt install -y gcc-i686-linux-gnu - sudo apt install -y gcc-aarch64-linux-gnu - - - name: Install Rust Toolchain (Linux) - if: runner.os == 'Linux' - uses: dtolnay/rust-toolchain@stable - - name: Install Python uses: actions/setup-python@v5 with: @@ -51,25 +37,31 @@ jobs: run: | echo "PYTHON=python3" >> $GITHUB_ENV - - name: Create shell envs (Windows) - if: runner.os == 'Windows' - shell: cmd - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe > msbuild_path.txt - set /p MSBUILD_PATH=> %GITHUB_ENV% - echo PYTHON=python >> %GITHUB_ENV% - - name: Build dist assets (Linux) if: runner.os == 'Linux' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash run: | + sudo apt update + sudo apt install -y automake libtool autogen mcpp + sudo apt install -y openjdk-21-jdk + sudo apt install -y gcc-multilib + sudo apt install -y gcc-i686-linux-gnu + sudo apt install -y gcc-aarch64-linux-gnu $PYTHON $GITHUB_WORKSPACE/scripts/package.py $PYTHON $GITHUB_WORKSPACE/scripts/test-dist.py + - name: Create shell envs (Windows x64) + if: runner.os == 'Windows' + shell: cmd + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe > msbuild_path.txt + set /p MSBUILD_PATH=> %GITHUB_ENV% + echo PYTHON=python >> %GITHUB_ENV% + - name: Build dist assets (Windows x64) if: runner.os == 'Windows' env: @@ -77,6 +69,10 @@ jobs: shell: cmd run: | call "%VCVARSALL%" x64 + dotnet tool install --global wix + set PATH=%PATH%;%USERPROFILE%\.dotnet\tools + wix extension add --global WixToolset.UI.wixext + wix extension list --global %PYTHON% %GITHUB_WORKSPACE%\scripts\package.py %PYTHON% %GITHUB_WORKSPACE%\scripts\test-dist.py diff --git a/scripts/package.py b/scripts/package.py index a78e7a34..91bfeba4 100755 --- a/scripts/package.py +++ b/scripts/package.py @@ -45,7 +45,7 @@ import zlib from utilities.versions import sync_sources_digest, sync_versions -from utilities.common import are_generated_files_git_changed, compare_dir, copy_file_list, create_temp_dir, get_src_generated_files, is_arm64_toolchain_installed, is_cmake_installed, is_debian_based, is_dotnet_installed, is_i386_toolchain_installed, is_redhat_based, is_rpmbuild_installed, is_ubuntu, is_dotnet_installed, is_wix_installed, is_x86_64_toolchain_installed, verify_git_repo, run_command_sudo +from utilities.common import are_generated_files_git_changed, compare_dir, copy_file_list, create_temp_dir, get_src_generated_files, is_arm64_toolchain_installed, is_cmake_installed, is_debian_based, is_dotnet_installed, is_i386_toolchain_installed, is_redhat_based, is_rpmbuild_installed, is_ubuntu, is_dotnet_installed, is_wix_installed, is_x86_64_toolchain_installed, run_command, verify_git_repo, run_command_sudo from utilities.files import compare_msi_files, compare_tar_gz_files, compare_zip_files, create_rtf_from_txt, create_zip_file, compare_deb_files, force_delete, force_delete_glob, path_join def delete_other_versions(target_dir: str, file_pattern: str, new_version: str ): @@ -86,10 +86,7 @@ def do_cmake_reconfigure(root_dir: str, options: str, sudo_pwd: str = "") ->str: cmake_command = ['cmake'] + shlex.split(options) + ['..'] formatted_command = ' '.join([f'[{elem}]' for elem in cmake_command]) print("CMake command:", formatted_command) # Display the cmake_command list with brackets - subprocess.run(cmake_command, check=True) - except subprocess.CalledProcessError as e: - print(f"Error: Running CMake configuration {options}: {e}") - sys.exit(1) + run_command(cmake_command) finally: # Restore the original working directory os.chdir(original_dir) @@ -101,10 +98,7 @@ def do_cmake_build(build_dir: str): original_dir = os.getcwd() try: os.chdir(build_dir) - subprocess.run(['cmake', '--build', '.'], check=True) - except subprocess.CalledProcessError as e: - print(f"Error running cmake build: {e}") - sys.exit(1) + run_command(['cmake', '--build', '.']) finally: # Restore the original working directory os.chdir(original_dir) @@ -114,10 +108,7 @@ def do_cpack_build(build_dir: str): original_dir = os.getcwd() try: os.chdir(build_dir) - subprocess.run(['cpack', '.'], check=True) - except subprocess.CalledProcessError as e: - print(f"Error running CPack: {e}") - sys.exit(1) + run_command(['cpack', '.']) finally: # Restore the original working directory os.chdir(original_dir) diff --git a/scripts/utilities/common.py b/scripts/utilities/common.py index 1fa353fd..287382e8 100644 --- a/scripts/utilities/common.py +++ b/scripts/utilities/common.py @@ -1,6 +1,7 @@ import filecmp import glob import os +import re import shutil import subprocess import sys @@ -182,9 +183,24 @@ def expand_globs(root_dir: str, file_list: list) -> list: def run_command(command: list) -> str: """Run a shell command and return the output.""" - result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - if result.returncode != 0: - print(f"Error during '{' '.join(command)}': {result.stderr}") + try: + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + if result.returncode != 0: + print(f"stdout for '{' '.join(command)}': {result.stdout}") + print(f"stderr for '{' '.join(command)}': {result.stderr}") + # If result.stderr contains the string "CPack Error: Problem running WiX.", then + # print the content of the log file at the specified path. + if "CPack Error: Problem running WiX." in result.stderr: + log_file_match = re.search(r"'([^']+)'", result.stderr) + if log_file_match: + log_file = log_file_match.group(1) + if os.path.exists(log_file): + print(f"Contents of {log_file}:") + with open(log_file, 'r') as f: + print(f.read()) + sys.exit(1) + except subprocess.CalledProcessError as e: + print(f"Error during '{' '.join(command)}': {e}") sys.exit(1) return result.stdout.strip() @@ -342,6 +358,3 @@ def compare_dir(dir1: str, dir2: str) -> bool: differences_found = True return not differences_found - - -