From 153d4bb059b682d8f507b6a9ebdaa31aeffd0251 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Thu, 1 Feb 2024 09:17:16 -0600 Subject: [PATCH] add back fucntional tests --- .github/workflows/ci_dbt_core_testing.yml | 275 ++++++++++++---------- 1 file changed, 148 insertions(+), 127 deletions(-) diff --git a/.github/workflows/ci_dbt_core_testing.yml b/.github/workflows/ci_dbt_core_testing.yml index 098947e9..c6434f41 100644 --- a/.github/workflows/ci_dbt_core_testing.yml +++ b/.github/workflows/ci_dbt_core_testing.yml @@ -131,7 +131,7 @@ jobs: # Since the dbt-common dependency is pinned in dev-requirements.txt we need to force update it # Since tox installs dependencies but doesn't force update, it won't get overridden in the next - # ssstep since the requirements will already be met + # step since the requirements will already be met - name: "Force update the version of dbt-common@${{ needs.job-prep.outputs.dbt-common-ref }}" run: | pip install pip install git+https://github.com/dbt-labs/dbt-common.git@${{ needs.job-prep.outputs.dbt-common-ref }} --force-reinstall @@ -144,129 +144,150 @@ jobs: - name: "Check installed versions" run: pip freeze - # dbt-core-integration-metadata: - # name: integration test metadata generation - # runs-on: ubuntu-latest - # if: ${{ github.event_name != 'pull_request' }} - # outputs: - # split-groups: ${{ steps.generate-split-groups.outputs.split-groups }} - # include: ${{ steps.generate-include.outputs.include }} - - # steps: - # - name: generate split-groups - # id: generate-split-groups - # run: | - # MATRIX_JSON="[" - # for B in $(seq 1 ${{ env.PYTHON_INTEGRATION_TEST_WORKERS }}); do - # MATRIX_JSON+=$(sed 's/^/"/;s/$/"/' <<< "${B}") - # done - # MATRIX_JSON="${MATRIX_JSON//\"\"/\", \"}" - # MATRIX_JSON+="]" - # echo "split-groups=${MATRIX_JSON}" - # echo "split-groups=${MATRIX_JSON}" >> $GITHUB_OUTPUT - - # - name: generate include - # id: generate-include - # run: | - # INCLUDE=('"python-version":"3.8","os":"windows-latest"' '"python-version":"3.8","os":"macos-latest"' ) - # INCLUDE_GROUPS="[" - # for include in ${INCLUDE[@]}; do - # for group in $(seq 1 ${{ env.PYTHON_INTEGRATION_TEST_WORKERS }}); do - # INCLUDE_GROUPS+=$(sed 's/$/, /' <<< "{\"split-group\":\"${group}\",${include}}") - # done - # done - # INCLUDE_GROUPS=$(echo $INCLUDE_GROUPS | sed 's/,*$//g') - # INCLUDE_GROUPS+="]" - # echo "include=${INCLUDE_GROUPS}" - # echo "include=${INCLUDE_GROUPS}" >> $GITHUB_OUTPUT - - # dbt-core-integration-tests: - # name: (${{ matrix.split-group }}) integration test / python ${{ matrix.python-version }} / ${{ matrix.os }} - # if: ${{ github.event_name != 'pull_request' }} - - # runs-on: ${{ matrix.os }} - # timeout-minutes: 30 - # needs: [job-prep, dbt-core-integration-metadata] - # strategy: - # fail-fast: false - # matrix: - # python-version: ["3.8", "3.9", "3.10", "3.11"] - # os: [ubuntu-20.04] - # split-group: ${{ fromJson(needs.dbt-core-integration-metadata.outputs.split-groups) }} - # include: ${{ fromJson(needs.dbt-core-integration-metadata.outputs.include) }} - # env: - # DBT_INVOCATION_ENV: github-actions - # DBT_TEST_USER_1: dbt_test_user_1 - # DBT_TEST_USER_2: dbt_test_user_2 - # DBT_TEST_USER_3: dbt_test_user_3 - - # steps: - # - name: "Check out the repository@${{ needs.job-prep.outputs.dbt-core-ref }}" - # uses: actions/checkout@v4 - # with: - # repository: dbt-labs/dbt-core - # ref: ${{ needs.job-prep.outputs.dbt-core-ref }} - - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v5 - # with: - # python-version: ${{ matrix.python-version }} - - # - name: Set up postgres (linux) - # if: runner.os == 'Linux' - # uses: ./.github/actions/setup-postgres-linux - - # - name: Set up postgres (macos) - # if: runner.os == 'macOS' - # uses: ./.github/actions/setup-postgres-macos - - # - name: Set up postgres (windows) - # if: runner.os == 'Windows' - # uses: ./.github/actions/setup-postgres-windows - - # - name: "Install python tools & dependencies" - # run: | - # python -m pip install --user --upgrade pip - # python -m pip --version - # python -m pip install -r dev-requirements.txt -r editable-requirements.txt - - # - name: "Check installed versions" - # run: pip freeze - - # - name: "Update the version of dbt-common@${{ needs.job-prep.outputs.dbt-common-ref }}s" - # run: | - # pip install pip install git+https://github.com/dbt-labs/dbt-common.git@${{ needs.job-prep.outputs.dbt-common-ref }} --force-reinstall - - # - name: "Check installed versions" - # run: pip freeze - - # - name: Run tests - # run: | - # python -m pytest {posargs} tests/functional -k "not tests/functional/graph_selection" - # python -m pytest {posargs} tests/functional/graph_selection - # python -m pytest {posargs} tests/adapter - # env: - # PYTEST_ADDOPTS: ${{ format('--splits {0} --group {1}', env.PYTHON_INTEGRATION_TEST_WORKERS, matrix.split-group) }} - - # integration-report: - # if: ${{ always() }} - # name: Integration Test Suite - # runs-on: ubuntu-latest - # needs: [dbt-core-integration-tests] - # steps: - # - name: "Integration Tests Failed" - # if: ${{ contains(needs.dbt-core-integration-tests.result, 'failure') || contains(needs.dbt-core-integration-tests.result, 'cancelled') }} - # # when this is true the next step won't execute - # run: | - # echo "::notice title='Integration test suite failed'" - # exit 1 - - # - name: "Integration Tests Passed" - # if: ${{ github.event_name != 'pull_request' }} - # run: | - # echo "::notice title='Integration test suite passed'" - - # - name: "Integration Tests Skipped" - # if: ${{ github.event_name == 'pull_request' }} - # run: | - # echo "::notice title='Integration test suite skipped on Pull Requests'" + dbt-core-integration-metadata: + name: integration test metadata generation + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' }} + outputs: + split-groups: ${{ steps.generate-split-groups.outputs.split-groups }} + include: ${{ steps.generate-include.outputs.include }} + + steps: + - name: generate split-groups + id: generate-split-groups + run: | + MATRIX_JSON="[" + for B in $(seq 1 ${{ env.PYTHON_INTEGRATION_TEST_WORKERS }}); do + MATRIX_JSON+=$(sed 's/^/"/;s/$/"/' <<< "${B}") + done + MATRIX_JSON="${MATRIX_JSON//\"\"/\", \"}" + MATRIX_JSON+="]" + echo "split-groups=${MATRIX_JSON}" + echo "split-groups=${MATRIX_JSON}" >> $GITHUB_OUTPUT + + - name: generate include + id: generate-include + run: | + INCLUDE=('"python-version":"3.8","os":"windows-latest"' '"python-version":"3.8","os":"macos-latest"' ) + INCLUDE_GROUPS="[" + for include in ${INCLUDE[@]}; do + for group in $(seq 1 ${{ env.PYTHON_INTEGRATION_TEST_WORKERS }}); do + INCLUDE_GROUPS+=$(sed 's/$/, /' <<< "{\"split-group\":\"${group}\",${include}}") + done + done + INCLUDE_GROUPS=$(echo $INCLUDE_GROUPS | sed 's/,*$//g') + INCLUDE_GROUPS+="]" + echo "include=${INCLUDE_GROUPS}" + echo "include=${INCLUDE_GROUPS}" >> $GITHUB_OUTPUT + + dbt-core-integration-tests: + name: (${{ matrix.split-group }}) integration test / python ${{ matrix.python-version }} / ${{ matrix.os }} + if: ${{ github.event_name != 'pull_request' }} + + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + needs: [job-prep, dbt-core-integration-metadata] + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + os: [ubuntu-20.04] + split-group: ${{ fromJson(needs.dbt-core-integration-metadata.outputs.split-groups) }} + include: ${{ fromJson(needs.dbt-core-integration-metadata.outputs.include) }} + env: + DBT_INVOCATION_ENV: github-actions + DBT_TEST_USER_1: dbt_test_user_1 + DBT_TEST_USER_2: dbt_test_user_2 + DBT_TEST_USER_3: dbt_test_user_3 + + steps: + - name: "Check out the repository@${{ needs.job-prep.outputs.dbt-core-ref }}" + uses: actions/checkout@v4 + with: + repository: dbt-labs/dbt-core + ref: ${{ needs.job-prep.outputs.dbt-core-ref }} + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up postgres (linux) + if: runner.os == 'Linux' + uses: ./.github/actions/setup-postgres-linux + + - name: Set up postgres (macos) + if: runner.os == 'macOS' + uses: ./.github/actions/setup-postgres-macos + + - name: Set up postgres (windows) + if: runner.os == 'Windows' + uses: ./.github/actions/setup-postgres-windows + + - name: "Install python tools" + run: | + python -m pip install --user --upgrade pip + python -m pip --version + + # tox takes care of installing the correct version of dbt-core dependencies but we need to + # install them first s that we can override the dbt-common branch + - name: "Manually install dbt-core dependencies" + run: | + python -m pip install -r dev-requirements.txt -r editable-requirements.txt + + # Since the dbt-common dependency is pinned in dev-requirements.txt we need to force update it + # Since tox installs dependencies but doesn't force update, it won't get overridden in the next + # step since the requirements will already be met + - name: "Force update the version of dbt-common@${{ needs.job-prep.outputs.dbt-common-ref }}" + run: | + pip install pip install git+https://github.com/dbt-labs/dbt-common.git@${{ needs.job-prep.outputs.dbt-common-ref }} --force-reinstall + + - name: Run Functional tests + run: tox + env: + TOXENV: integration + DBT_INVOCATION_ENV: github-actions + DBT_TEST_USER_1: dbt_test_user_1 + DBT_TEST_USER_2: dbt_test_user_2 + DBT_TEST_USER_3: dbt_test_user_3 + # DD_CIVISIBILITY_AGENTLESS_ENABLED: true + # DD_API_KEY: ${{ secrets.DATADOG_API_KEY }} + # DD_SITE: datadoghq.com + # DD_ENV: ci + # DD_SERVICE: ${{ github.event.repository.name }} + PYTEST_ADDOPTS: ${{ format('--splits {0} --group {1}', env.PYTHON_INTEGRATION_TEST_WORKERS, matrix.split-group) }} + + + - name: "Check installed versions" + run: pip freeze + + # - name: Run tests + # run: | + # python -m pytest {posargs} tests/functional -k "not tests/functional/graph_selection" + # python -m pytest {posargs} tests/functional/graph_selection + # python -m pytest {posargs} tests/adapter + # env: + # PYTEST_ADDOPTS: ${{ format('--splits {0} --group {1}', env.PYTHON_INTEGRATION_TEST_WORKERS, matrix.split-group) }} + + integration-report: + if: ${{ always() }} + name: Integration Test Suite + runs-on: ubuntu-latest + needs: [dbt-core-integration-tests] + steps: + - name: "Integration Tests Failed" + if: ${{ contains(needs.dbt-core-integration-tests.result, 'failure') || contains(needs.dbt-core-integration-tests.result, 'cancelled') }} + # when this is true the next step won't execute + run: | + echo "::notice title='Integration test suite failed'" + exit 1 + + - name: "Integration Tests Passed" + if: ${{ github.event_name != 'pull_request' }} + run: | + echo "::notice title='Integration test suite passed'" + + - name: "Integration Tests Skipped" + if: ${{ github.event_name == 'pull_request' }} + run: | + echo "::notice title='Integration test suite skipped on Pull Requests'"