From 6c66f9a6d9849d34a0fa72ab8a1127f0e00cf366 Mon Sep 17 00:00:00 2001 From: jnasbyupgrade Date: Tue, 4 Aug 2026 15:41:15 -0500 Subject: [PATCH 1/2] Add SQL style linter (Postgres-Extensions/linter) Vendor the shared org-wide SQL linter as a .vendor/linter submodule with a thin self-initializing lint.mk wrapper, wire it into the root Makefile scoped to sql/count_nulls.sql (the hand-written source; generated version snapshot files are excluded) and test/, and add a make lint CI job. test/core/functions.sql currently has 11 pre-existing comment-line-prefix findings (commented-out template/test code); the CI step is continue-on-error for now so this integration doesn't block on cleaning up that unrelated pre-existing debt. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/ci.yml | 19 +++++++++++++++++++ .gitmodules | 3 +++ .vendor/linter | 1 + Makefile | 5 +++++ lint.mk | 7 +++++++ 5 files changed, 35 insertions(+) create mode 100644 .gitmodules create mode 160000 .vendor/linter create mode 100644 lint.mk diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45cdcd9..496a1d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,25 @@ 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. + # + # continue-on-error: sql/count_nulls.sql (the only sql/ file in + # LINT_TARGETS) is clean, but test/core/functions.sql has + # pre-existing comment-line-prefix findings (commented-out + # template/test code) that are out of scope here and tracked + # separately. Drop continue-on-error once that's cleaned up. + run: make lint + continue-on-error: true + 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 From 56f6c03cabcc1e834490ad104e86b0fafbcadb6d Mon Sep 17 00:00:00 2001 From: jnasbyupgrade Date: Tue, 4 Aug 2026 15:53:50 -0500 Subject: [PATCH 2/2] Fix lint job to be an honest signal: use linter's EXCLUDED CODE marker continue-on-error on the make lint step masked real findings permanently, not just the known pre-existing ones -- any future violation would also report green. The linter (Postgres-Extensions/linter) has a purpose-built suppression convention for exactly this case: an `/* EXCLUDED CODE */` marker on the opening line of a block comment, which is an alias for `sql-lint:disable-block all` and skips comment-style checks for everything inside that block. Apply it narrowly to the two commented-out blocks in test/core/functions.sql that triggered the 11 comment-line-prefix findings (the unused test__ boilerplate template, and the disabled array-type test). make lint now finds 0 issues and exits 0 for real, so continue-on-error can be dropped entirely -- the lint job's pass/fail is now a true signal again. --- .github/workflows/ci.yml | 7 ------- test/core/functions.sql | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 496a1d2..e489d94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,14 +15,7 @@ jobs: # 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. - # - # continue-on-error: sql/count_nulls.sql (the only sql/ file in - # LINT_TARGETS) is clean, but test/core/functions.sql has - # pre-existing comment-line-prefix findings (commented-out - # template/test code) that are out of scope here and tracked - # separately. Drop continue-on-error once that's cleaned up. run: make lint - continue-on-error: true test: strategy: 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$$