Skip to content

Commit

Permalink
Periodic connector tests workflow: add Accept header per github doc…
Browse files Browse the repository at this point in the history
…s recommendation (#4722)
  • Loading branch information
sherifnada authored Jul 13, 2021
1 parent 427c46f commit 168b0b3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tools/bin/ci_integration_workflow_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,37 @@ set -e

# launches integration test workflows for master builds

if [[ -z "$GITHUB_TOKEN" ]] ; then
if [[ -z "$GITHUB_TOKEN" ]]; then
echo "GITHUB_TOKEN not set..."
exit 1
fi

REPO_API=https://api.github.com/repos/airbytehq/airbyte
WORKFLOW_PATH=.github/workflows/test-command.yml
WORKFLOW_ID=$(curl --header "Authorization: Bearer $GITHUB_TOKEN" "$REPO_API/actions/workflows" | jq -r ".workflows[] | select( .path == \"$WORKFLOW_PATH\" ) | .id")
MATCHING_WORKFLOW_IDS=$(wc -l <<< "${WORKFLOW_ID}")
MATCHING_WORKFLOW_IDS=$(wc -l <<<"${WORKFLOW_ID}")

if [ "$MATCHING_WORKFLOW_IDS" -ne "1" ] ; then
if [ "$MATCHING_WORKFLOW_IDS" -ne "1" ]; then
echo "More than one workflow exists with the path $WORKFLOW_PATH"
exit 1
fi

MAX_RUNNING_MASTER_WORKFLOWS=5
RUNNING_MASTER_WORKFLOWS=$(curl "$REPO_API/actions/workflows/$WORKFLOW_ID/runs?branch=master&status=in_progress" --header "Authorization: Bearer $GITHUB_TOKEN" | jq -r ".total_count")
if [ "$RUNNING_MASTER_WORKFLOWS" -gt "$MAX_RUNNING_MASTER_WORKFLOWS" ] ; then
if [ "$RUNNING_MASTER_WORKFLOWS" -gt "$MAX_RUNNING_MASTER_WORKFLOWS" ]; then
echo "More than $MAX_RUNNING_MASTER_WORKFLOWS integration tests workflows running on master."
echo "Skipping launching workflows."
exit 0
fi

CONNECTORS=$(./gradlew integrationTest --dry-run | grep 'integrationTest SKIPPED' | cut -d: -f 4 | sort | uniq)
echo "$CONNECTORS" | while read -r connector ; do
echo "$CONNECTORS" | while read -r connector; do
echo "Issuing request for connector $connector..."
curl \
-i \
-X POST \
--header "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"$REPO_API/actions/workflows/$WORKFLOW_ID/dispatches" \
-d "{\"ref\":\"master\", \"inputs\": { \"connector\": \"$connector\"} }"
done

0 comments on commit 168b0b3

Please sign in to comment.