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
59 changes: 26 additions & 33 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Benchmark
on:
push:
branches: [main]
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
workflow_dispatch:

concurrency:
Expand All @@ -15,31 +16,13 @@ env:
TIMEOUT: 10m

jobs:
sqlite:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: benchmark/go.mod
cache-dependency-path: benchmark/go.sum
- run: |
go build -o bin/valk
cd benchmark
node prepareSchema.js sqlite
rm -rf valk/migrations/*.sql
rm -f dev.db
DATABASE_URL="file:./dev.db" DATABASE_DIRECT_URL="file:./dev.db" ../bin/valk migrate init
../bin/valk generate
go generate ./ent
go run ./cmd/benchsummary -count=${{ env.COUNT }} -benchtime=${{ env.BENCHTIME }} -timeout=${{ env.TIMEOUT }} | tee ../bench-sqlite.txt
- uses: actions/upload-artifact@v4
with:
name: bench-sqlite-${{ github.sha }}
path: bench-sqlite.txt

postgres:
benchmark:
name: Benchmark (${{ matrix.db }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
db: [sqlite, postgres]
services:
postgres:
image: postgres:16
Expand All @@ -62,19 +45,29 @@ jobs:
with:
go-version-file: benchmark/go.mod
cache-dependency-path: benchmark/go.sum
- run: |
go build -o bin/valk

- name: Build Valkyrie CLI
run: go build -o bin/valk

- name: Run Benchmark (${{ matrix.db }})
run: |
cd benchmark
node prepareSchema.js postgres
node prepareSchema.js ${{ matrix.db }}
rm -rf valk/migrations/*.sql
DATABASE_URL="postgres://postgres:postgres@localhost:5432/bench?sslmode=disable" DATABASE_DIRECT_URL="postgres://postgres:postgres@localhost:5432/bench?sslmode=disable" ../bin/valk migrate init
rm -f dev.db
if [ "${{ matrix.db }}" = "sqlite" ]; then
DATABASE_URL="file:./dev.db" DATABASE_DIRECT_URL="file:./dev.db" ../bin/valk migrate init
else
DATABASE_URL="postgres://postgres:postgres@localhost:5432/bench?sslmode=disable" DATABASE_DIRECT_URL="postgres://postgres:postgres@localhost:5432/bench?sslmode=disable" ../bin/valk migrate init
fi
../bin/valk generate
go generate ./ent
go run ./cmd/benchsummary -count=${{ env.COUNT }} -benchtime=${{ env.BENCHTIME }} -timeout=${{ env.TIMEOUT }} | tee ../bench-postgres.txt
BENCH_DB=${{ matrix.db }} go run ./cmd/benchsummary -count=${{ env.COUNT }} -benchtime=${{ env.BENCHTIME }} -timeout=${{ env.TIMEOUT }} | tee ../bench-${{ matrix.db }}.txt
env:
BENCH_DB: postgres
BENCH_DB: ${{ matrix.db }}
PG_DATABASE_URL: postgres://postgres:postgres@localhost:5432/bench?sslmode=disable

- uses: actions/upload-artifact@v4
with:
name: bench-postgres-${{ github.sha }}
path: bench-postgres.txt
name: bench-${{ matrix.db }}-${{ github.sha }}
path: bench-${{ matrix.db }}.txt
29 changes: 29 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Lint PR"

on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened

jobs:
main:
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
perf
refactor
docs
ci
test
build
chore
2 changes: 2 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches: [ "main", "master" ]
pull_request:
schedule:
- cron: '0 0 * * 1'

jobs:
govulncheck:
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/validate.yml

This file was deleted.

130 changes: 85 additions & 45 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,52 @@ on:
branches: [ "main", "master" ]

jobs:
path-filter:
name: Check Changed Paths
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- 'generator/**'
- 'cli/**'
- 'schema/**'
- 'integration/**'
- 'dbProviders/**'
- 'migration/**'
- 'benchmark/**'
- '*.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/**'

compiler-unit-tests:
needs: path-filter
if: ${{ needs.path-filter.outputs.code == 'true' }}
name: Unit Tests (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Run compiler unit tests
run: go test -race -v ./...

integration-tests:
name: Run Integration Tests
needs: path-filter
if: ${{ needs.path-filter.outputs.code == 'true' }}
name: Run Database Integration Tests
runs-on: ubuntu-latest

services:
Expand All @@ -19,57 +63,53 @@ jobs:
POSTGRES_PASSWORD: testpassword
POSTGRES_DB: valk_test
ports:
- 5432:5432
- 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-file: 'go.mod'
cache: true
cache-dependency-path: '**/go.sum'
- name: Checkout code
uses: actions/checkout@v4

