-
Notifications
You must be signed in to change notification settings - Fork 1.7k
45 lines (42 loc) · 1.65 KB
/
lint_sqlfluff.yml
File metadata and controls
45 lines (42 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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/file-changes-action@v1.2.4
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/annotations-action@v0.5.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
title: "SQLFluff Lint"
input: "./annotations.json"