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

add ability to launch all integration/standard tests from slash commands #1169

Merged
merged 24 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
53 changes: 8 additions & 45 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ jobs:
- name: Checkout Airbyte
uses: actions/checkout@v2

# - name: Check images exist
# run: ./tools/bin/check_images_exist.sh
- name: Launch Integration Tests
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/jrhizor/add-other-builds'
run: ./tools/bin/ci_integration_workflow_launcher.sh
env:
GITHUB_TOKEN: ${{ secrets.SLASH_COMMAND_PAT }}

- name: Check images exist
run: ./tools/bin/check_images_exist.sh

- name: Pip Caching
uses: actions/cache@v2
Expand Down Expand Up @@ -65,49 +71,6 @@ jobs:
if: success() && github.ref == 'refs/heads/master'
run: ./tools/site/link_checker.sh check_docs

# this should happen as late as possible so we don't accidentally have tests in the wrong stage depending on creds
- name: Write Integration Test Credentials
run: ./tools/bin/ci_credentials.sh
env:
BIGQUERY_INTEGRATION_TEST_CREDS: ${{ secrets.BIGQUERY_INTEGRATION_TEST_CREDS }}
STRIPE_INTEGRATION_TEST_CREDS: ${{ secrets.STRIPE_INTEGRATION_TEST_CREDS }}
GH_INTEGRATION_TEST_CREDS: ${{ secrets.GH_INTEGRATION_TEST_CREDS }}
SALESFORCE_INTEGRATION_TESTS_CREDS: ${{ secrets.SALESFORCE_INTEGRATION_TESTS_CREDS }}
GOOGLE_ANALYTICS_TEST_CREDS: ${{ secrets.GOOGLE_ANALYTICS_TEST_CREDS }}
GOOGLE_ANALYTICS_TEST_TRACKING_ID: ${{ secrets.GOOGLE_ANALYTICS_TEST_TRACKING_ID }}
HUBSPOT_INTEGRATION_TESTS_CREDS: ${{ secrets.HUBSPOT_INTEGRATION_TESTS_CREDS }}
GSHEETS_INTEGRATION_TESTS_CREDS: ${{ secrets.GSHEETS_INTEGRATION_TESTS_CREDS }}
SNOWFLAKE_INTEGRATION_TEST_CREDS: ${{ secrets.SNOWFLAKE_INTEGRATION_TEST_CREDS }}
ADWORDS_INTEGRATION_TEST_CREDS: ${{ secrets.ADWORDS_INTEGRATION_TEST_CREDS }}
FACEBOOK_MARKETING_API_TEST_INTEGRATION_CREDS: ${{ secrets.FACEBOOK_MARKETING_API_TEST_INTEGRATION_CREDS }}
SOURCE_MARKETO_SINGER_INTEGRATION_TEST_CONFIG: ${{ secrets.SOURCE_MARKETO_SINGER_INTEGRATION_TEST_CONFIG }}
SHOPIFY_INTEGRATION_TEST_CREDS: ${{ secrets.SHOPIFY_INTEGRATION_TEST_CREDS }}
AWS_S3_INTEGRATION_TEST_CREDS: ${{ secrets.AWS_S3_INTEGRATION_TEST_CREDS }}
AWS_REDSHIFT_INTEGRATION_TEST_CREDS: ${{ secrets.AWS_REDSHIFT_INTEGRATION_TEST_CREDS }}
MAILCHIMP_TEST_CREDS: ${{ secrets.MAILCHIMP_TEST_CREDS }}

- name: Run Integration Tests (PR)
if: success() && github.ref != 'refs/heads/master'
run: ./tools/bin/integration_test_pr.sh

- name: Run Integration Tests (Master)
if: success() && github.ref == 'refs/heads/master'
run: ./gradlew --no-daemon integrationTest --scan

- name: Run Standard Source Tests (PR)
if: success() && github.ref != 'refs/heads/master'
run: ./tools/bin/standard_test_pr.sh

