From 8bfdd85b0945a45707e143499f20ef5ef2368ac2 Mon Sep 17 00:00:00 2001 From: marcus-snx Date: Wed, 7 Aug 2024 19:35:46 +0300 Subject: [PATCH 1/6] Add sqlfluff workflow --- .github/workflows/sql_linting.yml | 20 ++++++++++++++ transformers/synthetix/.sqlfluff | 37 ++++++++++++++++++++++++++ transformers/synthetix/.sqlfluffignore | 4 +++ 3 files changed, 61 insertions(+) create mode 100644 .github/workflows/sql_linting.yml create mode 100644 transformers/synthetix/.sqlfluff create mode 100644 transformers/synthetix/.sqlfluffignore diff --git a/.github/workflows/sql_linting.yml b/.github/workflows/sql_linting.yml new file mode 100644 index 000000000..1d4156b15 --- /dev/null +++ b/.github/workflows/sql_linting.yml @@ -0,0 +1,20 @@ +name: Lint Transformer Models + +on: + push: + branches: + - main + - 'transformers/**' + +jobs: + lint-models: + runs-on: ubuntu-latest + steps: + - uses: "actions/checkout@v3" + - uses: "actions/setup-python@v3" + with: + python-version: "3.10.0" + - name: Install SQLFluff + run: "pip install sqlfluff" + - name: Lint models + run: "diff-quality --violations=sqlfluff --fail-under 100" diff --git a/transformers/synthetix/.sqlfluff b/transformers/synthetix/.sqlfluff new file mode 100644 index 000000000..8b1c4c38a --- /dev/null +++ b/transformers/synthetix/.sqlfluff @@ -0,0 +1,37 @@ +[sqlfluff] +dialect = postgres +templater = jinja +runaway_limit = 10 +max_line_length = 80 +indent_unit = space + +[sqlfluff:indentation] +tab_space_size = 4 + +[sqlfluff:layout:type:comma] +spacing_before = touch +line_position = trailing + +[sqlfluff:rules:capitalisation.keywords] +capitalisation_policy = lower + +[sqlfluff:rules:aliasing.table] +aliasing = explicit + +[sqlfluff:rules:aliasing.column] +aliasing = explicit + +[sqlfluff:rules:aliasing.expression] +allow_scalar = False + +[sqlfluff:rules:capitalisation.identifiers] +extended_capitalisation_policy = lower + +[sqlfluff:rules:capitalisation.functions] +capitalisation_policy = lower + +[sqlfluff:rules:capitalisation.literals] +capitalisation_policy = lower + +[sqlfluff:rules:ambiguous.column_references] # Number in group by +group_by_and_order_by_style = implicit diff --git a/transformers/synthetix/.sqlfluffignore b/transformers/synthetix/.sqlfluffignore new file mode 100644 index 000000000..32713bc15 --- /dev/null +++ b/transformers/synthetix/.sqlfluffignore @@ -0,0 +1,4 @@ +target/ +dbt_modules/ +macros/ +templates/ From eb8b22c954b145486a9865d7fd24f7b995d20cb8 Mon Sep 17 00:00:00 2001 From: marcus-snx Date: Wed, 7 Aug 2024 19:38:48 +0300 Subject: [PATCH 2/6] Change python version in workflow --- .github/workflows/sql_linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sql_linting.yml b/.github/workflows/sql_linting.yml index 1d4156b15..493193e9f 100644 --- a/.github/workflows/sql_linting.yml +++ b/.github/workflows/sql_linting.yml @@ -13,7 +13,7 @@ jobs: - uses: "actions/checkout@v3" - uses: "actions/setup-python@v3" with: - python-version: "3.10.0" + python-version: "3.10.11" - name: Install SQLFluff run: "pip install sqlfluff" - name: Lint models From e78dd5ca3389f5220de226a9b3cab0ac1c413903 Mon Sep 17 00:00:00 2001 From: marcus-snx Date: Wed, 7 Aug 2024 19:41:28 +0300 Subject: [PATCH 3/6] Fix diff-quality command --- .github/workflows/sql_linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sql_linting.yml b/.github/workflows/sql_linting.yml index 493193e9f..9bdecf90b 100644 --- a/.github/workflows/sql_linting.yml +++ b/.github/workflows/sql_linting.yml @@ -17,4 +17,4 @@ jobs: - name: Install SQLFluff run: "pip install sqlfluff" - name: Lint models - run: "diff-quality --violations=sqlfluff --fail-under 100" + run: "diff-quality --violations=sqlfluff --compare-branch main --fail-under 100" From 024f3794a3ea8964b84c90bf223b716720975977 Mon Sep 17 00:00:00 2001 From: marcus-snx Date: Wed, 7 Aug 2024 19:49:53 +0300 Subject: [PATCH 4/6] Fix workflow file --- .github/workflows/sql_linting.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sql_linting.yml b/.github/workflows/sql_linting.yml index 9bdecf90b..029fe1286 100644 --- a/.github/workflows/sql_linting.yml +++ b/.github/workflows/sql_linting.yml @@ -10,7 +10,9 @@ jobs: lint-models: runs-on: ubuntu-latest steps: - - uses: "actions/checkout@v3" + - uses: "actions/checkout@v4" + with: + - fetch-depth: 0 - uses: "actions/setup-python@v3" with: python-version: "3.10.11" From 57c34f5a737925df6c5436e88e57c5fce7839995 Mon Sep 17 00:00:00 2001 From: marcus-snx Date: Wed, 7 Aug 2024 19:51:39 +0300 Subject: [PATCH 5/6] Fix workflow file again --- .github/workflows/sql_linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sql_linting.yml b/.github/workflows/sql_linting.yml index 029fe1286..f0305de05 100644 --- a/.github/workflows/sql_linting.yml +++ b/.github/workflows/sql_linting.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: "actions/checkout@v4" with: - - fetch-depth: 0 + fetch-depth: 0 - uses: "actions/setup-python@v3" with: python-version: "3.10.11" From adb61a42d5e908fe09fcc7043d5758e5ae35d767 Mon Sep 17 00:00:00 2001 From: marcus-snx Date: Wed, 7 Aug 2024 19:56:35 +0300 Subject: [PATCH 6/6] Fix workflow file again --- .github/workflows/sql_linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sql_linting.yml b/.github/workflows/sql_linting.yml index f0305de05..4634be4b7 100644 --- a/.github/workflows/sql_linting.yml +++ b/.github/workflows/sql_linting.yml @@ -19,4 +19,4 @@ jobs: - name: Install SQLFluff run: "pip install sqlfluff" - name: Lint models - run: "diff-quality --violations=sqlfluff --compare-branch main --fail-under 100" + run: "diff-quality --violations=sqlfluff --compare-branch origin/main --fail-under 100"