Skip to content

Commit

Permalink
Merge branch 'main' into improve-freshness-config-error-message
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk committed Apr 12, 2024
2 parents af03756 + 6fee361 commit 3a90b11
Show file tree
Hide file tree
Showing 25 changed files with 70 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20231005-151848.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: "Bump actions/checkout from 3 to 4"
time: 2023-10-05T15:18:48.00000Z
custom:
Author: dependabot[bot]
PR: 8781
Issue: 8781
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20231031-131954.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: Begin using DSI 0.4.x
time: 2023-10-31T13:19:54.750009-07:00
custom:
Author: QMalcolm peterallenwebb
PR: "8892"
Issue: "8892"
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20231106-130051.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: Update typing-extensions version to >=4.4
time: 2023-11-06T13:00:51.062386-08:00
custom:
Author: tlento
PR: "9012"
Issue: "9012"
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20231122-001840.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: "Bump ddtrace from 2.1.7 to 2.3.0"
time: 2023-11-22T00:18:40.00000Z
custom:
Author: dependabot[bot]
PR: 9132
Issue: 9132
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20231204-000945.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: "Bump freezegun from 0.3.12 to 1.3.0"
time: 2023-12-04T00:09:45.00000Z
custom:
Author: dependabot[bot]
PR: 9197
Issue: 9197
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20231211-005651.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: "Bump actions/setup-python from 4 to 5"
time: 2023-12-11T00:56:51.00000Z
custom:
Author: dependabot[bot]
PR: 9267
Issue: 9267
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20240115-012030.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: "Bump actions/download-artifact from 3 to 4"
time: 2024-01-15T01:20:30.00000Z
custom:
Author: dependabot[bot]
PR: 9374
Issue: 9374
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20240123-105843.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: remove dbt/adapters and add dependency on dbt-adapters
time: 2024-01-23T10:58:43.286952-08:00
custom:
Author: colin-rogers-dbt
PR: "9430"
Issue: "9430"
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20240129-005734.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: "Bump actions/upload-artifact from 3 to 4"
time: 2024-01-29T00:57:34.00000Z
custom:
Author: dependabot[bot]
PR: 9470
Issue: 9470
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20240129-005743.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: "Bump actions/cache from 3 to 4"
time: 2024-01-29T00:57:43.00000Z
custom:
Author: dependabot[bot]
PR: 9471
Issue: 9471
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20240212-011324.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: "Bump peter-evans/create-pull-request from 5 to 6"
time: 2024-02-12T01:13:24.00000Z
custom:
Author: dependabot[bot]
PR: 9552
Issue: 9552
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20240222-102947.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: Restrict protobuf to 4.* versions
time: 2024-02-22T10:29:47.595435-08:00
custom:
Author: QMalcolm
PR: "9566"
Issue: "9566"
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20240226-004412.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: "Bump codecov/codecov-action from 3 to 4"
time: 2024-02-26T00:44:12.00000Z
custom:
Author: dependabot[bot]
PR: 9659
Issue: 9659
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20240226-123502.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: Cap dbt-semantic-interfaces version range to <0.6
time: 2024-02-26T12:35:02.643779-08:00
custom:
Author: tlento
PR: "9671"
Issue: "9671"
2 changes: 1 addition & 1 deletion .changes/1.8.0/Dependencies-20240227-151115.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: bump dbt-common to accept major version 1
time: 2024-02-27T15:11:15.583604-05:00
custom:
Author: michelleark
PR: "9690"
Issue: "9690"
2 changes: 1 addition & 1 deletion .changes/1.8.0/Security-20240222-152445.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: Update Jinja2 to >= 3.1.3 to address CVE-2024-22195
time: 2024-02-22T15:24:45.158305-08:00
custom:
Author: QMalcolm
PR: CVE-2024-22195
Issue: 9638
2 changes: 1 addition & 1 deletion .changes/unreleased/Dependencies-20240117-100818.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: Relax pathspec upper bound version restriction
time: 2024-01-17T10:08:18.009949641+01:00
custom:
Author: rzjfr
PR: "9373"
Issue: "9373"
52 changes: 4 additions & 48 deletions .changie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,7 @@ kinds:
- {{.Body}} ({{ range $index, $element := $IssueList }}{{if $index}}, {{end}}{{$element}}{{end}})
- label: Under the Hood
- label: Dependencies
changeFormat: |-
{{- $PRList := list }}
{{- $changes := splitList " " $.Custom.PR }}
{{- range $pullrequest := $changes }}
{{- $changeLink := "[#nbr](https://github.com/dbt-labs/dbt-core/pull/nbr)" | replace "nbr" $pullrequest }}
{{- $PRList = append $PRList $changeLink }}
{{- end -}}
- {{.Body}} ({{ range $index, $element := $PRList }}{{if $index}}, {{end}}{{$element}}{{end}})
skipGlobalChoices: true
additionalChoices:
- key: Author
label: GitHub Username(s) (separated by a single space if multiple)
type: string
minLength: 3
- key: PR
label: GitHub Pull Request Number (separated by a single space if multiple)
type: string
minLength: 1
- label: Security
changeFormat: |-
{{- $PRList := list }}
{{- $changes := splitList " " $.Custom.PR }}
{{- range $pullrequest := $changes }}
{{- $changeLink := "[#nbr](https://github.com/dbt-labs/dbt-core/pull/nbr)" | replace "nbr" $pullrequest }}
{{- $PRList = append $PRList $changeLink }}
{{- end -}}
- {{.Body}} ({{ range $index, $element := $PRList }}{{if $index}}, {{end}}{{$element}}{{end}})
skipGlobalChoices: true
additionalChoices:
- key: Author
label: GitHub Username(s) (separated by a single space if multiple)
type: string
minLength: 3
- key: PR
label: GitHub Pull Request Number (separated by a single space if multiple)
type: string
minLength: 1

