Skip to content

Commit 3c92f59

Browse files
authored
Merge pull request #7704 from microdev1/ci
Conditionally run jobs on push
2 parents d16c53b + 91d4fed commit 3c92f59

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ on:
99
pull_request:
1010
release:
1111
types: [published]
12-
check_suite:
13-
types: [rerequested]
1412

1513
concurrency:
1614
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -64,24 +62,32 @@ jobs:
6462
PULL: ${{ github.event.number }}
6563
GITHUB_TOKEN: ${{ github.token }}
6664
EXCLUDE_COMMIT: ${{ github.event.pull_request.head.sha }}
67-
- name: Set head sha
65+
- name: Set head sha (pull)
6866
if: github.event_name == 'pull_request'
6967
run: echo "HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
70-
- name: Set base sha
68+
- name: Set base sha (pull)
7169
if: github.event_name == 'pull_request'
7270
run: |
7371
git fetch --no-tags --no-recurse-submodules --depth=$((DEPTH + 1)) origin $HEAD_SHA
7472
echo "BASE_SHA=$(git rev-list $HEAD_SHA --skip=$DEPTH --max-count=1)" >> $GITHUB_ENV
7573
env:
7674
DEPTH: ${{ steps.get-last-commit-with-checks.outputs.commit_depth || github.event.pull_request.commits }}
75+
- name: Set head sha (push)
76+
if: github.event_name == 'push'
77+
run: echo "HEAD_SHA=${{ github.event.after }}" >> $GITHUB_ENV
78+
- name: Set base sha (push)
79+
if: github.event_name == 'push'
80+
run: git cat-file -e $SHA && echo "BASE_SHA=$SHA" >> $GITHUB_ENV || true
81+
env:
82+
SHA: ${{ github.event.before }}
7783
- name: Get changes
7884
id: get-changes
79-
if: github.event_name == 'pull_request'
85+
if: env.BASE_SHA && env.HEAD_SHA
8086
run: echo $(git diff $BASE_SHA...$HEAD_SHA --name-only) | echo "changed_files=[\"$(sed "s/ /\", \"/g")\"]" >> $GITHUB_OUTPUT
8187
- name: Set matrix
8288
id: set-matrix
83-
working-directory: tools
8489
run: python3 -u ci_set_matrix.py
90+
working-directory: tools
8591
env:
8692
CHANGED_FILES: ${{ steps.get-changes.outputs.changed_files }}
8793
LAST_FAILED_JOBS: ${{ steps.get-last-commit-with-checks.outputs.check_runs }}

.github/workflows/create-website-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name: Update CircuitPython.org
66

77
on:
88
release:
9-
types: [published, rerequested]
9+
types: [published]
1010

1111
jobs:
1212
website:

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
name: pre-commit
66

77
on:
8-
pull_request:
98
push:
9+
pull_request:
1010

1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

tools/ci_changes_per_commit.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ def get_bad_check_runs(query_check_runs):
171171
more_pages = True
172172

173173
run_types = ["failed", "incomplete"]
174-
175-
regex_matrix = re.compile(r"^\S+ \/ (build|run) \(\S+\)$")
174+
have_dependent_jobs = ["scheduler", "mpy-cross", "tests"]
176175

177176
while more_pages:
178177
check_runs = query_check_runs.fetch()["data"]["node"]
@@ -184,14 +183,15 @@ def get_bad_check_runs(query_check_runs):
184183

185184
for check_run in check_runs[run_type]["nodes"]:
186185
name = check_run["name"]
187-
if name.startswith("ports") or regex_matrix.search(name):
188-
matrix = name.split(" ", 1)[0]
186+
187+
if any([name.startswith(job) for job in have_dependent_jobs]):
188+
return {}
189+
190+
if name.startswith("ports"):
189191
matrix_job = name.rsplit(" (", 1)[1][:-1]
190-
bad_runs.setdefault(matrix, []).append(matrix_job)
191-
elif name != "scheduler":
192-
bad_runs[name] = True
192+
bad_runs.setdefault("ports", []).append(matrix_job)
193193
else:
194-
return {}
194+
bad_runs[name] = True
195195

196196
if query_check_runs.paginate(
197197
check_runs[run_type]["pageInfo"], "after" + run_type_camel

tools/ci_set_matrix.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ def set_output(name: str, value):
9898

9999

100100
def set_boards(build_all: bool):
101-
if last_failed_jobs.get("mpy-cross") or last_failed_jobs.get("tests"):
102-
build_all = True
103-
104101
# Get boards in json format
105102
boards_info_json = build_board_info.get_board_mapping()
106103
all_board_ids = set()

0 commit comments

Comments
 (0)