Skip to content

Commit

Permalink
CI: Force rebuild when GHA triggered for nightly tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed Jan 14, 2025
1 parent 77fc492 commit e2b832b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
14 changes: 10 additions & 4 deletions scripts/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from utilities.package_digest import PackageDigest
from utilities.windows import call_vcvarsall
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_git_bot_user_name, get_git_user_name, 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, run_command_term, verify_git_repo, run_command_sudo
from utilities.common import are_generated_files_git_changed, compare_dir, copy_file_list, create_temp_dir, get_git_bot_user_name, get_git_user_name, get_src_generated_files, is_arm64_toolchain_installed, is_cmake_installed, is_debian_based, is_dotnet_installed, is_i386_toolchain_installed, is_nightly_github_action, is_redhat_based, is_rpmbuild_installed, is_ubuntu, is_dotnet_installed, is_wix_installed, is_x86_64_toolchain_installed, run_command, run_command_term, 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 ):
Expand Down Expand Up @@ -388,9 +388,15 @@ def is_build_skipping_allowed(root_dir: str, asset_file_name: str, version: str,
print("Error: MD5 unexpectadly disabled for digest file.")
sys.exit(1)
if local_asset_md5 == pdigest.package_md5 and pdigest.are_all_tests_passed():
if os.getenv('GITHUB_ACTIONS') == 'true' and pdigest.builder_id != get_git_bot_user_name():
print(f"Info: {asset_file_name} from {pdigest.builder_id} will be rebuild by {get_git_bot_user_name()}")
return False

if os.getenv('GITHUB_ACTIONS') == 'true':
if is_nightly_github_action():
print(f"Info: {asset_file_name} will be rebuild for scheduled github action")
return False

if pdigest.builder_id != get_git_bot_user_name():
print(f"Info: {asset_file_name} from {pdigest.builder_id} will be rebuild by {get_git_bot_user_name()}")
return False

print(f"Info: Allow skipping of already built and tested {asset_file_name}")
return True
Expand Down
22 changes: 22 additions & 0 deletions scripts/utilities/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import filecmp
import glob
import json
import os
import re
import shutil
Expand Down Expand Up @@ -381,6 +382,27 @@ def get_git_user_name() -> str:
except subprocess.CalledProcessError as e:
return "local"

def is_nightly_github_action() -> bool:
if os.getenv('GITHUB_ACTIONS') != 'true':
return False

event_name = os.getenv('GITHUB_EVENT_NAME')
if event_name != 'schedule':
return False

event_path = os.getenv('GITHUB_EVENT_PATH')
if not event_path or not os.path.exists(event_path):
return False

with open(event_path, 'r') as f:
event_data = json.load(f)

# Check if the event was manually dispatched
if event_data.get('action') == 'workflow_dispatch':
return False

return True

def are_generated_files_git_changed(root_dir: str) -> bool:
# Using git, verify if any of the generated files have changed.
#
Expand Down

0 comments on commit e2b832b

Please sign in to comment.