Skip to content

Commit

Permalink
Set the templater option to dbt (#4)
Browse files Browse the repository at this point in the history
* Set the templater option to dbt

* Modify tests

* Fix

* Remove the input for working directory

* Fix

* Test

* Update
  • Loading branch information
yu-iskw authored Dec 23, 2021
1 parent bd5886c commit b0cb2cf
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
with:
python-version: ${{ matrix.python }}
- uses: ./
id: list-sql
id: lint-sql
with:
github_token: ${{ secrets.github_token }}
working-directory: "${{ github.workspace }}/testdata/test_failed_dbt"
reporter: github-check
templater: jinja
config: "${{ github.workspace }}/testdata/test_failed_dbt/.sqlfluff"
paths: 'models'
paths: '${{ github.workspace }}/testdata/test_failed_dbt/models'
- name: "Test outputs"
shell: bash
run: |
Expand All @@ -46,13 +46,13 @@ jobs:
with:
python-version: ${{ matrix.python }}
- uses: ./
id: list-sql
id: lint-sql
with:
github_token: ${{ secrets.github_token }}
working-directory: "${{ github.workspace }}/testdata/test_failed_dbt"
reporter: github-pr-check
templater: jinja
config: "${{ github.workspace }}/testdata/test_failed_dbt/.sqlfluff"
paths: 'models'
paths: '${{ github.workspace }}/testdata/test_failed_dbt/models'
- name: "Test outputs"
shell: bash
run: |
Expand All @@ -74,14 +74,14 @@ jobs:
with:
python-version: ${{ matrix.python }}
- uses: ./
id: list-sql
id: lint-sql
continue-on-error: true
with:
github_token: ${{ secrets.github_token }}
working-directory: "${{ github.workspace }}/testdata/test_failed_dbt"
reporter: github-pr-review
templater: jinja
config: "${{ github.workspace }}/testdata/test_failed_dbt/.sqlfluff"
paths: 'models'
paths: '${{ github.workspace }}/testdata/test_failed_dbt/models'
- name: "Test outputs"
shell: bash
run: |
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ inputs:
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
working-directory:
description: 'Working directory relative to the root directory.'
default: '.'
### Flags for reviewdog ###
level:
description: 'Report level for reviewdog [info,warning,error]'
Expand Down Expand Up @@ -55,7 +52,7 @@ inputs:
default: ''
paths:
description: |
PATH is the path to a sql file or directory to lint based on the working directory.
PATH is the path to a sql file or directory to lint.
This can be either a file ('path/to/file.sql'), a path ('directory/of/sql/files'), a single ('-') character to indicate reading from *stdin* or a dot/blank ('.'/' ') which will be interpreted like passing the current working directory as a path argument.
required: true
encoding:
Expand Down Expand Up @@ -156,10 +153,15 @@ jobs:
id: lint-sql
with:
github_token: ${{ secrets.github_token }}
working-directory: "${{ github.workspace }}/testdata/test_failed_dbt"
reporter: github-check
config: "${{ github.workspace }}/testdata/test_failed_dbt/.sqlfluff"
paths: 'models'
reporter: github-pr-review
templater: jinja
config: "${{ github.workspace }}/.sqlfluff"
paths: '${{ github.workspace }}/models'
- name: 'Show outputs (Optional)'
shell: bash
run: |
echo '${{ steps.lint-sql.outputs.sqlfluff-results }}' | jq -r '.'
echo '${{ steps.lint-sql.outputs.sqlfluff-results-rdjson }}' | jq -r '.'
```
## Development
Expand Down
7 changes: 1 addition & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ inputs:
description: 'GITHUB_TOKEN'
required: true
default: '${{ github.token }}'
working-directory:
description: 'Working directory relative to the root directory.'
required: false
default: '.'
### Flags for reviewdog ###
level:
description: 'Report level for reviewdog [info,warning,error]'
Expand Down Expand Up @@ -42,7 +38,7 @@ inputs:
default: ''
paths:
description: |
PATH is the path to a sql file or directory to lint based on the working directory.
PATH is the path to a sql file or directory to lint.
This can be either a file ('path/to/file.sql'), a path ('directory/of/sql/files'), a single ('-') character to indicate reading from *stdin* or a dot/blank ('.'/' ') which will be interpreted like passing the current working directory as a path argument.
required: true
encoding:
Expand Down Expand Up @@ -139,7 +135,6 @@ runs:
REVIEWDOG_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
REVIEWDOG_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }}
REVIEWDOG_ESLINT_FLAGS: ${{ inputs.eslint_flags }}
REVIEWDOG_WORKDIR: ${{ inputs.working-directory }}
REVIEWDOG_TOOL_NAME: ${{ inputs.tool_name }}
SQLFLUFF_VERSION: ${{ inputs.sqlfluff_version }}
SQLFLUFF_CONFIG: ${{ inputs.config }}
Expand Down
4 changes: 0 additions & 4 deletions script.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/bash
set -e

if [ -n "${GITHUB_WORKSPACE}" ]; then
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit
fi

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN:?}"

echo '::group::🐶 Installing sqlfluff ... https://github.com/sqlfluff/sqlfluff'
Expand Down
4 changes: 3 additions & 1 deletion testdata/test_failed_dbt/models/staging/staging_02.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{
config(enabled=true)
config(
enabled=true
)
}}

SELECT
Expand Down
8 changes: 8 additions & 0 deletions testdata/test_failed_dbt/models/staging/staging_03.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{
config(
enabled=true
)
}}

SELECT
1 2 3

0 comments on commit b0cb2cf

Please sign in to comment.