diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00c7f8749f..7029cc4897 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,17 +54,16 @@ jobs: uses: ./.github/actions/deps/external with: action: cache - # Disabled: Needs to be updated - # - name: Get last commit with checks - # id: get-last-commit-with-checks - # if: github.event_name == 'pull_request' - # working-directory: tools - # run: python3 -u ci_changes_per_commit.py - # env: - # REPO: ${{ github.repository }} - # PULL: ${{ github.event.number }} - # GITHUB_TOKEN: ${{ github.token }} - # EXCLUDE_COMMIT: ${{ github.event.after }} + - name: Get last commit with checks + id: get-last-commit-with-checks + if: github.event_name == 'pull_request' + working-directory: tools + run: python3 -u ci_changes_per_commit.py + env: + REPO: ${{ github.repository }} + PULL: ${{ github.event.number }} + GITHUB_TOKEN: ${{ github.token }} + EXCLUDE_COMMIT: ${{ github.event.after }} - name: Set up mpy-cross uses: ./.github/actions/mpy_cross with: diff --git a/tools/ci_changes_per_commit.py b/tools/ci_changes_per_commit.py index 4d71f8e38c..6452f241c0 100644 --- a/tools/ci_changes_per_commit.py +++ b/tools/ci_changes_per_commit.py @@ -166,26 +166,14 @@ def get_commit_depth_and_check_suite(query_commits): return [None, None] -def append_runs_to_list(runs, bad_runs_by_matrix): - regex_matrix = re.compile("^build-[^ ]+") - regex_board = re.compile("\([^ ]+\)$") - for run in runs["nodes"]: - name = run["name"] - res_matrix = regex_matrix.search(name) - if res_matrix: - matrix = res_matrix.group() - if matrix not in bad_runs_by_matrix: - bad_runs_by_matrix[matrix] = [] - res_board = regex_board.search(name) - if res_board: - bad_runs_by_matrix[matrix].append(res_board.group()[1:-1]) - - def get_bad_check_runs(query_check_runs): more_pages = True bad_runs_by_matrix = {} + run_types = ["failed", "incomplete"] + regex_matrix = re.compile("^[^\n ]+ \/ (build|run) \([^\n ]+\)$") + while more_pages: check_runs = query_check_runs.fetch()["data"]["node"] more_pages = False @@ -194,7 +182,17 @@ def get_bad_check_runs(query_check_runs): run_type_camel = run_type.capitalize() + "Run" run_type = run_type + "Runs" - append_runs_to_list(check_runs[run_type], bad_runs_by_matrix) + for check_run in check_runs[run_type]["nodes"]: + name = check_run["name"] + res_matrix = regex_matrix.search(name) + if res_matrix: + matrix = name.split(" /", 1)[0] + matrix_job = name.split(" (", 1)[1][:-1] + bad_runs_by_matrix.setdefault(matrix, []).append(matrix_job) + elif name != "scheduler": + bad_runs_by_matrix[name] = True + else: + return {} if query_check_runs.paginate( check_runs[run_type]["pageInfo"], "after" + run_type_camel diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index 6e7a4f1229..8c248d8fd7 100755 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -92,6 +92,9 @@ def set_output(name: str, value): def set_boards_to_build(build_all: bool): + if "mpy_cross" in last_failed_jobs or "tests" in last_failed_jobs: + build_all = True + # Get boards in json format boards_info_json = build_board_info.get_board_mapping() all_board_ids = set()