-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(cherry picked from commit 9e3501f)
- Loading branch information
Showing
5 changed files
with
110 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ jobs: | |
- run: git fetch origin main | ||
- run: pre-commit run --from-ref origin/main --to-ref HEAD | ||
- run: hatch fmt --check | ||
- run: hatch version | ||
- run: hatch build | ||
- run: hatch test --all | ||
|
||
coverage: | ||
|
@@ -41,10 +43,10 @@ jobs: | |
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
python-version: 3.11 | ||
cache: pip | ||
- run: pip install hatch | ||
- run: hatch test --cover | ||
- run: hatch test -py 3.11 --cover | ||
- uses: codecov/[email protected] | ||
with: | ||
verbose: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ __pycache__ | |
/dist | ||
|
||
#coverage reports | ||
/.coverage | ||
/.coverage* | ||
/coverage.xml | ||
|
||
#auto-generated | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,87 @@ | ||
# /// script | ||
# requires-python = ">=3.9" | ||
# dependencies = [ | ||
# "click", | ||
# ] | ||
# /// | ||
|
||
import pathlib | ||
import shutil | ||
import textwrap | ||
from pathlib import Path | ||
|
||
project_dir: Path = Path(__file__, "../../.dbt_project").resolve() | ||
|
||
print(f"Will generate DBT project at {project_dir}") | ||
|
||
project_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
(project_dir / "dbt_project.yml").write_text("""\ | ||
name: my_pumpkin | ||
version: 1.0.0 | ||
profile: test_pumpkin | ||
models: | ||
my_pumpkin: | ||
+dbt-pumpkin-path: "_schema/{name}.yml" | ||
""") | ||
|
||
(project_dir / "profiles.yml").write_text(f"""\ | ||
test_pumpkin: | ||
target: test | ||
outputs: | ||
test: | ||
# Comment to stop formatting in 1 line | ||
type: duckdb | ||
path: {project_dir}/test.duckdb | ||
threads: 8 | ||
""") | ||
|
||
models_dir = project_dir / "models" | ||
models_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
for i in range(1, 1000): | ||
model_path = models_dir / f"model_{i}.sql" | ||
model_path.write_text("""\ | ||
select 1 as id | ||
import click | ||
|
||
|
||
@click.command | ||
@click.option( | ||
"--project-dir", | ||
envvar="DBT_PROJECT_DIR", | ||
default=".dbt_project", | ||
type=click.Path(path_type=pathlib.Path, resolve_path=True), | ||
) | ||
@click.option( | ||
"--profiles-dir", | ||
envvar="DBT_PROFILES_DIR", | ||
default=".dbt_project", | ||
type=click.Path(path_type=pathlib.Path, resolve_path=True), | ||
) | ||
@click.option("--keep", is_flag=True, default=False, show_default=True, help="Don't prune project dir") | ||
@click.argument("models", default=10, type=int) | ||
def cli(*_, project_dir: Path, profiles_dir: Path, keep: bool, models: int): | ||
""" | ||
Generates simple DBT project which can be used for manual testing of dbt-pumpkin output | ||
""" | ||
|
||
print(f"Will generate DBT project at {project_dir}") | ||
|
||
if not keep and project_dir.exists(): | ||
shutil.rmtree(project_dir) | ||
|
||
project_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
(project_dir / "dbt_project.yml").write_text( | ||
textwrap.dedent("""\ | ||
name: my_pumpkin | ||
version: 1.0.0 | ||
profile: test_pumpkin | ||
models: | ||
my_pumpkin: | ||
+dbt-pumpkin-path: "_schema/{name}.yml" | ||
""") | ||
) | ||
|
||
print(f"Will generate DBT profiles at {profiles_dir}") | ||
|
||
(profiles_dir / "profiles.yml").write_text( | ||
textwrap.dedent(f"""\ | ||
test_pumpkin: | ||
target: test | ||
outputs: | ||
test: | ||
# Comment to stop formatting in 1 line | ||
type: duckdb | ||
path: {project_dir}/test.duckdb | ||
threads: 8 | ||
""") | ||
) | ||
|
||
models_dir = project_dir / "models" | ||
models_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
for i in range(1, models + 1): | ||
model_path = models_dir / f"model_{i}.sql" | ||
model_path.write_text( | ||
textwrap.dedent("""\ | ||
select 1 as id | ||
""") | ||
) | ||
|
||
print("Generated") | ||
|
||
|
||
def main(): | ||
cli() | ||
|
||
|
||
print("Generated") | ||
if __name__ == "__main__": | ||
main() |