Skip to content

Fix SQLFluff test and derived tables copying #100

Fix SQLFluff test and derived tables copying

Fix SQLFluff test and derived tables copying #100

Workflow file for this run

name: SQLFluff
on:
- pull_request
jobs:
lint-mimic-iv:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: install sqlfluff
run: "pip install sqlfluff==3.5.0"
- name: Get changed files
id: get_file_changes
uses: trilom/[email protected]
with:
output: ' '
- name: Get changed .sql files in mimic-iv concepts folder
id: get_files_to_lint
shell: bash
run: |
# Compose list of changed SQL files under mimic-iv/concepts and export to step output
raw="${{ steps.get_file_changes.outputs.files_modified }} ${{ steps.get_file_changes.outputs.files_added }}"
# Check for mimic-iv SQL files which may have changed
filtered="$(printf '%s' "$raw" | tr -s ' ' '\n' | grep -E '^mimic-iv/concepts/.*[.]sql$' || true)"
# Turn this into a space separated list for the next step
files="$(printf '%s' "$filtered" | tr -s '\n' ' ')"
echo "lintees=${files}" >> "$GITHUB_OUTPUT"
- name: Lint SQL files
id: sqlfluff_json
if: steps.get_files_to_lint.outputs.lintees != ''
shell: bash
run: sqlfluff lint --format github-annotation --annotation-level failure --nofail ${{ steps.get_files_to_lint.outputs.lintees }} > annotations.json
- name: Annotate
uses: yuzutech/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
title: "SQLFluff Lint"
input: "./annotations.json"