Skip to content

Commit 2ccefc8

Browse files
sfc-gh-npukasfc-gh-mslot
authored andcommitted
Make linting its own workflow (#317)
lint-check-18 will error so we cannot merge a PR, but will allow the rest of the tests to run without needing to immediately fix a simple formatting bug. --- Signed-off-by: Naisila Puka <naisila.puka@snowflake.com>
1 parent d4c7638 commit 2ccefc8

4 files changed

Lines changed: 68 additions & 13 deletions

File tree

.github/actions/build-and-install/action.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ runs:
3333
run: |
3434
python3.11 -m pipenv install --dev
3535
36-
- name: Check formatting
37-
shell: bash
38-
run: |
39-
make check-indent PG_INDENT=/home/postgres/pgsql-${PG_INDENT_VERSION}/bin/pgindent
40-
4136
- name: Check for typos # ;)
4237
uses: ./.github/actions/check-typos
4338

.github/workflows/lint.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Check formatting for pg_lake repos
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
pg_version:
7+
required: true
8+
type: string
9+
image_tag:
10+
required: true
11+
type: string
12+
13+
env:
14+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
20+
container:
21+
image: ghcr.io/snowflake-labs/pg-lake-ci-pg-almalinux:${{ inputs.image_tag }}
22+
options: --user 1001 --shm-size=128MB
23+
volumes:
24+
- /usr/local:/host/usr/local
25+
credentials:
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
name: Check out repository code
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Export PGDIR, PATH and PG_REGRESS_DIR
36+
run: |
37+
echo "PGDIR=/home/postgres/pgsql-${{ inputs.pg_version }}" >> $GITHUB_ENV
38+
echo "PATH=/home/postgres/pgsql-${{ inputs.pg_version }}/bin:$PATH" >> $GITHUB_ENV
39+
echo "PG_REGRESS_DIR=/home/postgres/pgsql-${{ inputs.pg_version }}/regress" >> $GITHUB_ENV
40+
41+
- uses: actions/cache@v4
42+
id: cache_pipenv
43+
name: Cache pipenv
44+
with:
45+
path: ~/.local/share/virtualenvs
46+
key: ${{ runner.os }}-python-3.11-pipenv-${{ hashFiles('Pipfile.lock') }}
47+
48+
- name: Install pipenv dependencies
49+
if: steps.cache_pipenv.outputs.cache-hit != 'true'
50+
run: |
51+
python3.11 -m pipenv install --dev
52+
53+
- name: Check formatting
54+
run: |
55+
make check-indent

.github/workflows/pytest_all.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ env:
1414
CDWREGIONTEST_SECRET_ACCESS_KEY: ${{ secrets.cdwregiontest_secret_access_key }}
1515
ORG: snowflake-labs
1616
PG_LAKE_DELTA_SUPPORT: 1
17-
PG_INDENT_VERSION: 18
1817

1918
jobs:
2019
build-image-almalinux:
@@ -131,6 +130,14 @@ jobs:
131130
container_os: 'debian'
132131
pg_version: ${{ matrix.pg_version }}
133132

133+
# Formatting checks only on one postgres version
134+
lint-check-18:
135+
needs: [build-image-almalinux]
136+
uses: ./.github/workflows/lint.yml
137+
with:
138+
pg_version: "18"
139+
image_tag: ${{ needs.build-image-almalinux.outputs.tag }}
140+
134141
test-check:
135142
needs: [build-image-almalinux, build-and-install-almalinux]
136143
runs-on: ubuntu-latest

Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ UNAME_S := $(shell uname -s)
4848

4949
# List of targets for indent checks
5050
INDENT_TARGETS = pgduck_server $(EXTENSION_TARGETS)
51-
PG_INDENT_VERSION = 18
52-
PG_INDENT ?= pgindent
53-
TYPEDEFS = /tmp/typedefs-$(PG_INDENT_VERSION).list
51+
TYPEDEFS = /tmp/typedefs-$(PG_MAJOR_VERSION).list
5452

5553
CMAKE_AVRO_ARGS = -DCMAKE_INSTALL_PREFIX=avrolib -DCMAKE_BUILD_TYPE=RelWithDebInfo
5654

@@ -65,22 +63,22 @@ endif
6563

6664
# style/indent-related changes
6765

68-
# This target ensures that we download the PG_INDENT_VERSION's typedefs.list
66+
# This target ensures that we download the target major version's typedefs.list
6967
# from buildfarm if we don't have a local copy. Since we currently do not
7068
# override the typedefs.list, this should be equivalent to what we were
7169
# previously doing by pulling from the postgres source tree.
7270

7371
typedefs: $(TYPEDEFS)
7472

7573
$(TYPEDEFS):
76-
curl -o $(TYPEDEFS) https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?branch=REL_$(PG_INDENT_VERSION)_STABLE
74+
curl -o $(TYPEDEFS) https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?branch=REL_$(PG_MAJOR_VERSION)_STABLE
7775

7876
check-indent: typedefs
79-
$(PG_INDENT) --typedefs=$(TYPEDEFS) --check --diff $(INDENT_TARGETS)
77+
pgindent --typedefs=$(TYPEDEFS) --check --diff $(INDENT_TARGETS)
8078
pipenv run black --check --diff $(INDENT_TARGETS)
8179

8280
reindent: typedefs
83-
$(PG_INDENT) --typedefs=$(TYPEDEFS) $(INDENT_TARGETS)
81+
pgindent --typedefs=$(TYPEDEFS) $(INDENT_TARGETS)
8482
pipenv run black $(INDENT_TARGETS)
8583

8684
submodules:

0 commit comments

Comments
 (0)