Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 7 additions & 124 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,132 +9,15 @@ on:
- main

jobs:
test:
test-lint:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [oldstable, stable]
services:
postgres:
image: postgres:17.4
ports:
- 5444:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: password
go-version: [ "1.25", "1.24" ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
- uses: actions/checkout@v4
- run: ls -la ./.github/workflows/
- name: Run test and lint on ${{ matrix.go-version }}
uses: ./.github/workflows/lint-tests.yaml
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
/go/pkg/mod
key: go-mod-v4-${{ hashFiles('**/go.sum') }}
- name: Install Dependencies
run: go mod download
- name: Run tests
run: |
mkdir -p /tmp/test-reports
# gotestsum hash is version version v1.12.3
go run gotest.tools/gotestsum@ddd0b05a6878e2e8257a2abe6e7df66cebc53d0e --junitfile /tmp/test-reports/unit-tests.xml
make test-examples
- uses: actions/upload-artifact@v4
name: Upload test results
with:
name: test-reports-${{ matrix.go-version }}
path: /tmp/test-reports
- name: Update coverage report
uses: ncruces/go-coverage-report@v0.3.0
with:
report: true
chart: true
amend: true
if: |
matrix.go-version == 'stable'
continue-on-error: true

test-race:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [oldstable, stable]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
/go/pkg/mod
key: go-mod-v4-${{ hashFiles('**/go.sum') }}
- name: Install Dependencies
run: go mod download
- name: Run tests with race detector
run: make test-race

lint:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [oldstable, stable]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
/go/pkg/mod
key: go-mod-v4-${{ hashFiles('**/go.sum') }}
- name: Install Dependencies
run: go mod download
- name: Install tooling
run: make tooling
- name: Linting
run: make lint
- name: Running vulncheck
run: make vuln-check

fmt:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [oldstable, stable]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
/go/pkg/mod
key: go-mod-v4-${{ hashFiles('**/go.sum') }}
- name: Install Dependencies
run: go mod download
- name: Install tooling
run: make tooling
- name: Running formatting
run: |
make fmt
make has-changes
go-version: ${{ matrix.go-version }}
172 changes: 172 additions & 0 deletions .github/workflows/lint-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: CI

on:
workflow_call:
inputs:
go-version:
type: string
required: true

jobs:
preflight:
runs-on: ubuntu-latest
outputs:
gopath: ${{ steps.gopath.outputs.value }}
go-mods-cache-key: ${{ steps.cache-keys.outputs.go-mods-cache-key }}
go-bins-cache-key: ${{ steps.cache-keys.outputs.go-bins-cache-key }}
steps:
- uses: actions/checkout@v4
with:
submodules: "false"

- uses: jdx/mise-action@v3
with:
cache: true
reshim: true
tool_versions: |
go ${{ inputs.go-version }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Get Go path
id: gopath
run: echo "value=$(go env GOPATH)" >> $GITHUB_OUTPUT

- name: Cache keys
id: cache-keys
run: |
echo "go-mods-cache-key=go-mods-${{ runner.os }}-${{ hashFiles('**/go.sum') }}" >> $GITHUB_OUTPUT

- name: Cache Go mods
id: go-mods-cache
uses: actions/cache@v4
with:
lookup-only: true
path: ${{ steps.gopath.outputs.value }}/pkg/mod
key: ${{ steps.cache-keys.outputs.go-mods-cache-key }}

- name: 📥 Download dependencies
if: steps.go-mods-cache.outputs.cache-hit != 'true'
run: go mod download



test:
runs-on: ubuntu-latest
needs: preflight
services:
postgres:
image: postgres:17.4
ports:
- 5444:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: password
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v3
with:
cache: true
reshim: true
tool_versions: |
go ${{ inputs.go-version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: 💾 Cache Go mods
uses: actions/cache@v4
with:
path: ${{ needs.preflight.outputs.gopath }}/pkg/mod
key: ${{ needs.preflight.outputs.go-mods-cache-key }}
fail-on-cache-miss: true
- name: Run tests units
run: |
mkdir -p /tmp/test-reports
gotestsum --junitfile /tmp/test-reports/unit-tests.xml
- uses: actions/upload-artifact@v4
name: Upload test results
with:
name: test-reports-${{ matrix.go-version }}
path: /tmp/test-reports
- name: Run Examples
run: make test-examples

- name: Update coverage report
uses: ncruces/go-coverage-report@v0.3.0
with:
report: true
chart: true
amend: true
if: |
matrix.go-version == 'stable'
continue-on-error: true

test-race:
runs-on: ubuntu-latest
needs: preflight
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v3
with:
cache: true
reshim: true
tool_versions: |
go ${{ inputs.go-version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: 💾 Cache Go mods
uses: actions/cache@v4
with:
path: ${{ needs.preflight.outputs.gopath }}/pkg/mod
key: ${{ needs.preflight.outputs.go-mods-cache-key }}
fail-on-cache-miss: true
- name: Run tests with race detector
run: make test-race

lint:
runs-on: ubuntu-latest
needs: preflight
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v3
with:
cache: true
reshim: true
tool_versions: |
go ${{ inputs.go-version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: 💾 Cache Go mods
uses: actions/cache@v4
with:
path: ${{ needs.preflight.outputs.gopath }}/pkg/mod
key: ${{ needs.preflight.outputs.go-mods-cache-key }}
fail-on-cache-miss: true
- name: go vet
run: mise vet
- name: Running staticcheck
run: mise static
- name: Running vulncheck
run: mise vuln

fmt:
runs-on: ubuntu-latest
needs: preflight
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v3
with:
cache: true
reshim: true
tool_versions: |
go ${{ inputs.go-version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: 💾 Cache Go mods
uses: actions/cache@v4
with:
path: ${{ needs.preflight.outputs.gopath }}/pkg/mod
key: ${{ needs.preflight.outputs.go-mods-cache-key }}
fail-on-cache-miss: true
- name: Running formatting
run: |
mise fmt
mise has-changes
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ lint:
staticcheck -checks=all ./...

fmt:
go list -f '{{.Dir}}' ./... | xargs -I {} goimports -local $(BASE_PACKAGE) -w {}
go fmt ./...
goimports -l -w .

vuln-check:
govulncheck ./...
Expand Down
3 changes: 3 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ go = "1.25.1"
"go:honnef.co/go/tools/cmd/staticcheck" = { version = "v0.6.1" }
"go:golang.org/x/vuln/cmd/govulncheck" = { version = "v1.1.4" }
"go:golang.org/x/tools/cmd/goimports" = { version = "v0.20.0" }
"go:gotest.tools/gotestsum" = { version = "ddd0b05a6878e2e8257a2abe6e7df66cebc53d0e" }

[tasks]
test = "go test ./..."
vet = "go vet ./..."
static = "staticcheck -checks=all ./..."
vuln = "govulncheck ./..."
fmt = "go fmt ./... && goimports -l -w ."
has-changes = "git diff --exit-code --quiet HEAD --"
Loading