Skip to content

Commit 8f8dd79

Browse files
meta: Added sql linting to CI.
1 parent 475a1c9 commit 8f8dd79

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

.github/workflows/cicd.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
pull_request:
66

77
jobs:
8-
ci:
9-
name: Continuous Integration
8+
ci-node:
9+
name: Continuous Integration Node
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
@@ -20,10 +20,39 @@ jobs:
2020
- run: npm ci
2121
- run: npm test
2222
- run: npm run lint
23+
ci-db:
24+
name: Continuous Integration Database
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
python-version: ["3.10"]
29+
steps:
30+
- uses: actions/checkout@v3
31+
with:
32+
fetch-depth: 0
33+
- name: Set up Python ${{ matrix.python-version }}
34+
uses: actions/setup-python@v3
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
- name: Cache requirements
38+
uses: actions/cache@v3
39+
with:
40+
path: ~/.cache/pip
41+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
42+
restore-keys: |
43+
${{ runner.os }}-pip-
44+
- name: Install requirements
45+
if: steps.cache.outputs.cache-hit != 'true'
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install -r db/linting/requirements.txt
49+
- name: Analysing the SQL code
50+
run: |
51+
bash db/linting/lint.sh
2352
cd:
2453
name: Continuous Deployment
2554
runs-on: ubuntu-latest
26-
needs: ci
55+
needs: [ci-node,ci-db]
2756
if: startsWith(github.ref, 'refs/tags/v')
2857
steps:
2958
- name: Checkout the repository

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ node_modules/
22

33
local_folder/
44

5-
dist/
5+
dist/
6+
7+
.venv/

db/linting/.sqlfluff

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[sqlfluff]
2+
large_file_skip_char_limit = 0
3+
large_file_skip_byte_limit = 0
4+
exclude_rules = L016,LT05,RF05

db/linting/lint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
echo 'Linting migrations folder'
2+
sqlfluff lint source/migrations/ --dialect postgres --ignore parsing --config db/linting/.sqlfluff

db/linting/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sqlfluff>=2.0.0, <=2.1.0

0 commit comments

Comments
 (0)