Disable CGO #901
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: [push, pull_request] | |
jobs: | |
test: | |
name: test (postgres ${{ matrix.pgVersion }}) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
pgVersion: ['14.8', '15.3', '16.0', 'latest'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Run tests | |
run: go test ./... | |
env: | |
POSTGRES_VERSION: ${{ matrix.pgVersion }} | |
lint: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
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 | |
license-check: | |
name: License check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- 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: | |
name: examples (postgres ${{ matrix.pgVersion }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
pgVersion: ['14.8', '15.3', '16.0', 'latest'] | |
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@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Run example migrations | |
run: | | |
go run . init | |
for file in ./examples/*.json; do | |
if [ -f "$file" ]; then | |
go run . start --complete $file; | |
fi | |
done | |
build: | |
runs-on: ubuntu-latest | |
needs: [test, lint, examples] | |
env: | |
PGROLL_VERSION: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || github.sha }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Build pgroll (Linux amd64) | |
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/xataio/pgroll/cmd.Version=${PGROLL_VERSION}" -o pgroll.linux.amd64 | |
- name: Build pgroll (Linux arm64) | |
run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-X github.com/xataio/pgroll/cmd.Version=${PGROLL_VERSION}" -o pgroll.linux.arm64 | |
- name: Build pgroll (MacOS amd64) | |
run: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-X github.com/xataio/pgroll/cmd.Version=${PGROLL_VERSION}" -o pgroll.macos.amd64 | |
- name: Build pgroll (MacOS arm64) | |
run: CGO_ENABLED=0 CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-X github.com/xataio/pgroll/cmd.Version=${PGROLL_VERSION}" -o pgroll.macos.arm64 | |
- name: Build pgroll (Windows) | |
run: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-X github.com/xataio/pgroll/cmd.Version=${PGROLL_VERSION}" -o pgroll.win.amd64 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: pgroll.linux.amd64 | |
path: pgroll.linux.amd64 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: pgroll.linux.arm64 | |
path: pgroll.linux.arm64 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: pgroll.macos.amd64 | |
path: pgroll.macos.amd64 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: pgroll.macos.arm64 | |
path: pgroll.macos.arm64 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: pgroll.win.amd64 | |
path: pgroll.win.amd64 | |
release: | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
fail_on_unmatched_files: true | |
files: | | |
artifacts/pgroll.linux.amd64/pgroll.linux.amd64 | |
artifacts/pgroll.linux.arm64/pgroll.linux.arm64 | |
artifacts/pgroll.macos.amd64/pgroll.macos.amd64 | |
artifacts/pgroll.macos.arm64/pgroll.macos.arm64 | |
artifacts/pgroll.win.amd64/pgroll.win.amd64 |