- name: Run Formatter Check
run: make fmt-check
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true

- name: Run Tidy Check
run: make tidy-check
- name: Run Formatter Check
run: make fmt-check

- name: Vet packages
run: make vet
- name: Run Tidy Check
run: make tidy-check

- name: Run compiler unit tests
run: make test
- name: Vet packages
run: make vet

- name: Run SQLite Integration Tests
run: |
cp integration/schema.prisma integration/schema.prisma.bak
node integration/prepareSchema.js sqlite
rm -f integration/valk/migrations/*.sql
make integration-gen
cd integration
../bin/valk migrate -u "file:dev.db" init_sqlite
go test -race -tags sqlite -v ./...
mv schema.prisma.bak schema.prisma
- name: Run SQLite Integration Tests
run: |
cp integration/schema.prisma integration/schema.prisma.bak
node integration/prepareSchema.js sqlite
rm -f integration/valk/migrations/*.sql
make integration-gen
cd integration
../bin/valk migrate -u "file:dev.db" init_sqlite
go test -race -tags sqlite -v ./...
mv schema.prisma.bak schema.prisma

- name: Run Postgres Integration Tests
run: |
PG_URL="${{ secrets.PG_DATABASE_URL }}"
if [ -z "$PG_URL" ]; then
PG_URL="postgres://testuser:testpassword@localhost:5432/valk_test?sslmode=disable"
else
PG_URL="${PG_URL/valkyrie_test/valk_test}"
fi
cp integration/schema.prisma integration/schema.prisma.bak
node integration/prepareSchema.js postgres
rm -f integration/valk/migrations/*.sql
make integration-gen
cd integration
../bin/valk migrate -u "$PG_URL" init_pg
PG_DATABASE_URL="$PG_URL" go test -race -v ./...
mv schema.prisma.bak schema.prisma
- name: Run Postgres Integration Tests
run: |
PG_URL="${{ secrets.PG_DATABASE_URL }}"
if [ -z "$PG_URL" ]; then
PG_URL="postgres://testuser:testpassword@localhost:5432/valk_test?sslmode=disable"
else
PG_URL="${PG_URL/valkyrie_test/valk_test}"
fi
cp integration/schema.prisma integration/schema.prisma.bak
node integration/prepareSchema.js postgres
rm -f integration/valk/migrations/*.sql
make integration-gen
cd integration
../bin/valk migrate -u "$PG_URL" init_pg
PG_DATABASE_URL="$PG_URL" go test -race -v ./...
mv schema.prisma.bak schema.prisma
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ bin
docker-compose.yml
api-example.gotpl
*.bak
schema.prisma.backup
schema.prisma.backup

coverage.out
coverage.html
*.out
9 changes: 8 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build build-prod run test install db-up db-down db-clean bi fmt fmt-check tidy tidy-check vulncheck vet integration-gen integration-test bench bench-sqlite bench-pg bench-all race lint test-sqlite test-pg test-dbs ci-local
.PHONY: build build-prod run test coverage cover-html install db-up db-down db-clean bi fmt fmt-check tidy tidy-check vulncheck vet integration-gen integration-test bench bench-sqlite bench-pg bench-all race lint test-sqlite test-pg test-dbs ci-local

bi: build install

Expand All @@ -7,6 +7,13 @@ e2e: test integration-test
race:
go test -race ./... && cd integration && go test -race ./...

coverage:
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out

cover-html: coverage
go tool cover -html=coverage.out -o coverage.html

bench:
cd benchmark && make bench && cd ..

Expand Down
Loading