yu-iskw / action-sqlfluff

Run sqlfluff with reviewdog to check or format styles
https://github.com/marketplace/actions/run-sqlfluff-with-reviewdog
MIT License
67 stars 27 forks source link

Can't get changed files. #34

Closed tenajima closed 2 years ago

tenajima commented 2 years ago

My repository is like this.

.
├── README.md
├── other_directory
│   └── other_files
├── dbt
│   ├──.sqlfluff
│   ├──packages.yml
|   └── models

And I want to lint to dbt/models/. So my yaml for workflow write like this.

name: sqlfluff with reviewdog
on:
  pull_request:
jobs:
  test-check:
    name: runner / sqlfluff (github-check)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: auth
        uses: google-github-actions/setup-gcloud@v0
        with:
          project_id: unipos-dev-diu
          service_account_key: ${{ secrets.gcp_key }}
          export_default_credentials: true
      - uses: yu-iskw/action-sqlfluff@v3.3.1
        id: lint-sql
        env:
          GCLOUD_PROJECT: my-project
        with:
          working-directory: ./dbt
          github_token: ${{ secrets.github_token }}
          reporter: github-pr-review
          sqlfluff_version: "0.13.0"
          sqlfluff_command: "lint"
          config: "./.sqlfluff"
          paths: './models'
          extra_requirements_txt: './extra_requirements.txt'
      - 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 '.'

I think setting woriking-directory is required, because of running dbt deps. But, then here is not working well... I expect models/marts/hoge.sql, but git diff --name-only --no-color sqlfluff_bot HEAD returns dbt/models/marts/hoge.sql. There is any solutions ?

yu-iskw commented 2 years ago

I think https://github.com/yu-iskw/action-sqlfluff/pull/36 would solve the issue. The patch was released at https://github.com/yu-iskw/action-sqlfluff/releases/tag/v3.3.2 . Can you give it a try?

tenajima commented 2 years ago

I appreciate it! I'll try today, and report the result!

tenajima commented 2 years ago

Thank you so much! This issue has been fixed!