Skip to content

Commit

Permalink
ci: use hatch to execute needs_testrun.py (#11709)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettlangdon authored Dec 13, 2024
1 parent d1bce2e commit 509d390
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ extra-dependencies = [
test = [
"python -m doctest {args} scripts/get-target-milestone.py scripts/needs_testrun.py tests/suitespec.py",
]
needs_testrun = [
"scripts/needs_testrun.py {args}",
]

[envs.meta-testing]
python = "3.10"
Expand Down
10 changes: 9 additions & 1 deletion scripts/needs_testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,13 @@ def extract_git_commit_selections(git_commit_message: str) -> t.Set[str]:
def main() -> bool:
argp = ArgumentParser()

try:
default_pr_number = _get_pr_number()
except RuntimeError:
default_pr_number = None

argp.add_argument("suite", help="The suite to use", type=str)
argp.add_argument("--pr", help="The PR number", type=int, default=_get_pr_number())
argp.add_argument("--pr", help="The PR number", type=int, default=default_pr_number)
argp.add_argument(
"--sha", help="Commit hash to use as diff base (defaults to PR merge root)", type=lambda v: v or None
)
Expand All @@ -282,6 +287,9 @@ def main() -> bool:
if args.verbose:
LOGGER.setLevel(logging.INFO)

if not args.pr:
raise RuntimeError("Could not determine PR number")

return needs_testrun(args.suite, args.pr, sha=args.sha)


Expand Down
2 changes: 1 addition & 1 deletion scripts/run-test-suite
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ set -e
if ! [[ -v CIRCLECI && $CIRCLE_BRANCH =~ main ]]; then
if [[ -f "$CHECKPOINT_FILENAME" ]]; then
latest_success_commit=$(cat $CHECKPOINT_FILENAME)
if ! ./scripts/needs_testrun.py $CIRCLE_JOB --sha $latest_success_commit; then
if ! hatch run scripts:needs_testrun $CIRCLE_JOB --sha $latest_success_commit; then
echo "The $CIRCLE_JOB job succeeded at commit $latest_success_commit."
echo "None of the changes on this branch since that commit affect the $CIRCLE_JOB job."
echo "Skipping this job."
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-test-suite-hatch
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ set -e
if ! [[ -v CIRCLECI && $CIRCLE_BRANCH =~ main ]]; then
if [[ -f "$CHECKPOINT_FILENAME" ]]; then
latest_success_commit=$(cat $CHECKPOINT_FILENAME)
if ! ./scripts/needs_testrun.py $CIRCLE_JOB --sha $latest_success_commit; then
if ! hatch run scripts:needs_testrun $CIRCLE_JOB --sha $latest_success_commit; then
echo "The $CIRCLE_JOB job succeeded at commit $latest_success_commit."
echo "None of the changes on this branch since that commit affect the $CIRCLE_JOB job."
echo "Skipping this job."
Expand Down

0 comments on commit 509d390

Please sign in to comment.