diff --git a/.github/workflows/diff-quality.yml b/.github/workflows/diff-quality.yml index 42d0fa5..203fedd 100644 --- a/.github/workflows/diff-quality.yml +++ b/.github/workflows/diff-quality.yml @@ -37,6 +37,41 @@ jobs: with: project_id: crypto-stellar credentials_json: "${{ secrets.CREDS_PROD_HUBBLE }}" + + - name: Get changed files + id: get_file_changes + uses: trilom/file-changes-action@v1.2.4 + with: + output: " " + + - name: Get new and changed .sql files in /models to lint + id: get_files_to_lint + shell: bash -l {0} + run: | + # Set the command in the $() brackets as an output to use in later steps + echo "::set-output name=lintees::$( + # Issue where grep regular expressions don't work as expected on the + # Github Actions shell, check dbt/models/ folder + echo \ + $(echo ${{ steps.get_file_changes.outputs.files_modified }} | + tr -s ' ' '\n' | + grep -E '^models.*[.]sql$' | + tr -s '\n' ' ') \ + $(echo ${{ steps.get_file_changes.outputs.files_added }} | + tr -s ' ' '\n' | + grep -E '^models.*[.]sql$' | + tr -s '\n' ' ') + )" + + - name: Lint dbt models + id: sqlfluff_json + if: steps.get_files_to_lint.outputs.lintees != '' + shell: bash -l {0} + run: | + python -m pip install --upgrade pip + dbt deps + sqlfluff lint --format github-annotation --annotation-level failure --nofail ${{ steps.get_files_to_lint.outputs.lintees }} > annotations.json + sed -i '/^\[/!d' annotations.json # see https://github.com/sqlfluff/sqlfluff/issues/2244 - name: Checkout source branch and diff quality run: | diff --git a/models/intermediate/trades/int_trade_agg_day.sql b/models/intermediate/trades/int_trade_agg_day.sql index ba352c1..7cd90a6 100644 --- a/models/intermediate/trades/int_trade_agg_day.sql +++ b/models/intermediate/trades/int_trade_agg_day.sql @@ -9,7 +9,7 @@ with base_trades as ( select date('{{ dbt_airflow_macros.ds() }}') as day_agg - , ledger_closed_at + ledger_closed_at , selling_asset_id , selling_asset_code , selling_asset_issuer