From aa60601d63c787eca795721cfd474ba3aa39aae0 Mon Sep 17 00:00:00 2001 From: Septiple Date: Sun, 23 Jun 2024 16:38:17 +0200 Subject: [PATCH] Test can now be run against a specific branch for other repos. (#9) If the branch does not exist, the default branch is used instead. --- .github/workflows/pytest.yml | 6 ++++++ getrefs.py | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 4450b65..6c4a66d 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -18,11 +18,17 @@ on: description: "Ref/sha to use for pyanodontest" required: false default: "v1" + test_branch: + type: string + description: "Branch to use for pyanodontest" + required: false + default: "" env: GITHUB_TOKEN: ${{ secrets.TESTUSER_TOKEN }} EVENT_REPOSITORY: ${{ inputs.repository }} EVENT_REF: ${{ inputs.ref }} + EVENT_BRANCH: ${{ inputs.test_branch }} jobs: genereate_matrix: diff --git a/getrefs.py b/getrefs.py index 53364a5..f8d6c38 100644 --- a/getrefs.py +++ b/getrefs.py @@ -14,6 +14,7 @@ def main(): event_repository = os.environ.get("EVENT_REPOSITORY", "") event_ref = os.environ.get("EVENT_REF", "") + event_branch = os.environ.get("EVENT_BRANCH", "") with open("mods.json", "r") as f: mods = json.load(f) @@ -38,7 +39,10 @@ def main(): if mod["repository"] == event_repository: ref = event_ref else: - branch = repo.get_branch(repo.default_branch) + try: + branch = repo.get_branch(event_branch) + except github.UnknownObjectException: + branch = repo.get_branch(repo.default_branch) ref = branch.commit.sha mod_refs.append({"name": mod["name"], "repository": mod["repository"], "ref": ref})