# todo (cgardens) - just run pr integration tests, until we can fix the build.
# https://airbytehq.slack.com/archives/C019WEENQRM/p1606012092002600?thread_ts=1605924059.000200&cid=C019WEENQRM
- name: Run Standard Source Tests (Master Tmp)
if: success() && github.ref == 'refs/heads/master'
run: ./tools/bin/standard_test_pr.sh

# - name: Run Standard Source Tests (Master)
# if: success() && github.ref == 'refs/heads/master'
# run: ./gradlew --no-daemon standardSourceTestPython --scan

- name: Build Core Docker Images
if: success() && github.ref == 'refs/heads/master'
run: ./gradlew --no-daemon composeBuild --scan
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/slash-commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
with:
token: ${{ secrets.SLASH_COMMAND_PAT }}
commands: |
source-exchangeratesapi-singer
test
static-args: |
ref=${{ steps.getref.outputs.ref }}
dispatch-type: workflow
event-type-suffix: "" # used to map this command to integration-test.yml
23 changes: 0 additions & 23 deletions .github/workflows/source-exchangeratesapi-singer.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/test-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: integration-test
on:
workflow_dispatch:
inputs:
connector:
description: 'Airbyte Connector'
required: true

jobs:
integration_test:
runs-on: ubuntu-latest
steps:
- name: Search for valid integration name format
id: regex
uses: AsasInnab/regex-action@v1
with:
regex_pattern: '^[a-zA-Z0-9-_]+$'
regex_flags: 'i' # required to be set for this plugin
search_string: ${{ github.event.inputs.connector }}
- name: Validate input workflow format
if: steps.regex.outputs.first_match != github.event.inputs.connector
run: echo "The connector provided has an invalid format!" && exit 1
- name: Checkout Airbyte
uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '14'
- uses: actions/setup-node@v1
with:
node-version: '14.7'
- uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Write Integration Test Credentials
run: ./tools/bin/ci_credentials.sh
env:
BIGQUERY_INTEGRATION_TEST_CREDS: ${{ secrets.BIGQUERY_INTEGRATION_TEST_CREDS }}
STRIPE_INTEGRATION_TEST_CREDS: ${{ secrets.STRIPE_INTEGRATION_TEST_CREDS }}
GH_INTEGRATION_TEST_CREDS: ${{ secrets.GH_INTEGRATION_TEST_CREDS }}
SALESFORCE_INTEGRATION_TESTS_CREDS: ${{ secrets.SALESFORCE_INTEGRATION_TESTS_CREDS }}
GOOGLE_ANALYTICS_TEST_CREDS: ${{ secrets.GOOGLE_ANALYTICS_TEST_CREDS }}
GOOGLE_ANALYTICS_TEST_TRACKING_ID: ${{ secrets.GOOGLE_ANALYTICS_TEST_TRACKING_ID }}
HUBSPOT_INTEGRATION_TESTS_CREDS: ${{ secrets.HUBSPOT_INTEGRATION_TESTS_CREDS }}
GSHEETS_INTEGRATION_TESTS_CREDS: ${{ secrets.GSHEETS_INTEGRATION_TESTS_CREDS }}
SNOWFLAKE_INTEGRATION_TEST_CREDS: ${{ secrets.SNOWFLAKE_INTEGRATION_TEST_CREDS }}
ADWORDS_INTEGRATION_TEST_CREDS: ${{ secrets.ADWORDS_INTEGRATION_TEST_CREDS }}
FACEBOOK_MARKETING_API_TEST_INTEGRATION_CREDS: ${{ secrets.FACEBOOK_MARKETING_API_TEST_INTEGRATION_CREDS }}
SOURCE_MARKETO_SINGER_INTEGRATION_TEST_CONFIG: ${{ secrets.SOURCE_MARKETO_SINGER_INTEGRATION_TEST_CONFIG }}
SHOPIFY_INTEGRATION_TEST_CREDS: ${{ secrets.SHOPIFY_INTEGRATION_TEST_CREDS }}
AWS_S3_INTEGRATION_TEST_CREDS: ${{ secrets.AWS_S3_INTEGRATION_TEST_CREDS }}
AWS_REDSHIFT_INTEGRATION_TEST_CREDS: ${{ secrets.AWS_REDSHIFT_INTEGRATION_TEST_CREDS }}
MAILCHIMP_TEST_CREDS: ${{ secrets.MAILCHIMP_TEST_CREDS }}
- run: |
./tools/bin/ci_integration_test.sh ${{ github.event.inputs.connector }}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
integrationTestImplementation project(':airbyte-workers')
integrationTestImplementation project(':airbyte-config:models')
integrationTestImplementation project(':airbyte-protocol:models')
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs)
implementation files(project(':airbyte-integrations:bases:base-singer').airbyteDocker.outputs)
}

