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

Migrate arg to artifacts-dir #30

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/ci_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ jobs:
- name: Run e2e test
run: |
docker run --rm \
--volume "$PWD/dbt_project":/dbt_project \
--volume "$PWD/dbt_project/target":/dbt_project/target \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:ci \
dbt-bouncer --dbt-project-dir dbt_project
dbt-bouncer --dbt-artifacts-dir dbt_project/target

github-action-tests:
needs: [pre-commit]
Expand All @@ -168,7 +168,7 @@ jobs:
- name: Run action
uses: ./
with:
dbt-project-dir: dbt_project
dbt-artifacts-dir: dbt_project/target

pex-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -211,4 +211,4 @@ jobs:
run: poetry run pex . -c dbt-bouncer -o ./dist/dbt-bouncer.pex

- name: Test pex file
run: ./dist/dbt-bouncer.pex --dbt-project-dir dbt_project
run: ./dist/dbt-bouncer.pex --dbt-artifacts-dir dbt_project/target
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'dbt-bouncer'
description: 'Configure and enforce conventions for your dbt project.'
inputs:
dbt-project-dir:
dbt-artifacts-dir:
default: '.'
description: 'Directory where your dbt project is located.'
description: 'Directory where the dbt artifacts exists, generally the `target` directory inside a dbt project.'
required: false

runs:
Expand All @@ -14,4 +14,4 @@ runs:
shell: bash
run: |
${{ github.action_path }}/dist/dbt-bouncer.pex \
--dbt-project-dir ${{ inputs.dbt-project-dir }}
--dbt-artifacts-dir ${{ inputs.dbt-artifacts-dir }}
8 changes: 4 additions & 4 deletions dbt_bouncer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

@click.command()
@click.option(
"--dbt-project-dir",
help="Directory where the dbt project exists.",
"--dbt-artifacts-dir",
help="Directory where the dbt artifacts exists, generally the `target` directory inside a dbt project.",
required=True,
type=click.Path(exists=True),
)
@click.version_option()
def cli(dbt_project_dir):
def cli(dbt_artifacts_dir):
logger.info(f"Running dbt_bouncer ({version()})...")

# Load manifest
manifest_json_path = Path(dbt_project_dir) / "target/manifest.json"
manifest_json_path = Path(dbt_artifacts_dir) / "manifest.json"
logger.info(f"Loading manifest.json from {manifest_json_path}...")
if not manifest_json_path.exists():
raise FileNotFoundError(f"No manifest.json found at {manifest_json_path}.")
Expand Down
Binary file modified dist/dbt-bouncer.pex
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_logger_debug() -> None:
runner = CliRunner()
runner.invoke(
cli,
["--dbt-project-dir", "dbt_project"],
["--dbt-artifacts-dir", "dbt_project/target"],
)

assert (
Expand All @@ -29,5 +29,5 @@ def test_logger_debug() -> None:

def test_logger_info(caplog) -> None:
runner = CliRunner()
runner.invoke(cli, ["--dbt-project-dir", "dbt_project"])
runner.invoke(cli, ["--dbt-artifacts-dir", "dbt_project/target"])
assert "Running dbt_bouncer (0.0.0)..." in caplog.text
15 changes: 6 additions & 9 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def test_cli_happy_path(caplog):
runner.invoke(
cli,
[
"--dbt-project-dir",
"dbt_project",
"--dbt-artifacts-dir",
"dbt_project/target",
],
)
assert "Running dbt_bouncer (0.0.0)..." in caplog.text
Expand All @@ -25,8 +25,8 @@ def test_cli_dbt_dir_doesnt_exist():
result = runner.invoke(
cli,
[
"--dbt-project-dir",
"non-existent-directory",
"--dbt-artifacts-dir",
"non-existent-directory/target",
],
)
assert type(result.exception) in [SystemExit]
Expand All @@ -37,12 +37,9 @@ def test_cli_manifest_doesnt_exist(tmp_path):
result = runner.invoke(
cli,
[
"--dbt-project-dir",
"--dbt-artifacts-dir",
tmp_path,
],
)
assert type(result.exception) in [FileNotFoundError]
assert (
result.exception.args[0]
== f"No manifest.json found at {tmp_path / 'target/manifest.json'}."
)
assert result.exception.args[0] == f"No manifest.json found at {tmp_path / 'manifest.json'}."