Skip to content
Merged
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
117 changes: 117 additions & 0 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

go-databasing is a Go library providing direct database access for Senzing databases. This is a Senzing Garage project (experimental/development) with semantic versions `0.n.x` - not production-ready.

**Supported databases:** PostgreSQL, SQLite, MySQL, MS SQL Server, Oracle, DB2 (partial)

## Build Commands

```bash
# First-time setup (installs golangci-lint, gotestfmt, govulncheck, godoc, etc.)
make dependencies-for-development

# Update Go module dependencies
make dependencies

# Build for current platform
make build

# Build for all platforms (darwin/linux/windows × amd64/arm64)
make build-all
```

## Testing

Tests require running database services via Docker Compose.

```bash
# Start database services (PostgreSQL, MySQL, MS SQL, Oracle)
make setup

# Run tests (with gotestfmt output)
make test

# Run tests with coverage report (opens HTML in browser)
make coverage

# Verify coverage meets thresholds
make check-coverage

# Stop services and clean up
make clean
```

Run a single test:

```bash
go test -v -run TestFunctionName ./path/to/package
```

Tests run with `-p 1` (serial execution) due to database resource constraints.

## Linting

```bash
# Run all linters (golangci-lint + govulncheck + cspell)
make lint

# Individual linters
make golangci-lint
make govulncheck
make cspell
make bearer # Security scanning

# Auto-fix many lint issues
make fix
```

The project uses an extensive golangci-lint configuration (`.github/linters/.golangci.yaml`) with 80+ linters enabled. Code coverage threshold is >80%.

## Architecture

### Package Structure