integrationTest.dependsOn airbyteDocker
32 changes: 32 additions & 0 deletions tools/bin/ci_integration_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e

# runs integration and/or standard tests for an integration name

connector="$1"
all_integration_tests=$(./gradlew integrationTest --dry-run | grep 'integrationTest SKIPPED' | cut -d: -f 4)
all_standard_python_tests=$(./gradlew standardSourceTestPython --dry-run | grep 'standardSourceTestPython SKIPPED' | cut -d: -f 4)

if [[ "$connector" == "all" ]] ; then
echo "Running: ./gradlew --no-daemon --scan integrationTest standardSourceTestPython"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "Running: ./gradlew --no-daemon --scan integrationTest standardSourceTestPython"
cmd="./gradlew --no-daemon --scan integrationTest standardSourceTestPython"
echo "Running: $cmd"
$cmd

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just $cmd doesn't work, and we'd need to add evals.

# jrhizor in ~/code/airbyte on git:jrhizor/add-other-builds ● [15:01:23]
→ cmd="echo hi"

# jrhizor in ~/code/airbyte on git:jrhizor/add-other-builds ● [15:03:10]
→ $cmd
zsh: command not found: echo hi

Since this is temporary anyways, going to just merge as is and improve later.

./gradlew --no-daemon --scan integrationTest standardSourceTestPython
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
./gradlew --no-daemon --scan integrationTest standardSourceTestPython

else
selected_integration_test=$(echo "$all_integration_tests" | grep "^$connector$" || echo "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not blocking for this PR, but should this selection logic live in a gradle task where we just say "integrationTest" and it figures out whether it's standard python or anything else? That way it can be re-used by any other tools, and is more accessible for anyone new to the repo since it's all wrapped in a gradle task

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. It feels like integrationTest is the right umbrella task, but we'd need to switch that to javaIntegrationTest or something first to put both under it.

selected_standard_python_test=$(echo "$all_standard_python_tests" | grep "^$connector$" || echo "")
integrationTestCommand=":airbyte-integrations:connectors:$connector:integrationTest"
standardPythonTestCommand=":airbyte-integrations:connectors:$connector:standardSourceTestPython"
if [ -n "$selected_integration_test" ] && [ -n "$selected_standard_python_test" ] ; then
echo "Running: ./gradlew --no-daemon --scan $integrationTestCommand $standardPythonTestCommand"
./gradlew --no-daemon --scan "$integrationTestCommand" "$standardPythonTestCommand"
elif [ -z "$selected_integration_test" ] && [ -n "$selected_standard_python_test" ] ; then
echo "Running: ./gradlew --no-daemon --scan $standardPythonTestCommand"
./gradlew --no-daemon --scan "$standardPythonTestCommand"
elif [ -n "$selected_integration_test" ] && [ -z "$selected_standard_python_test" ] ; then
echo "Running: ./gradlew --no-daemon --scan $integrationTestCommand"
./gradlew --no-daemon --scan "$integrationTestCommand"
else
echo "Connector '$connector' not found..."
exit 1
fi
fi
15 changes: 15 additions & 0 deletions tools/bin/ci_integration_workflow_launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

# launches integration test workflows for master builds

# todo: check if existing things already run for these on master
# todo: report status of jobs somewhere

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

echo "TODO..."
15 changes: 0 additions & 15 deletions tools/bin/integration_test_pr.sh

This file was deleted.

11 changes: 0 additions & 11 deletions tools/bin/standard_test_pr.sh

This file was deleted.