Skip to content

[HCI] Padronizações Gerais no Cadastro do Paciente #35

[HCI] Padronizações Gerais no Cadastro do Paciente

[HCI] Padronizações Gerais no Cadastro do Paciente #35

Workflow file for this run

name: SQLFluff
on:
- pull_request
jobs:
lint-models:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Install Python
uses: "actions/setup-python@v2"
with:
python-version: "3.10"
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: '1.7.1'
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- name: Install the project dependencies
run: poetry install --no-interaction
- name: Add Poetry virtualenv to PATH
run: |
echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
- name: Install DBT Dependencies
run: "dbt deps"
- name: Get changed files
id: get_file_changes
uses: trilom/file-changes-action@v1.2.4
with:
output: ' '
- name: Display changed files
run: |
echo "Modified files: ${{ steps.get_file_changes.outputs.files_modified }}"
echo "Added files: ${{ steps.get_file_changes.outputs.files_added }}"
- name: Get 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 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 each SQL file individually
run: |
# Loop through each changed SQL file and lint them individually
for file in ${{ steps.get_file_changes.outputs.files_modified }} ${{ steps.get_file_changes.outputs.files_added }}; do
if [[ $file == *.sql ]]; then
echo "Linting $file"
sqlfluff lint failure $file || exit_code=$?
fi
done
shell: bash
- name: Fail if any file had a linting error
run: |
if [[ -n "$exit_code" ]]; then
exit $exit_code
fi
- name: Lint dbt models
id: sqlfluff_json
if: steps.get_files_to_lint.outputs.lintees != ''
shell: bash -l {0}
run: sqlfluff lint ./models/ > annotations.json
- name: Annotate
uses: yuzutech/annotations-action@v0.3.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
title: "SQLFluff Lint"
input: "./annotations.json"