Skip to content

Commit 61c7e4c

Browse files
authored
Merge pull request #214 from adafruit/actions-failure-check
Added function to check that actions is passing
2 parents 7de0fc4 + 74fa968 commit 61c7e4c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

adabot/lib/circuitpython_library_validators.py

+24
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def get_result(self):
110110
ERROR_GITHUB_COMMITS_SINCE_LAST_RELEASE_GTM = "Library has new commits since last release over a month ago"
111111
ERROR_GITHUB_COMMITS_SINCE_LAST_RELEASE_1M = "Library has new commits since last release within the last month"
112112
ERROR_GITHUB_COMMITS_SINCE_LAST_RELEASE_1W = "Library has new commits since last release within the last week"
113+
ERROR_GITHUB_FAILING_ACTIONS = "The most recent GitHub Actions run has failed"
113114
ERROR_RTD_MISSING_LATEST_RELEASE = "ReadTheDocs missing the latest release. (Ignore me! RTD doesn't update when a new version is released. Only on pushes.)"
114115
ERROR_DRIVERS_PAGE_DOWNLOAD_FAILED = "Failed to download drivers page from CircuitPython docs"
115116
ERROR_DRIVERS_PAGE_DOWNLOAD_MISSING_DRIVER = "CircuitPython drivers page missing driver"
@@ -257,6 +258,29 @@ def validate_repo_state(self, repo):
257258
errors.append(ERROR_ONLY_ALLOW_MERGES)
258259
return errors
259260

261+
def validate_actions_state(self, repo):
262+
"""Validate if the most recent GitHub Actions run on the default branch
263+
has passed.
264+
Just returns a message stating that the most recent run failed.
265+
"""
266+
if not (repo["owner"]["login"] == "adafruit" and
267+
repo["name"].startswith("Adafruit_CircuitPython")):
268+
return []
269+
270+
actions_params = {"branch": repo["default_branch"]}
271+
response = github.get(
272+
"/repos/" + repo["full_name"] + "/actions/runs",
273+
params=actions_params)
274+
275+
if not response.ok:
276+
return [ERROR_UNABLE_PULL_REPO_DETAILS]
277+
278+
workflow_runs = response.json()["workflow_runs"]
279+
if workflow_runs and workflow_runs[0]["conclusion"] == "failure":
280+
return [ERROR_GITHUB_FAILING_ACTIONS]
281+
return []
282+
283+
260284
def validate_release_state(self, repo):
261285
"""Validate if a repo 1) has a release, and 2) if there have been commits
262286
since the last release. Only files that drive user-facing changes

0 commit comments

Comments
 (0)