diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45cdcd9..e489d94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,18 @@ on: - master pull_request: jobs: + lint: + name: ๐Ÿงน SQL lint + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: make lint + # Deliberately not pre-initializing the .vendor/linter submodule via + # `submodules:` above -- letting `make lint` self-init it (lint.mk) + # is what actually proves that works from a plain clone. + run: make lint + test: strategy: matrix: diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9443c64 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".vendor/linter"] + path = .vendor/linter + url = https://github.com/Postgres-Extensions/linter.git diff --git a/.vendor/linter b/.vendor/linter new file mode 160000 index 0000000..b40aaf7 --- /dev/null +++ b/.vendor/linter @@ -0,0 +1 @@ +Subproject commit b40aaf70be8af80f048da777e551c5b790bd9e69 diff --git a/Makefile b/Makefile index e57011a..1bd051c 100644 --- a/Makefile +++ b/Makefile @@ -2,3 +2,8 @@ include pgxntool/base.mk # Temporary hack testdeps: $(wildcard test/*/*.sql) $(wildcard test/*.sql) # Be careful not to include directories in this + +# sql/count_nulls.sql is the hand-written source the versioned sql/count_nulls--*.sql +# files are generated/derived from; those aren't relinted (see linter's DESIGN.md). +LINT_TARGETS = sql/count_nulls.sql test/ +include lint.mk diff --git a/lint.mk b/lint.mk new file mode 100644 index 0000000..2783a90 --- /dev/null +++ b/lint.mk @@ -0,0 +1,7 @@ +# lint.mk โ€” thin wrapper; the whole local footprint for consuming +# https://github.com/Postgres-Extensions/linter. Everything else lives in +# the .vendor/linter submodule; see its README for available targets/rules. +.vendor/linter/lint.mk: + git submodule update --init -- .vendor/linter + +include .vendor/linter/lint.mk diff --git a/test/core/functions.sql b/test/core/functions.sql index 482526c..ce1d7ae 100644 --- a/test/core/functions.sql +++ b/test/core/functions.sql @@ -12,7 +12,7 @@ $$; * mistake! */ -/* +/* EXCLUDED CODE โ€” unused boilerplate template for new test functions, not meant to be enabled CREATE FUNCTION test__ () RETURNS SETOF text LANGUAGE plpgsql AS $body$ DECLARE @@ -180,7 +180,7 @@ BEGIN ); -- Doesn't work for array types - /* + /* EXCLUDED CODE โ€” doesn't work for array types RETURN NEXT bag_eq( $$SELECT a, b, c, null_count( array[a], array[b], array[c] ) FROM test_data$$ , $$SELECT * FROM test_data$$