Skip to content

Merge pull request #104 from xataio/add-postgres-table-parser #265

Merge pull request #104 from xataio/add-postgres-table-parser

Merge pull request #104 from xataio/add-postgres-table-parser #265

Workflow file for this run

name: Build
on:
push:
branches:
- main
tags:
- "**"
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- "**"
permissions:
contents: write
packages: write
jobs:
test:
name: test
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: Run tests
run: make test
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage
integration-test:
name: integration tests
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: Run integration tests
run: make integration-test
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.58.1
# 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
coverage:
if: github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch
runs-on: ubuntu-latest
needs: test # Depends on the artifact uploaded by the "test" job
permissions:
contents: read
actions: read # to download code coverage results from "test" job
pull-requests: write # write permission needed to comment on PR
steps:
- uses: fgrosse/[email protected]
with:
coverage-artifact-name: "code-coverage"
coverage-file-name: "coverage"
root-package: "github.com/xataio/pgstream"
license-check:
name: license check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ensure .go files have a license reference
run: make license-check
release:
runs-on: ubuntu-latest
needs: [test, integration-test, lint, license-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 }}