Skip to content

Commit 36453f0

Browse files
committed
test: specify ami and branch
1 parent 148af22 commit 36453f0

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

flake.nix

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,6 @@
688688
exit 0
689689
fi
690690
691-
# Check for required PostgreSQL version argument
692-
if [ -z "$1" ]; then
693-
echo "Error: PostgreSQL version must be provided"
694-
show_help
695-
exit 1
696-
fi
697-
698691
export PATH="${pkgs.lib.makeBinPath (with pkgs; [
699692
packer
700693
awscli2
@@ -794,18 +787,19 @@
794787
795788
show_help() {
796789
cat << EOF
797-
Usage: run-testinfra [--help] <ami-name>
790+
Usage: run-testinfra [--help] <ami-name> [branch]
798791
799792
Trigger the testinfra-test-only workflow to test a specific AMI.
800793
801794
This script will:
802795
1. Check if you're authenticated with GitHub
803-
2. Get the current branch and commit
796+
2. Get the current branch and commit (or use provided branch)
804797
3. Trigger the testinfra-test-only workflow with the specified AMI name
805798
4. Watch the workflow progress until completion
806799
807800
Arguments:
808801
ami-name The name of the AMI to test
802+
branch Optional branch to run the workflow on (default: current branch)
809803
810804
Options:
811805
--help Show this help message and exit
@@ -815,8 +809,9 @@
815809
- Git installed
816810
- Must be run from a git repository
817811
818-
Example:
812+
Examples:
819813
run-testinfra supabase-postgres-abc123
814+
run-testinfra supabase-postgres-abc123 develop
820815
EOF
821816
}
822817
@@ -854,13 +849,14 @@
854849
fi
855850
856851
AMI_NAME="$1"
852+
if [ -n "$2" ]; then
853+
BRANCH="$2"
854+
else
855+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
856+
fi
857857
858-
# Get current branch and commit
859-
BRANCH=$(git rev-parse --abbrev-ref HEAD)
860-
COMMIT=$(git rev-parse HEAD)
861-
862-
# Check if we're on a standard branch
863-
if [[ "$BRANCH" != "develop" && ! "$BRANCH" =~ ^release/ ]]; then
858+
# Check if we're on a standard branch (only if using current branch)
859+
if [[ -z "$2" && "$BRANCH" != "develop" && ! "$BRANCH" =~ ^release/ ]]; then
864860
echo "Warning: Running workflow from non-standard branch: $BRANCH"
865861
echo "This is supported for testing purposes."
866862
read -p "Continue? [y/N] " -n 1 -r
@@ -871,16 +867,19 @@
871867
fi
872868
fi
873869
870+
# Get current repository name
871+
REPO=$(git remote get-url origin | sed -E 's/.*github.com[:/](.*)\.git/\1/')
872+
874873
# Trigger the workflow with the AMI name
875-
echo "Triggering testinfra-test-only workflow for AMI: $AMI_NAME"
876-
gh workflow run testinfra-test-only.yml --ref "$BRANCH" -f ami_name="$AMI_NAME"
874+
echo "Triggering testinfra-only workflow for AMI: $AMI_NAME on branch: $BRANCH"
875+
gh workflow run testinfra-only.yml --repo "$REPO" --ref "$BRANCH" -f ami_name="$AMI_NAME"
877876
878877
# Wait for workflow to start and get the run ID
879878
echo "Waiting for workflow to start..."
880879
sleep 5
881880
882881
# Get the latest run ID for this workflow
883-
RUN_ID=$(gh run list --workflow=testinfra-test-only.yml --limit 1 --json databaseId --jq '.[0].databaseId')
882+
RUN_ID=$(gh run list --workflow=testinfra-only.yml --repo "$REPO" --branch "$BRANCH" --limit 1 --json databaseId --jq '.[0].databaseId')
884883
885884
if [ -z "$RUN_ID" ]; then
886885
echo "Error: Could not find workflow run ID"
@@ -894,11 +893,11 @@
894893
895894
# Try to watch the run, but handle network errors gracefully
896895
while true; do
897-
if gh run watch "$RUN_ID" --exit-status; then
896+
if gh run watch "$RUN_ID" --repo "$REPO" --exit-status; then
898897
break
899898
else
900899
echo "Network error while watching workflow. Retrying in 5 seconds..."
901-
echo "You can also check the status manually with: gh run view $RUN_ID"
900+
echo "You can also check the status manually with: gh run view $RUN_ID --repo $REPO"
902901
sleep 5
903902
fi
904903
done

0 commit comments

Comments
 (0)