Skip to content

Commit

Permalink
Test can now be run against a specific branch for other repos. (#9)
Browse files Browse the repository at this point in the history
If the branch does not exist, the default branch is used instead.
  • Loading branch information
Septiple authored Jun 23, 2024
1 parent 16fa9c1 commit aa60601
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion getrefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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})
Expand Down

0 comments on commit aa60601

Please sign in to comment.