newlines:
afterChangelogHeader: 1
Expand Down Expand Up @@ -106,18 +70,10 @@ footerFormat: |
{{- $changeList := splitList " " $change.Custom.Author }}
{{- $IssueList := list }}
{{- $changeLink := $change.Kind }}
{{- if or (eq $change.Kind "Dependencies") (eq $change.Kind "Security") }}
{{- $changes := splitList " " $change.Custom.PR }}
{{- range $issueNbr := $changes }}
{{- $changeLink := "[#nbr](https://github.com/dbt-labs/dbt-core/pull/nbr)" | replace "nbr" $issueNbr }}
{{- $IssueList = append $IssueList $changeLink }}
{{- end -}}
{{- else }}
{{- $changes := splitList " " $change.Custom.Issue }}
{{- range $issueNbr := $changes }}
{{- $changeLink := "[#nbr](https://github.com/dbt-labs/dbt-core/issues/nbr)" | replace "nbr" $issueNbr }}
{{- $IssueList = append $IssueList $changeLink }}
{{- end -}}
{{- $changes := splitList " " $change.Custom.Issue }}
{{- range $issueNbr := $changes }}
{{- $changeLink := "[#nbr](https://github.com/dbt-labs/dbt-core/issues/nbr)" | replace "nbr" $issueNbr }}
{{- $IssueList = append $IssueList $changeLink }}
{{- end }}
{{- /* check if this contributor has other changes associated with them already */}}
{{- if hasKey $contributorDict $author }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bot-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
commit_message: "Add automated changelog yaml from template for bot PR"
changie_kind: ${{ matrix.changie_kind }}
label: ${{ matrix.label }}
custom_changelog_string: "custom:\n Author: ${{ github.event.pull_request.user.login }}\n PR: ${{ github.event.pull_request.number }}"
custom_changelog_string: "custom:\n Author: ${{ github.event.pull_request.user.login }}\n Issue: ${{ github.event.pull_request.number }}"
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ jobs:
- name: Install source distributions
# ignore dbt-1.0.0, which intentionally raises an error when installed from source
run: |
find ./dist/dbt-[a-z]*.gz -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/
find ./dist/dbt_[a-z]*.gz -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/
- name: Check source distributions
run: |
Expand Down
13 changes: 11 additions & 2 deletions core/dbt/tests/fixtures/project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
from pathlib import Path
from typing import Mapping

import pytest # type: ignore
import random
from argparse import Namespace
Expand Down Expand Up @@ -493,11 +495,18 @@ def get_tables_in_schema(self):
return {model_name: materialization for (model_name, materialization) in result}


@pytest.fixture(scope="class")
def environment() -> Mapping[str, str]:
# By default, fixture initialization is done with the following environment
# from the os, but this fixture provides a way to customize the environment.
return os.environ


# Housekeeping that needs to be done before we start setting up any test fixtures.
@pytest.fixture(scope="class")
def initialization() -> None:
def initialization(environment) -> None:
# Create an "invocation context," which dbt application code relies on.
set_invocation_context(os.environ)
set_invocation_context(environment)

# Enable caches used between test runs, for better testing performance.
enable_test_caching()
Expand Down
19 changes: 13 additions & 6 deletions tests/functional/partial_parsing/test_pp_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,16 @@ def test_env_vars_models(self, project):


class TestProjectEnvVars:
@pytest.fixture(scope="class")
def environment(self):
custom_env = os.environ.copy()
custom_env["ENV_VAR_NAME"] = "Jane Smith"
return custom_env

@pytest.fixture(scope="class")
def project_config_update(self):
# Need to set the environment variable here initially because
# the project fixture loads the config.
os.environ["ENV_VAR_NAME"] = "Jane Smith"
return {"models": {"+meta": {"meta_name": "{{ env_var('ENV_VAR_NAME') }}"}}}

@pytest.fixture(scope="class")
Expand All @@ -279,6 +284,7 @@ def models(self):

def test_project_env_vars(self, project):
# Initial run
os.environ["ENV_VAR_NAME"] = "Jane Smith"
results = run_dbt(["run"])
assert len(results) == 1
manifest = get_manifest(project.project_root)
Expand Down Expand Up @@ -308,13 +314,14 @@ def models(self):
"model_one.sql": model_one_sql,
}

