Skip to content

Add pgroll binary to .gitignore #1963

Add pgroll binary to .gitignore

Add pgroll binary to .gitignore #1963

Workflow file for this run

name: Build
on: [push, pull_request]
permissions:
contents: write
packages: write
jobs:
test:
name: 'test (pg: ${{ matrix.pgVersion }}, schema: ${{ matrix.testSchema }})'
runs-on: ubuntu-latest
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 ./...
env:
POSTGRES_VERSION: ${{ matrix.pgVersion }}
PGROLL_TEST_SCHEMA: ${{ matrix.testSchema }}
lint:
name: lint
runs-on: ubuntu-latest
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@v4
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54.2
# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
args: --timeout=30m --out-format=colored-line-number --config=.golangci.yml
- name: Ensure JSON examples are formatted
run: |
for file in ./examples/*.json; do
if ! diff <(cat $file | jq) <(cat $file); then
echo "$file is not formatted: run 'cat $file | jq' to fix";
exit 1;
fi
done
type-generation:
name: type generation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate types
run: |
make generate
- name: Ensure generated types are up-to-date
run: |
if ! git diff --quiet; then
echo "generated types are out of date!"
echo "run 'make generate' to regenerate type definitions"
exit 1
fi
dead-code-check:
name: dead code check
runs-on: ubuntu-latest
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-latest
steps:
- uses: actions/checkout@v4
- name: Ensure .go files have a license reference
run: |
curl -s https://raw.githubusercontent.com/lluissm/license-header-checker/master/install.sh | bash
./bin/license-header-checker -a -r .github/license-header.txt . go && [[ -z `git status -s` ]]
examples-schema-validation:
name: validate examples JSON
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate example migrations against JSON schema
run: |
npx -y ajv-cli --spec=draft2020 validate --strict-schema=false -s schema.json -d "./examples/*.json"
examples:
name: 'examples (pg: ${{ matrix.pgVersion }}, schema: ${{ matrix.testSchema }})'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pgVersion: ['14.8', '15.3', '16.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
go run . init
for file in ./examples/*.json; do
if [ -f "$file" ]; then
go run . start --complete $file;
fi
done
env:
POSTGRES_PORT: 5432
POSTGRES_HOST: localhost
PGPASSWORD: postgres
PGROLL_SCHEMA: ${{ matrix.testSchema }}
release:
runs-on: ubuntu-latest
needs: [test, lint, examples-schema-validation, examples, license-check, type-generation, dead-code-check]
if: startsWith(github.ref, 'refs/tags/')
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- 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@v5
with:
distribution: goreleaser
version: latest
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 }}