Skip to content

Commit 1734e59

Browse files
committed
add workflow to lint mimic-iv SQL files on PR
1 parent a89d9d4 commit 1734e59

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.github/workflows/lint_sqlfluff.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: SQLFluff
2+
3+
on:
4+
- pull_request
5+
6+
jobs:
7+
lint-mimic-iv:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: checkout
11+
uses: actions/checkout@v3
12+
- name: Install Python
13+
uses: "actions/setup-python@v2"
14+
with:
15+
python-version: "3.7"
16+
- name: install sqlfluff
17+
run: "pip install sqlfluff==1.4.5"
18+
- name: Get changed files
19+
id: get_file_changes
20+
uses: trilom/[email protected]
21+
with:
22+
output: ' '
23+
24+
- name: Get changed .sql files in mimic-iv concepts folder
25+
id: get_files_to_lint
26+
shell: bash -l {0}
27+
run: |
28+
# Set the command in the $() brackets as an output to use in later steps
29+
echo "::set-output name=lintees::$(
30+
echo \
31+
$(echo ${{ steps.get_file_changes.outputs.files_modified }} |
32+
tr -s ' ' '\n' |
33+
grep -E '^mimic-iv/concepts/.*[.]sql$' |
34+
tr -s '\n' ' ') \
35+
$(echo ${{ steps.get_file_changes.outputs.files_added }} |
36+
tr -s ' ' '\n' |
37+
grep -E '^mimic-iv/concepts/.*[.]sql$' |
38+
tr -s '\n' ' ')
39+
)"
40+
41+
- name: Lint SQL files
42+
id: sqlfluff_json
43+
if: steps.get_files_to_lint.outputs.lintees != ''
44+
shell: bash -l {0}
45+
run: sqlfluff lint --format github-annotation --annotation-level failure --nofail ${{ steps.get_files_to_lint.outputs.lintees }} > annotations.json
46+
- name: Annotate
47+
uses: yuzutech/[email protected]
48+
with:
49+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
50+
title: "SQLFluff Lint"
51+
input: "./annotations.json"

.sqlfluff

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[sqlfluff:core]
22
rules = core,L019
33
large_file_skip_byte_limit = 40000
4+
dialect = bigquery
45

56
[sqlfluff:layout:type:comma]
67
line_position = leading

0 commit comments

Comments
 (0)