Skip to content

Update init.sql placeholder references #4118

Update init.sql placeholder references

Update init.sql placeholder references #4118

Workflow file for this run

name: Build
on:
pull_request:
push:
branches:
- main
tags:
- 'v*'
permissions:
contents: write
packages: write
jobs:
cross-build:
name: cross-platform build
runs-on: ubuntu-24.04
container:
image: goreleaser/goreleaser-cross:v1.24
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
# Mark the checkout as 'safe' despite being owned by `root`
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: 'v2.5.1'
args: build --snapshot
- uses: actions/upload-artifact@v4
with:
name: platform-binaries
path: dist/
if-no-files-found: error
test:
name: 'test (pg: ${{ matrix.pgVersion }}, schema: ${{ matrix.testSchema }})'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
pgVersion: ['14.8', '15.3', '16.4', '17.0' ,'latest']
testSchema: [ 'public', 'non_public' ]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run tests
run: go test -cover -coverprofile=coverage.out ./...
env:
POSTGRES_VERSION: ${{ matrix.pgVersion }}
PGROLL_TEST_SCHEMA: ${{ matrix.testSchema }}
- name: Archive code coverage results
uses: actions/upload-artifact@v4
if: matrix.pgVersion == 'latest' && matrix.testSchema == 'public'
with:
name: code-coverage
path: coverage.out
lint:
name: lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.1
args: --timeout=30m --config=.golangci.yml
format:
name: format
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Install gofumpt tool
run: |
go install mvdan.cc/gofumpt@latest
- name: Run make format
run: |
chmod 666 pkg/state/init.sql
make format
- name: Ensure code is formatted
run: |
if ! git diff --quiet; then
echo "code formatting is out-of-date!"
echo "run 'make format' to reformat"
exit 1
fi
coverage:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
actions: read
pull-requests: write
steps:
- uses: fgrosse/[email protected]
with:
coverage-artifact-name: "code-coverage"
coverage-file-name: "coverage.out"
root-package: "github.com/xataio/pgroll"
code-generation:
name: code generation
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Generate code
run: |
chmod 666 pkg/state/init.sql
make generate
- name: Ensure generated code is up-to-date
run: |
if ! git diff --quiet; then
echo "generated code is out of date!"
echo "run 'make generate' to regenerate"
exit 1
fi
check-ledger:
name: check ledger
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Generate ledger
run: |
make ledger
- name: Ensure ledger is up to date
run: |
if ! git diff --quiet; then
echo "generated ledger is out of date!"
echo "run 'make ledger' to regenerate the ledger"
exit 1
fi
dead-code-check:
name: dead code check
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Install deadcode tool
run: |
go install golang.org/x/tools/cmd/deadcode@latest
- name: Run deadcode analysis
run: |
deadcode --test ./... > deadcode.out
if [ -s deadcode.out ]; then
echo "Dead code analysis found the following dead code:"
cat deadcode.out
exit 1
fi
license-check:
name: license check
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Ensure .go files have a license reference
run: |
make license && [[ -z `git status -s` ]]
examples:
name: 'examples (pg: ${{ matrix.pgVersion }}, schema: ${{ matrix.testSchema }})'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
pgVersion: ['14.8', '15.3', '16.4', '17.0' ,'latest']
testSchema: [ 'public', 'non_public' ]
services:
postgres:
image: postgres:${{ matrix.pgVersion }}
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run example migrations
run: |
if [ "$PGROLL_SCHEMA" != "public" ]; then
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -c "CREATE SCHEMA $PGROLL_SCHEMA;"
fi
make examples
env:
POSTGRES_PORT: 5432
POSTGRES_HOST: localhost
PGPASSWORD: postgres
PGROLL_SCHEMA: ${{ matrix.testSchema }}
release:
runs-on: ubuntu-24.04
container:
image: goreleaser/goreleaser-cross:v1.24
needs: [test, lint, examples, license-check, format, code-generation, dead-code-check, check-ledger, cross-build]
if: startsWith(github.ref, 'refs/tags/')
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Mark the checkout as 'safe' despite being owned by `root`
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
- run: git fetch --force --tags
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: 'v2.5.1'
args: release --clean
env:
# We use two GitHub tokens here:
# * The actions-bound `GITHUB_TOKEN` with permissions to write packages.
# * The org level `GIT_TOKEN` to be able to publish the brew tap file.
# See: https://goreleaser.com/errors/resource-not-accessible-by-integration/
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
GITHUB_USERNAME: ${{ github.repository_owner }}
DOCKER_USERNAME: ghcr.io/${{ github.repository_owner }}
- name: Set up PostgreSQL client
run: |
apt-get update
apt-get install -y postgresql-client
- name: Update doc versions on pgroll.com
run: |
# Insert new doc version
psql "$DATABASE_URL" -c "INSERT INTO doc_versions (version, owner, repository, ref, config_path, examples_path) \
VALUES ( \
'${{ github.ref_name }}', \
'xataio', \
'pgroll', \
'${{ github.ref_name }}', \
'docs/config.json', \
'examples/')"
# Update 'latest' row to point to the new tag
psql "$DATABASE_URL" -c "UPDATE doc_versions SET ref='${{ github.ref_name }}' WHERE version='latest'"
echo "Database updated successfully with version ${{ github.ref_name }}"
env:
DATABASE_URL: ${{ secrets.PGROLL_COM_DATABASE_URL }}