Build/test fixes
This commit is contained in:
36
.github/workflows/ci.yml
vendored
36
.github/workflows/ci.yml
vendored
@@ -34,8 +34,8 @@ jobs:
|
|||||||
- name: Download dependencies
|
- name: Download dependencies
|
||||||
run: go mod download
|
run: go mod download
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run unit tests
|
||||||
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
|
run: make test
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v4
|
||||||
@@ -55,13 +55,15 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version: '1.25'
|
||||||
|
|
||||||
- name: golangci-lint
|
- name: Install golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v9
|
run: |
|
||||||
with:
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin latest
|
||||||
version: latest
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||||
args: --config=.golangci.json
|
|
||||||
|
- name: Run linter
|
||||||
|
run: make lint
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
@@ -74,10 +76,22 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version: '1.25'
|
||||||
|
|
||||||
- name: Build
|
- name: Download dependencies
|
||||||
run: go build -v ./cmd/relspec
|
run: go mod download
|
||||||
|
|
||||||
|
- name: Build binary
|
||||||
|
run: make build
|
||||||
|
|
||||||
|
- name: Verify binary exists
|
||||||
|
run: |
|
||||||
|
if [ ! -f build/relspec ]; then
|
||||||
|
echo "Error: Binary not found at build/relspec"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Build successful: build/relspec"
|
||||||
|
ls -lh build/relspec
|
||||||
|
|
||||||
- name: Check mod tidiness
|
- name: Check mod tidiness
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
82
.github/workflows/integration-tests.yml
vendored
Normal file
82
.github/workflows/integration-tests.yml
vendored
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
name: Integration Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
integration-tests:
|
||||||
|
name: Integration Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: relspec
|
||||||
|
POSTGRES_PASSWORD: relspec_test_password
|
||||||
|
POSTGRES_DB: relspec_test
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.25'
|
||||||
|
|
||||||
|
- name: Cache Go modules
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-
|
||||||
|
|
||||||
|
- name: Download dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
|
- name: Install PostgreSQL client
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y postgresql-client
|
||||||
|
|
||||||
|
- name: Initialize test database
|
||||||
|
env:
|
||||||
|
PGPASSWORD: relspec_test_password
|
||||||
|
run: |
|
||||||
|
psql -h localhost -U relspec -d relspec_test -f tests/postgres/init.sql
|
||||||
|
|
||||||
|
- name: Verify database setup
|
||||||
|
env:
|
||||||
|
PGPASSWORD: relspec_test_password
|
||||||
|
run: |
|
||||||
|
echo "Verifying database initialization..."
|
||||||
|
psql -h localhost -U relspec -d relspec_test -c "
|
||||||
|
SELECT
|
||||||
|
(SELECT COUNT(*) FROM pg_namespace WHERE nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND nspname NOT LIKE 'pg_%') as schemas,
|
||||||
|
(SELECT COUNT(*) FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as tables,
|
||||||
|
(SELECT COUNT(*) FROM pg_views WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as views,
|
||||||
|
(SELECT COUNT(*) FROM pg_sequences WHERE schemaname NOT IN ('pg_catalog', 'information_schema')) as sequences;
|
||||||
|
"
|
||||||
|
|
||||||
|
- name: Run integration tests
|
||||||
|
env:
|
||||||
|
RELSPEC_TEST_PG_CONN: postgres://relspec:relspec_test_password@localhost:5432/relspec_test
|
||||||
|
run: make test-integration
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
echo "Integration tests completed."
|
||||||
|
echo "PostgreSQL service was running on localhost:5432"
|
||||||
22
Makefile
22
Makefile
@@ -1,4 +1,4 @@
|
|||||||
.PHONY: all build test lint coverage clean install help docker-up docker-down docker-test docker-test-integration
|
.PHONY: all build test test-unit test-integration lint coverage clean install help docker-up docker-down docker-test docker-test-integration
|
||||||
|
|
||||||
# Binary name
|
# Binary name
|
||||||
BINARY_NAME=relspec
|
BINARY_NAME=relspec
|
||||||
@@ -22,9 +22,23 @@ build: ## Build the binary
|
|||||||
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/relspec
|
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/relspec
|
||||||
@echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
|
@echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
|
||||||
|
|
||||||
test: ## Run tests
|
test: test-unit ## Run all unit tests (alias for test-unit)
|
||||||
@echo "Running tests..."
|
|
||||||
$(GOTEST) -v -race -coverprofile=coverage.out ./...
|
test-unit: ## Run unit tests (excludes integration tests)
|
||||||
|
@echo "Running unit tests..."
|
||||||
|
$(GOTEST) -v -race -coverprofile=coverage.out -covermode=atomic $$(go list ./... | grep -v '/tests/integration' | grep -v '/pkg/readers/pgsql')
|
||||||
|
|
||||||
|
test-integration: ## Run integration tests (requires RELSPEC_TEST_PG_CONN environment variable)
|
||||||
|
@echo "Running integration tests..."
|
||||||
|
@if [ -z "$$RELSPEC_TEST_PG_CONN" ]; then \
|
||||||
|
echo "Error: RELSPEC_TEST_PG_CONN environment variable is not set"; \
|
||||||
|
echo "Example: export RELSPEC_TEST_PG_CONN='postgres://relspec:relspec_test_password@localhost:5432/relspec_test'"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
@echo "Running PostgreSQL reader tests..."
|
||||||
|
$(GOTEST) -v -count=1 ./pkg/readers/pgsql/
|
||||||
|
@echo "Running general integration tests..."
|
||||||
|
$(GOTEST) -v -count=1 ./tests/integration/
|
||||||
|
|
||||||
coverage: test ## Run tests with coverage report
|
coverage: test ## Run tests with coverage report
|
||||||
@echo "Generating coverage report..."
|
@echo "Generating coverage report..."
|
||||||
|
|||||||
Reference in New Issue
Block a user