diff --git a/.github/scripts/integration-test-matrix.js b/.github/scripts/integration-test-matrix.js index b3190206f..a138ac469 100644 --- a/.github/scripts/integration-test-matrix.js +++ b/.github/scripts/integration-test-matrix.js @@ -8,47 +8,39 @@ module.exports = ({ context }) => { // `changes` is a list of adapter names that have related // file changes in the PR // ex: ['postgres', 'snowflake'] - const changes = JSON.parse(process.env.CHANGES); const labels = context.payload.pull_request.labels.map(({ name }) => name); console.log("labels", labels); - console.log("changes", changes); const testAllLabel = labels.includes("test all"); const include = []; for (const adapter of supportedAdapters) { - if ( - changes.includes(adapter) || - testAllLabel || - labels.includes(`test ${adapter}`) - ) { - for (const pythonVersion of supportedPythonVersions) { - if ( - pythonVersion === defaultPythonVersion || - labels.includes(`test python${pythonVersion}`) || - testAllLabel - ) { - // always run tests on ubuntu by default + for (const pythonVersion of supportedPythonVersions) { + if ( + pythonVersion === defaultPythonVersion || + labels.includes(`test python${pythonVersion}`) || + testAllLabel + ) { + // always run tests on ubuntu by default + include.push({ + os: "ubuntu-latest", + adapter, + "python-version": pythonVersion, + }); + + if (labels.includes("test windows") || testAllLabel) { include.push({ - os: "ubuntu-latest", + os: "windows-latest", adapter, "python-version": pythonVersion, }); + } - if (labels.includes("test windows") || testAllLabel) { - include.push({ - os: "windows-latest", - adapter, - "python-version": pythonVersion, - }); - } - - if (labels.includes("test macos") || testAllLabel) { - include.push({ - os: "macos-latest", - adapter, - "python-version": pythonVersion, - }); - } + if (labels.includes("test macos") || testAllLabel) { + include.push({ + os: "macos-latest", + adapter, + "python-version": pythonVersion, + }); } } } diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 278e85bf5..4964d10bf 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -33,6 +33,9 @@ on: pull_request_target: # manual trigger workflow_dispatch: + # run this once per night to ensure no regressions from latest dbt-core changes + schedule: + - cron: '0 5 * * *' # 5 UTC # explicitly turn off permissions for `GITHUB_TOKEN` permissions: read-all @@ -74,21 +77,6 @@ jobs: persist-credentials: false ref: ${{ github.event.pull_request.head.sha }} - - name: Check if relevant files changed - # https://github.com/marketplace/actions/paths-changes-filter - # For each filter, it sets output variable named by the filter to the text: - # 'true' - if any of changed files matches any of filter rules - # 'false' - if none of changed files matches any of filter rules - # also, returns: - # `changes` - JSON array with names of all filters matching any of the changed files - uses: dorny/paths-filter@v2 - id: get-changes - with: - token: ${{ secrets.GITHUB_TOKEN }} - filters: | - redshift: - - 'dbt/**' - - 'tests/**' - name: Generate integration test matrix id: generate-matrix uses: actions/github-script@v4 diff --git a/dev_requirements.txt b/dev_requirements.txt index 7b29eb359..76d4f8427 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,7 +1,7 @@ # install latest changes in dbt-core + dbt-postgres -# TODO: how to automate switching from develop to version branches? -git+https://github.com/dbt-labs/dbt.git@develop#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt.git@develop#egg=dbt-postgres&subdirectory=plugins/postgres +# TODO: how to switch from HEAD to x.y.latest branches after minor releases? +git+https://github.com/dbt-labs/dbt.git#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt.git#egg=dbt-postgres&subdirectory=plugins/postgres bumpversion flake8 diff --git a/tests/unit/test_context.py b/tests/unit/test_context.py index b6598a224..12f250b71 100644 --- a/tests/unit/test_context.py +++ b/tests/unit/test_context.py @@ -446,16 +446,20 @@ def test_resolve_specific(config, manifest_extended, redshift_adapter, get_inclu manifest=manifest_extended, ) + ctx['adapter'].config.dispatch + # macro_a exists, but default__macro_a and redshift__macro_a do not with pytest.raises(dbt.exceptions.CompilationException): ctx['adapter'].dispatch('macro_a').macro - + assert ctx['adapter'].dispatch('some_macro').macro is package_rs_macro - assert ctx['adapter'].dispatch('some_macro', packages=[ - 'dbt']).macro is rs_macro - assert ctx['adapter'].dispatch('some_macro', packages=[ - 'root']).macro is package_rs_macro - assert ctx['adapter'].dispatch('some_macro', packages=[ - 'root', 'dbt']).macro is package_rs_macro - assert ctx['adapter'].dispatch('some_macro', packages=[ - 'dbt', 'root']).macro is rs_macro + assert ctx['adapter'].dispatch('some_macro', 'dbt').macro is rs_macro + assert ctx['adapter'].dispatch('some_macro', 'root').macro is package_rs_macro + + # override 'dbt' namespace, dispatch to 'root' first + ctx['adapter'].config.dispatch = [{'macro_namespace': 'dbt', 'search_order': ['root', 'dbt']}] + assert ctx['adapter'].dispatch('some_macro', macro_namespace = 'dbt').macro is package_rs_macro + + # override 'root' namespace, dispatch to 'dbt' first + ctx['adapter'].config.dispatch = [{'macro_namespace': 'root', 'search_order': ['dbt', 'root']}] + assert ctx['adapter'].dispatch('some_macro', macro_namespace='root').macro is rs_macro