Skip to content

1.2.0 rc: parser as WebAssembly (no cgo), PostgreSQL 18 parser embedded #34

1.2.0 rc: parser as WebAssembly (no cgo), PostgreSQL 18 parser embedded

1.2.0 rc: parser as WebAssembly (no cgo), PostgreSQL 18 parser embedded #34

Workflow file for this run

name: test
on:
push:
branches: [main]
pull_request:
permissions:
contents: write # the coverage badge is committed back to main
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
# pg_dump for the migration side: its major version must be at least the embedded
# server's (17), which Ubuntu's own packages lag behind
- name: Install PostgreSQL 17 client
run: |
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -fsSL -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update -q
sudo apt-get install -y -q postgresql-client-17
# /usr/bin/pg_dump is Ubuntu's wrapper and picks the default (older) cluster version
echo /usr/lib/postgresql/17/bin >> "$GITHUB_PATH"
/usr/lib/postgresql/17/bin/pg_dump --version
# the embedded PostgreSQL archive, its extracted binaries + initialized template data
# directory (internal/oracle), and PostgreSQL's regression corpus (TestRegress)
- name: Cache PostgreSQL binaries and regress corpus
uses: actions/cache@v4
with:
path: |
~/.embedded-postgres-go
~/.cache/sqlshape
key: sqlshape-pg-${{ hashFiles('internal/oracle/oracle.go', 'internal/analyze/testdata/tools/fetch-regress.sh') }}
- name: Fetch regress corpus
run: internal/analyze/testdata/tools/fetch-regress.sh
# the binary as users run it: as a vettool over the examples
- name: Smoke test
run: go build -o sqlshape ./cmd/sqlshape && .github/scripts/smoke.sh ./sqlshape
# coverage counts every package except the catalog generator (a manual tool run
# against a PostgreSQL) and the 5-statement main; the generated protobuf node types
# (internal/pgparse/pg_query.pb.go, 40k lines of accessors) are dropped from the profile.
# -count=1: a cached test result replays the profile it recorded, with block positions
# from the sources of that run; after an edit to a package the cached package does not
# depend on, the stale blocks no longer line up and the merged total drops by ten points
- name: Test
run: |
pkgs=$(go list ./... | grep -v -e /internal/catalog/gen -e /cmd/sqlshape | paste -sd,)
go test ./... -count=1 -coverpkg="$pkgs" -coverprofile=cover.out -timeout 20m
grep -v '/pg_query\.pb\.go:' cover.out > cover.filtered && mv cover.filtered cover.out
# coverage badge: statement coverage of the whole module, committed as an SVG so the
# README can show it without a third-party service; --min makes it a regression gate
- name: Coverage badge
run: python3 .github/scripts/coverage_badge.py --min 90 cover.out .github/badges/coverage.svg
- name: Commit coverage badge
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .github/badges
if ! git diff --cached --quiet; then
git commit -m "CI: coverage badge [skip ci]"
git push
fi
# The analyzer against PostgreSQL 18: the embedded catalog loads, the oracle boots, and
# the regress probe replays 18's corpus (asserting its baseline once there is one).
pg18:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Cache PostgreSQL 18 binaries and regress corpus
uses: actions/cache@v4
with:
path: ~/.cache/sqlshape
key: sqlshape-pg18-${{ hashFiles('internal/oracle/oracle.go', 'internal/analyze/testdata/tools/fetch-regress.sh') }}
- name: Fetch regress corpus
run: internal/analyze/testdata/tools/fetch-regress.sh REL_18_3
- name: Test
env:
SQLSHAPE_PG: "18"
run: |
go test ./internal/catalog ./internal/oracle -count=1
go test ./internal/analyze -run 'TestRegress$' -count=1 -v -timeout 25m 2>&1 | grep -E 'statements:|hits|PASS|FAIL|ok '