Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodic connector tests workflow: add Accept header per github docs recommendation #4722

Merged
merged 4 commits into from
Jul 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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