@pytest.fixture(scope="class")
def environment(self):
custom_env = os.environ.copy()
custom_env["ENV_VAR_HOST"] = "localhost"
return custom_env

@pytest.fixture(scope="class")
def dbt_profile_target(self):
# Need to set these here because the base integration test class
# calls 'load_config' before the tests are run.
# Note: only the specified profile is rendered, so there's no
# point it setting env_vars in non-used profiles.
os.environ["ENV_VAR_HOST"] = "localhost"
return {
"type": "postgres",
"threads": 4,
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_docs_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

from .utils import config_from_parts_or_dicts

from dbt.flags import set_from_args
from argparse import Namespace

set_from_args(Namespace(WARN_ERROR=False), None)

SNOWPLOW_SESSIONS_DOCS = r"""
This table contains one record for every session recorded by Snowplow.
Expand Down
27 changes: 14 additions & 13 deletions tests/unit/test_graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

from argparse import Namespace
import unittest
from unittest.mock import MagicMock, patch

Expand All @@ -23,11 +22,15 @@
from queue import Empty
from .utils import config_from_parts_or_dicts, generate_name_macros, inject_plugin

from dbt.flags import set_from_args
from argparse import Namespace

set_from_args(Namespace(WARN_ERROR=False), None)


class GraphTest(unittest.TestCase):
def tearDown(self):
self.mock_filesystem_search.stop()
self.mock_hook_constructor.stop()
self.load_state_check.stop()
self.load_source_file_patcher.stop()
reset_adapters()
Expand Down Expand Up @@ -69,17 +72,6 @@ def mock_filesystem_search(project, relative_dirs, extension, ignore_spec):
self.mock_filesystem_search = self.filesystem_search.start()
self.mock_filesystem_search.side_effect = mock_filesystem_search

# Create HookParser patcher
self.hook_patcher = patch.object(dbt.parser.hooks.HookParser, "__new__")

def create_hook_patcher(cls, project, manifest, root_project):
result = MagicMock(project=project, manifest=manifest, root_project=root_project)
result.__iter__.side_effect = lambda: iter([])
return result

self.mock_hook_constructor = self.hook_patcher.start()
self.mock_hook_constructor.side_effect = create_hook_patcher

# Create the Manifest.state_check patcher
@patch("dbt.parser.manifest.ManifestLoader.build_manifest_state_check")
def _mock_state_check(self):
Expand Down Expand Up @@ -112,6 +104,15 @@ def mock_load_source_file(path, parse_file_type, project_name, saved_files):

self.mock_source_file.side_effect = mock_load_source_file

# Create hookparser source file patcher
self.load_source_file_manifest_patcher = patch("dbt.parser.manifest.load_source_file")
self.mock_source_file_manifest = self.load_source_file_manifest_patcher.start()

def mock_load_source_file_manifest(path, parse_file_type, project_name, saved_files):
return []

self.mock_source_file_manifest.side_effect = mock_load_source_file_manifest

def get_config(self, extra_cfg=None):
if extra_cfg is None:
extra_cfg = {}
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from dbt.graph.cli import parse_difference
from queue import Empty

from dbt.flags import set_from_args
from argparse import Namespace

set_from_args(Namespace(WARN_ERROR=False), None)


def _mock_manifest(nodes):
config = mock.MagicMock(enabled=True)
Expand Down

0 comments on commit 3a90b11

Please sign in to comment.