|
688 | 688 | exit 0
|
689 | 689 | fi
|
690 | 690 |
|
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 |
| -
|
698 | 691 | export PATH="${pkgs.lib.makeBinPath (with pkgs; [
|
699 | 692 | packer
|
700 | 693 | awscli2
|
|
794 | 787 |
|
795 | 788 | show_help() {
|
796 | 789 | cat << EOF
|
797 |
| - Usage: run-testinfra [--help] <ami-name> |
| 790 | + Usage: run-testinfra [--help] <ami-name> [branch] |
798 | 791 |
|
799 | 792 | Trigger the testinfra-test-only workflow to test a specific AMI.
|
800 | 793 |
|
801 | 794 | This script will:
|
802 | 795 | 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) |
804 | 797 | 3. Trigger the testinfra-test-only workflow with the specified AMI name
|
805 | 798 | 4. Watch the workflow progress until completion
|
806 | 799 |
|
807 | 800 | Arguments:
|
808 | 801 | ami-name The name of the AMI to test
|
| 802 | + branch Optional branch to run the workflow on (default: current branch) |
809 | 803 |
|
810 | 804 | Options:
|
811 | 805 | --help Show this help message and exit
|
|
815 | 809 | - Git installed
|
816 | 810 | - Must be run from a git repository
|
817 | 811 |
|
818 |
| - Example: |
| 812 | + Examples: |
819 | 813 | run-testinfra supabase-postgres-abc123
|
| 814 | + run-testinfra supabase-postgres-abc123 develop |
820 | 815 | EOF
|
821 | 816 | }
|
822 | 817 |
|
|
854 | 849 | fi
|
855 | 850 |
|
856 | 851 | AMI_NAME="$1"
|
| 852 | + if [ -n "$2" ]; then |
| 853 | + BRANCH="$2" |
| 854 | + else |
| 855 | + BRANCH=$(git rev-parse --abbrev-ref HEAD) |
| 856 | + fi |
857 | 857 |
|
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 |
864 | 860 | echo "Warning: Running workflow from non-standard branch: $BRANCH"
|
865 | 861 | echo "This is supported for testing purposes."
|
866 | 862 | read -p "Continue? [y/N] " -n 1 -r
|
|
871 | 867 | fi
|
872 | 868 | fi
|
873 | 869 |
|
| 870 | + # Get current repository name |
| 871 | + REPO=$(git remote get-url origin | sed -E 's/.*github.com[:/](.*)\.git/\1/') |
| 872 | +
|
874 | 873 | # 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" |
877 | 876 |
|
878 | 877 | # Wait for workflow to start and get the run ID
|
879 | 878 | echo "Waiting for workflow to start..."
|
880 | 879 | sleep 5
|
881 | 880 |
|
882 | 881 | # 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') |
884 | 883 |
|
885 | 884 | if [ -z "$RUN_ID" ]; then
|
886 | 885 | echo "Error: Could not find workflow run ID"
|
|
894 | 893 |
|
895 | 894 | # Try to watch the run, but handle network errors gracefully
|
896 | 895 | 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 |
898 | 897 | break
|
899 | 898 | else
|
900 | 899 | 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" |
902 | 901 | sleep 5
|
903 | 902 | fi
|
904 | 903 | done
|
|
0 commit comments