...

Text file src/edge-infra.dev/hack/scripts/ci/ci-pub-L2-e2e-targets.sh

Documentation: edge-infra.dev/hack/scripts/ci

     1#!/usr/bin/env bash
     2usage() { echo "Usage: $0 [-f use file output]" 1>&2; exit 0; }
     3[ $# -eq 0 ] && usage
     4while getopts ":f:c:h" opt; do
     5    case $opt in 
     6        f) targets_file="$OPTARG" ;;
     7        h | *) usage ;;
     8    esac
     9done
    10
    11# TODO: exit early so we dont trigger an argo run 
    12# that will end in an error because the branch does not exist
    13branch_exists=$(git branch -r | grep -c "$GITHUB_HEAD_REF")
    14echo "branch_exists? $branch_exists"
    15if [[ $branch_exists -eq 1 ]]; then
    16  echo "${GITHUB_HEAD_REF} exists"
    17else 
    18  echo "${GITHUB_HEAD_REF} does not exist"
    19fi
    20
    21# get all integration and end-to-end tests and replace newlines with spaces
    22intTests=$(bazel query "kind(.*_test, attr('tags', 'integration', set($(<"$targets_file"))))"|tr '\r\n' ' ')
    23e2eTests=$(bazel query "kind(.*_test, attr('tags', 'end-to-end', set($(<"$targets_file"))))"|tr '\r\n' ' ')
    24
    25if [ -z "$intTests" ] && [ -z "$e2eTests" ]; then
    26    echo "No integration or end-to-end targets found - exiting"
    27    exit 0
    28fi
    29
    30echo "Integration tests being sent:"
    31echo "$intTests"
    32
    33echo "End-to-end tests being sent:"
    34echo "$e2eTests"
    35
    36commit=$(git rev-parse HEAD)
    37echo "stable commit $commit"
    38
    39pr=$(echo "$GITHUB_REF_NAME" | cut -d "/" -f 1)
    40
    41gcloud pubsub topics publish \
    42  projects/ret-edge-pltf-infra/topics/argo-ci-topic \
    43  --message="
    44  {
    45    \"cluster\": \"gke\", 
    46    \"intTests\": \"$intTests\",
    47    \"e2eTests\": \"$e2eTests\",
    48    \"metadata\": {
    49      \"commitSha\": \"$commit\",
    50      \"repo\": \"$GITHUB_REPOSITORY\",
    51      \"prNumber\": \"$pr\",
    52      \"workflowName\": \"$GITHUB_WORKFLOW\",
    53      \"runID\": \"$GITHUB_RUN_ID\",
    54      \"jobName\": \"$GITHUB_JOB\",
    55      \"headRef\": \"$GITHUB_HEAD_REF\"
    56    }
    57  }"

View as plain text