Skip to content

Commit e027e8c

Browse files
committed
progress
1 parent a34d84c commit e027e8c

File tree

2 files changed

+34
-63
lines changed

2 files changed

+34
-63
lines changed

.github/workflows/pull_request.yml

Lines changed: 33 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,20 @@ jobs:
7979
lint:
8080
name: Lint Project
8181
runs-on: ubuntu-latest
82+
services:
83+
postgres:
84+
image: postgres:latest
85+
env:
86+
POSTGRES_USER: postgres
87+
POSTGRES_PASSWORD: postgres
88+
POSTGRES_DB: postgres
89+
ports:
90+
- 5432:5432
8291
steps:
8392
- name: Checkout PR Branch
8493
uses: actions/checkout@v4
8594
with:
8695
submodules: true
87-
- name: Build and start postgres with plpgsql_check
88-
run: |
89-
docker build -t postgres-plpgsql-check:latest .
90-
docker run -d --name postgres \
91-
-e POSTGRES_USER=postgres \
92-
-e POSTGRES_PASSWORD=postgres \
93-
-e POSTGRES_DB=postgres \
94-
-p 5432:5432 \
95-
postgres-plpgsql-check:latest
96-
# Wait for postgres to be ready
97-
sleep 5
98-
docker exec postgres pg_isready -U postgres
9996
- name: Free Disk Space
10097
uses: ./.github/actions/free-disk-space
10198
- name: Install toolchain
@@ -157,33 +154,13 @@ jobs:
157154
env:
158155
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159156

160-
# Build and run custom postgres image with plpgsql_check
161-
- name: Build and start postgres with plpgsql_check
162-
if: runner.os == 'Linux'
163-
run: |
164-
docker build -t postgres-plpgsql-check:latest .
165-
docker run -d --name postgres \
166-
-e POSTGRES_USER=postgres \
167-
-e POSTGRES_PASSWORD=postgres \
168-
-e POSTGRES_DB=postgres \
169-
-p 5432:5432 \
170-
postgres-plpgsql-check:latest
171-
# Wait for postgres to be ready
172-
sleep 5
173-
docker exec postgres pg_isready -U postgres
174-
- name: Build and start postgres with plpgsql_check (Windows)
175-
if: runner.os == 'Windows'
176-
run: |
177-
docker build -t postgres-plpgsql-check:latest .
178-
docker run -d --name postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres -p 5432:5432 postgres-plpgsql-check:latest
179-
Start-Sleep -Seconds 5
180-
docker exec postgres pg_isready -U postgres
157+
# running containers via `services` only works on linux
158+
# https://github.com/actions/runner/issues/1866
159+
- name: Setup postgres
160+
id: postgres
161+
uses: ikalnytskyi/action-setup-postgres@v7
181162
- name: Print Roles
182-
if: runner.os == 'Linux'
183-
run: docker exec postgres psql -U postgres -c "select rolname from pg_roles;"
184-
- name: Print Roles (Windows)
185-
if: runner.os == 'Windows'
186-
run: docker exec postgres psql -U postgres -c "select rolname from pg_roles;"
163+
run: psql ${{ steps.postgres.outputs.connection-uri }} -c "select rolname from pg_roles;"
187164
- name: Run tests
188165
run: cargo test --workspace
189166

@@ -192,23 +169,20 @@ jobs:
192169
Test JS Bindings
193170
# use the same image we use for compiling
194171
runs-on: ubuntu-22.04
172+
services:
173+
postgres:
174+
image: postgres:latest
175+
env:
176+
POSTGRES_USER: postgres
177+
POSTGRES_PASSWORD: postgres
178+
POSTGRES_DB: postgres
179+
ports:
180+
- 5432:5432
195181
steps:
196182
- name: Checkout PR branch
197183
uses: actions/checkout@v4
198184
with:
199185
submodules: true
200-
- name: Build and start postgres with plpgsql_check
201-
run: |
202-
docker build -t postgres-plpgsql-check:latest .
203-
docker run -d --name postgres \
204-
-e POSTGRES_USER=postgres \
205-
-e POSTGRES_PASSWORD=postgres \
206-
-e POSTGRES_DB=postgres \
207-
-p 5432:5432 \
208-
postgres-plpgsql-check:latest
209-
# Wait for postgres to be ready
210-
sleep 5
211-
docker exec postgres pg_isready -U postgres
212186
- name: Free Disk Space
213187
uses: ./.github/actions/free-disk-space
214188
- name: Install toolchain
@@ -231,23 +205,20 @@ jobs:
231205
codegen:
232206
name: Check Codegen
233207
runs-on: ubuntu-22.04
208+
services:
209+
postgres:
210+
image: postgres:latest
211+
env:
212+
POSTGRES_USER: postgres
213+
POSTGRES_PASSWORD: postgres
214+
POSTGRES_DB: postgres
215+
ports:
216+
- 5432:5432
234217
steps:
235218
- name: Checkout PR branch
236219
uses: actions/checkout@v4
237220
with:
238221
submodules: true
239-
- name: Build and start postgres with plpgsql_check
240-
run: |
241-
docker build -t postgres-plpgsql-check:latest .
242-
docker run -d --name postgres \
243-
-e POSTGRES_USER=postgres \
244-
-e POSTGRES_PASSWORD=postgres \
245-
-e POSTGRES_DB=postgres \
246-
-p 5432:5432 \
247-
postgres-plpgsql-check:latest
248-
# Wait for postgres to be ready
249-
sleep 5
250-
docker exec postgres pg_isready -U postgres
251222
- name: Free Disk Space
252223
uses: ./.github/actions/free-disk-space
253224
- name: Install toolchain

crates/pgt_plpgsql_check/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ pub async fn check_plpgsql(
231231
Ok(diagnostics)
232232
}
233233

234-
#[cfg(test)]
234+
#[cfg(all(test, not(target_os = "windows")))]
235235
mod tests {
236236
use sqlx::{Executor, PgPool};
237237

0 commit comments

Comments
 (0)