- **connector/** - Factory for creating `database/sql/driver.Connector` from database URLs
- `NewConnector(ctx, databaseURL)` routes to database-specific connectors based on URL scheme
- **connector{mysql,postgresql,sqlite,mssql,oracle,db2}/** - Database-specific connector implementations
- **sqlexecutor/** - Reads SQL files and executes statements against databases
- `BasicSQLExecutor` implements the `SQLExecutor` interface
- Uses Senzing component ID 6422 for logging
- **postgresql/** - PostgreSQL-specific utilities (e.g., `GetCurrentWatermark()` for transaction OID)
- **checker/** - Validates Senzing database schema installation
- **dbhelper/** - OS-specific database helpers

### Database URL Schemes

```console
sqlite3://na:na@nowhere/path/to/db.db
postgresql://user:pass@host:5432/database
mysql://user:pass@host:3306/database
mssql://user:pass@host:1433/database
oci://user:pass@host:1521/service
```

### Key Patterns

- All packages follow the Senzing `Basic*` struct pattern (e.g., `BasicSQLExecutor`, `BasicPostgresql`)
- Observer pattern support via `go-observing` for monitoring database operations
- Structured logging via `go-logging` and `go-messaging`

## Environment Variables

- `LD_LIBRARY_PATH` - Oracle instant client and Senzing libraries (default: `/opt/senzing/er/lib:/opt/oracle/instantclient_23_5`)
- `SENZING_TOOLS_DATABASE_URL` - Default database URL for testing (default: `sqlite3://na:na@nowhere/tmp/sqlite/G2C.db`)
- `SENZING_LOG_LEVEL` - Set to `TRACE` for verbose logging during coverage tests

## Test Database Access (via Docker)

When running `make setup`:

- PostgreSQL: localhost:5432 (pgAdmin at localhost:9171)
- MySQL: localhost:3306 (phpMyAdmin at localhost:9173)
- MS SQL: localhost:1433 (Adminer at localhost:9177)
- Oracle: localhost:1521
3 changes: 0 additions & 3 deletions .claude/commands/senzing-code-review.md

This file was deleted.

3 changes: 3 additions & 0 deletions .claude/commands/senzing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Senzing

- Perform the steps specified by <https://raw.githubusercontent.com/senzing-factory/claude/refs/tags/v1/commands/senzing.md>
File renamed without changes.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
version: 2
updates:
- package-ecosystem: github-actions
cooldown:
default-days: 21
directory: /
schedule:
interval: daily
- package-ecosystem: gomod
cooldown:
default-days: 21
directory: /
schedule:
interval: daily
2 changes: 1 addition & 1 deletion .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
27 changes: 19 additions & 8 deletions .github/linters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
- [jscpd configuration]
- Example:

```json
{
"ignore": [
"**/*.go,**/go-test*.yaml"
],
```json
{
"ignore": ["**/*.go,**/go-test*.yaml"],
"threshold": 10
}
```
}
```

## .yaml-lint.yml

Expand All @@ -40,10 +38,23 @@
- [yaml-lint]
- [yaml-lint configuration]

[.checkov.yaml]: .checkov.yaml
## bearer.yml

- [bearer.yml]
- Used by [bearer.yaml]
- [bearer]
- [bearer repository]
- [bearer configuration]

[.checkov.yaml]: .checkov.yaml
[.golangci.yaml]: .golangci.yaml
[.jscpd.json]: .jscpd.json
[.yaml-lint.yml]: .yaml-lint.yml
[bearer configuration]: https://docs.bearer.com/reference/config/
[bearer repository]: https://github.com/Bearer/bearer/tree/main
[bearer.yaml]: ../workflows/README.md#beareryaml
[bearer.yml]: bearer.yml
[bearer]: https://docs.bearer.com/
[checkov configuration]: https://www.checkov.io/2.Basics/CLI%20Command%20Reference.html
[checkov]: https://www.checkov.io/
[golangci linters]: https://golangci-lint.run/usage/linters/
Expand Down
14 changes: 13 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
":disableDependencyDashboard",
"docker:pinDigests"
],
"enabledManagers": ["dockerfile", "docker-compose"],
"extends": ["config:recommended", ":disableDependencyDashboard"]
"schedule": ["on sunday"],
"prCreation": "not-pending",
"packageRules": [
{
"matchUpdateTypes": ["major", "minor", "patch"],
"minimumReleaseAge": "21 days"
}
]
}
12 changes: 8 additions & 4 deletions .github/workflows/bearer.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
name: bearer
name: Bearer

on:
push:
branches-ignore: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

permissions: {}

jobs:
rule_check:
permissions:
contents: read
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v6
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/claude-pr-review.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Claude PR Review

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

on:
pull_request:
types: [opened, synchronize]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

permissions: {}

jobs:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/dependabot-approve-and-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

permissions: {}

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/go-proxy-pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
permissions:
contents: write
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Pull new module version
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/go-test-darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Go test darwin

on: [pull_request, workflow_dispatch]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

env:
ACCEPT_EULA: Y
MSSQL_PID: Developer
Expand Down Expand Up @@ -30,6 +34,7 @@ jobs:
matrix:
go: ["1.24"]
os: [macos-latest]
timeout-minutes: 30

steps:
- name: Checkout repository
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/go-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Go test linux

on: [push, workflow_dispatch]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

env:
LD_LIBRARY_PATH: /opt/senzing/er/lib:/opt/oracle/instantclient_23_5
SENZING_TOOLS_DATABASE_URL: sqlite3://na:na@nowhere/tmp/sqlite/G2C.db
Expand All @@ -21,6 +25,7 @@ jobs:
matrix:
go: ["1.24"]
os: [ubuntu-latest]
timeout-minutes: 30

services:
oracle:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/go-test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Go test windows

on: [pull_request, workflow_dispatch]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

env:
ACCEPT_EULA: Y
MSSQL_PID: Developer
Expand All @@ -28,6 +32,7 @@ jobs:
fail-fast: false
matrix:
go: ["1.24"]
timeout-minutes: 30

steps:
- name: Checkout repository
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name: Golangci lint

on:
push:
branches-ignore: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

permissions: {}

jobs:
golangci:
name: lint
name: Lint
permissions:
# Required: allow read access to the content for analysis.
contents: read
Expand All @@ -21,6 +23,7 @@ jobs:
fail-fast: false
matrix:
go: ["1.24"]
timeout-minutes: 10

steps:
- name: Checkout repository
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/govulncheck.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: govulncheck
name: Govulncheck

on:
push:
branches-ignore: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

permissions: {}

jobs:
Expand All @@ -14,8 +16,10 @@ jobs:
contents: read
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: ["1.24"]
timeout-minutes: 10

steps:
- name: Checkout repository
Expand Down
Loading
Loading