Skip to content

Stop tracking go.work.sum #70

Stop tracking go.work.sum

Stop tracking go.work.sum #70

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.26"]
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
# The committed go.work makes the satellite steps below compile against
# this commit's core, not the published one, so a breaking change here
# fails them rather than passing CI silently.
- name: Run tests
run: go test ./... -count=1 -race
- name: Test integrations (gormguard)
run: cd integrations/gormguard && go test ./... -count=1 -race
- name: Test integrations (sqlxguard)
run: cd integrations/sqlxguard && go test ./... -count=1 -race
- name: Test integrations (pgxguard)
run: cd integrations/pgxguard && go test ./... -count=1 -race
- name: Test integrations (bunguard)
run: cd integrations/bunguard && go test ./... -count=1 -race
- name: Test integrations (xormguard)
run: cd integrations/xormguard && go test ./... -count=1 -race
- name: Test integrations (entguard)
run: cd integrations/entguard && go test ./... -count=1 -race
- name: Test parsers (pgparser)
run: cd parsers/pgparser && go test ./... -count=1 -race
- name: Test parsers (mysqlparser)
run: cd parsers/mysqlparser && go test ./... -count=1 -race
# Exercises explain/ against live servers. The tabular EXPLAIN output it
# parses is version-dependent (MySQL 9 defaults @@explain_format to TREE;
# MariaDB emits 10 columns where MySQL emits 12), so this cannot be covered
# by unit tests. Service containers mirror test/integration/docker-compose.yml.
integration:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18.3-alpine
env:
POSTGRES_USER: sqlguard
POSTGRES_PASSWORD: sqlguard
POSTGRES_DB: sqlguard
ports:
- 55432:5432
options: >-
--health-cmd "pg_isready -U sqlguard -d sqlguard"
--health-interval 2s
--health-timeout 5s
--health-retries 30
mysql:
image: mysql:9.7.1
env:
MYSQL_ROOT_PASSWORD: sqlguard
MYSQL_DATABASE: sqlguard
ports:
- 53306:3306
options: >-
--health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -psqlguard"
--health-interval 2s
--health-timeout 5s
--health-retries 30
mariadb:
image: mariadb:12.3.2
env:
MARIADB_ROOT_PASSWORD: sqlguard
MARIADB_DATABASE: sqlguard
ports:
- 53307:3306
options: >-
--health-cmd "mariadb-admin ping -h 127.0.0.1 -uroot -psqlguard"
--health-interval 2s
--health-timeout 5s
--health-retries 30
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version: "1.26"
- name: Run integration tests
run: make test-integration
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Each satellite carries its own go.mod, so golangci-lint at the root
# does NOT reach them — lint every module individually (same MODULES
# set the Makefile loops over).
module:
- .
- integrations/gormguard
- integrations/sqlxguard
- integrations/pgxguard
- integrations/bunguard
- integrations/xormguard
- integrations/entguard
- parsers/pgparser
- parsers/mysqlparser
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version: "1.26"
- uses: golangci/golangci-lint-action@v9
with:
version: v2.12.2
working-directory: ${{ matrix.module }}
args: --timeout=5m
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version: "1.26"
- name: Build CLI
run: go build -o bin/sqlguard ./cmd/sqlguard
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version: "1.26"
# `make coverage` runs every module and merges into a single coverage.out
# (root go test does not reach the satellite modules).
- name: Generate merged coverage
run: make coverage
- name: Upload to Codecov
uses: codecov/codecov-action@v7
with:
files: ./coverage.out
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false