From 6a5baba2d0cb428a2e555327446b4c1605944ec1 Mon Sep 17 00:00:00 2001 From: Dave Connors Date: Thu, 16 Feb 2023 16:36:34 -0600 Subject: [PATCH 1/2] seeded with files of each type --- .github/workflows/ci.yml | 21 ++++++++++++--- tests/invalid/dbt_project.yml | 44 +++++++++++++++++++++++++++++++ tests/invalid/packages.yml | 8 ++++++ tests/invalid/schema.yml | 0 tests/invalid/selectors.yml | 0 tests/{ => valid}/dbt_project.yml | 0 tests/valid/packages.yml | 8 ++++++ tests/{ => valid}/schema.yml | 0 tests/valid/selectors.yml | 0 9 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 tests/invalid/dbt_project.yml create mode 100644 tests/invalid/packages.yml create mode 100644 tests/invalid/schema.yml create mode 100644 tests/invalid/selectors.yml rename tests/{ => valid}/dbt_project.yml (100%) create mode 100644 tests/valid/packages.yml rename tests/{ => valid}/schema.yml (100%) create mode 100644 tests/valid/selectors.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3865b3e..eb6bc9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,20 @@ jobs: node-version: 16 - name: install avj run: npm install --no-save ajv-cli@5.0.0 - - name: validate dbt_project.yml sample file - run: npx ajv-cli validate -s schemas/dbt_project.json -d tests/dbt_project.yml - - name: validate sample model YAML file - run: npx ajv-cli validate -s schemas/dbt_yml_files.json -d tests/schema.yml + - name: Validate dbt_project.yml sample files + run: | + npx ajv-cli test -s schemas/dbt_project.json -d tests/valid/dbt_project.yml --valid + npx ajv-cli test -s schemas/dbt_project.json -d tests/invalid/dbt_project.yml --invalid + - name: Validate resource yml sample files + run: | + npx ajv-cli test -s schemas/dbt_yml_files.json -d tests/valid/schema.yml --valid + npx ajv-cli test -s schemas/dbt_yml_files.json -d tests/invalid/schema.yml --invalid + - name: Validate packages.yml sample files + run: | + npx ajv-cli test -s schemas/packages.json -d tests/valid/packages.yml --valid + npx ajv-cli test -s schemas/packages.json -d tests/invalid/packages.yml --invalid + - name: Validate selectors.yml sample files + run: | + npx ajv-cli test -s schemas/selectors.json -d tests/valid/selectors.yml --valid + npx ajv-cli test -s schemas/selectors.json -d tests/invalid/selectors.yml --invalid + diff --git a/tests/invalid/dbt_project.yml b/tests/invalid/dbt_project.yml new file mode 100644 index 0000000..ae13f43 --- /dev/null +++ b/tests/invalid/dbt_project.yml @@ -0,0 +1,44 @@ +# this file was generated with dbt init with dbt 1.2.1 + +# Name your project! Project names should contain only lowercase characters +# and underscores. A good package name should reflect your organization's +# name or the intended use of these models +name: 'test' +version: '1.0.0' +config-version: 2 + +# This setting configures which "profile" dbt uses for this project. +profile: 'test' + +# These configurations specify where dbt should look for different types of files. +# The `model-paths` config, for example, states that models in this project can be +# found in the "models/" directory. You probably won't need to change these! +model-paths: ["models"] +analysis-paths: ["analyses"] +test-paths: ["tests"] +seed-paths: ["seeds"] +macro-paths: ["macros"] +snapshot-paths: ["snapshots"] + +target-path: "target" # directory which will store compiled SQL files +clean-targets: # directories to be removed by `dbt clean` + - "target" + - "dbt_packages" + + +# Configuring models +# Full documentation: https://docs.getdbt.com/docs/configuring-models + +# In this example config, we tell dbt to build all models in the example/ directory +# as tables. These settings can be overridden in the individual model files +# using the `{{ config(...) }}` macro. +models: + test: + # Config indicated by + and applies to all files under models/example/ + example: + +materialized: view + +bogus_key: true + +seeds: + test: + +enabled: false diff --git a/tests/invalid/packages.yml b/tests/invalid/packages.yml new file mode 100644 index 0000000..54f02c4 --- /dev/null +++ b/tests/invalid/packages.yml @@ -0,0 +1,8 @@ +packages: + - package: dbt-labs/dbt-utils + version_number: 1.0.0 + + - git_address: "https://github.com/dbt-labs/dbt-utils.git" + revision: 0.9.2 + + - local_path: /opt/dbt/redshift \ No newline at end of file diff --git a/tests/invalid/schema.yml b/tests/invalid/schema.yml new file mode 100644 index 0000000..e69de29 diff --git a/tests/invalid/selectors.yml b/tests/invalid/selectors.yml new file mode 100644 index 0000000..e69de29 diff --git a/tests/dbt_project.yml b/tests/valid/dbt_project.yml similarity index 100% rename from tests/dbt_project.yml rename to tests/valid/dbt_project.yml diff --git a/tests/valid/packages.yml b/tests/valid/packages.yml new file mode 100644 index 0000000..5729aae --- /dev/null +++ b/tests/valid/packages.yml @@ -0,0 +1,8 @@ +packages: + - package: dbt-labs/dbt-utils + version: 1.0.0 + + - git: "https://github.com/dbt-labs/dbt-utils.git" + revision: 1.0.0 + + - local: /opt/dbt/redshift \ No newline at end of file diff --git a/tests/schema.yml b/tests/valid/schema.yml similarity index 100% rename from tests/schema.yml rename to tests/valid/schema.yml diff --git a/tests/valid/selectors.yml b/tests/valid/selectors.yml new file mode 100644 index 0000000..e69de29 From 056a886dc6e00a513cc6cee9a59dc3a9c2be050f Mon Sep 17 00:00:00 2001 From: Dave Connors Date: Thu, 16 Feb 2023 16:43:55 -0600 Subject: [PATCH 2/2] added data to all files --- tests/invalid/schema.yml | 24 ++++++++++++++++++++++++ tests/invalid/selectors.yml | 8 ++++++++ tests/valid/selectors.yml | 8 ++++++++ 3 files changed, 40 insertions(+) diff --git a/tests/invalid/schema.yml b/tests/invalid/schema.yml index e69de29..7cb767b 100644 --- a/tests/invalid/schema.yml +++ b/tests/invalid/schema.yml @@ -0,0 +1,24 @@ +# this file was generated with dbt init with dbt 1.2.1 + +version: 2 + +models: + - name: my_first_dbt_model + description: "A starter dbt model" + jarrod: saltalamachhia + columns: + - name: id + description: "The primary key for this table" + nomar: garciaparra + tests: + - unique + - not_null + + - name: my_second_dbt_model + description: "A starter dbt model" + columns: + - name: id + description: "The primary key for this table" + tests: + - unique + - not_null diff --git a/tests/invalid/selectors.yml b/tests/invalid/selectors.yml index e69de29..a21a0e2 100644 --- a/tests/invalid/selectors.yml +++ b/tests/invalid/selectors.yml @@ -0,0 +1,8 @@ +selector: + - name: nodes_to_joy + definition: + method_of_attack: tag + value: nightly + dont_include: + - "@tag:daily" + diff --git a/tests/valid/selectors.yml b/tests/valid/selectors.yml index e69de29..ff62f5e 100644 --- a/tests/valid/selectors.yml +++ b/tests/valid/selectors.yml @@ -0,0 +1,8 @@ +selectors: + - name: nodes_to_joy + definition: + method: tag + value: nightly + exclude: + - "@tag:daily" + \ No newline at end of file