From c131695f9b2206e1fd64db29ce81238a9f107c42 Mon Sep 17 00:00:00 2001 From: Clancy Date: Thu, 23 Jul 2026 22:59:43 +0300 Subject: [PATCH 1/3] ci(workflows): add PR title linting and upgrade verify and lint workflows 1- Add lint-pr.yml to enforce conventional commits specification ( feat:, fix:, perf:) on PR titles 2- Upgrade verify.yml to skip integration tests when only documentation or non-code files are changed 3- Add cross-platform OS matrix testing (ubuntu-latest, windows-latest, macos-latest) for compiler unit tests to verify cross-OS compilation and path handling 4- Upgrade lint.yml to use golangci/golangci-lint-action@v6 for cached linting and inline PR code annotations 5- Remove validate.yml as it's already covered in verify.yml 6- Update security.yml to run weekly ci(workflows): optimize CI pipeline with matrix testing, path filtering, and PR linting 1- Add lint-pr.yml to enforce conventional commits specification (feat:, fix:, perf:) on PR titles 2- Upgrade verify.yml to skip integration tests when only documentation or non-code files are changed 3- Add cross-platform OS matrix testing (ubuntu-latest, windows-latest, macos-latest) for compiler unit tests to verify cross-OS compilation and path handling 4- Convert benchmark.yml to a matrix (sqlite, postgres) for parallel, deduplicated benchmark runs 5- Upgrade lint.yml to use golangci/golangci-lint-action@v6 for cached linting and inline PR code annotations 6- Remove validate.yml as it is already covered in verify.yml 7- Update security.yml to run weekly via scheduled cron 8- Add coverage targets to makefile and ignore generated coverage files in gitignore --- .github/workflows/benchmark.yml | 56 ++++++-------- .github/workflows/lint-pr.yml | 29 +++++++ .github/workflows/lint.yml | 14 ++-- .github/workflows/security.yml | 2 + .github/workflows/validate.yml | 38 ---------- .github/workflows/verify.yml | 130 +++++++++++++++++++++----------- .gitignore | 6 +- makefile | 9 ++- 8 files changed, 160 insertions(+), 124 deletions(-) create mode 100644 .github/workflows/lint-pr.yml delete mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 25c4f48..aab0150 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -15,31 +15,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 @@ -62,19 +44,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 diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml new file mode 100644 index 0000000..58eb942 --- /dev/null +++ b/.github/workflows/lint-pr.yml @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index add7a7f..1c76d88 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,13 +24,13 @@ jobs: go-version-file: 'go.mod' cache: true - - name: Install golangci-lint - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - - name: Run golangci-lint (root) - run: $(go env GOPATH)/bin/golangci-lint run ./... + uses: golangci/golangci-lint-action@v6 + with: + version: v1.58.0 - name: Run golangci-lint (integration) - run: | - cd integration - $(go env GOPATH)/bin/golangci-lint run ./... + uses: golangci/golangci-lint-action@v6 + with: + version: v1.58.0 + working-directory: integration diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 61be105..0a52158 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -4,6 +4,8 @@ on: push: branches: [ "main", "master" ] pull_request: + schedule: + - cron: '0 0 * * 1' jobs: govulncheck: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml deleted file mode 100644 index a7fd251..0000000 --- a/.github/workflows/validate.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: validate - -on: - push: - branches-ignore: - - 'main' - - 'master' - pull_request: - branches-ignore: - - 'main' - - 'master' - -jobs: - check-and-test: - name: Check, Build, and Test - runs-on: ubuntu-latest - 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: Run Formatter Check - run: make fmt-check - - - name: Run Tidy Check - run: make tidy-check - - - name: Vet packages - run: make vet - - - name: Run compiler unit tests - run: make test diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index aa07778..a0b6563 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -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: @@ -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 diff --git a/.gitignore b/.gitignore index dd2ac16..003cec1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,8 @@ bin docker-compose.yml api-example.gotpl *.bak -schema.prisma.backup \ No newline at end of file +schema.prisma.backup + +coverage.out +coverage.html +*.out \ No newline at end of file diff --git a/makefile b/makefile index cabf24e..f61c402 100644 --- a/makefile +++ b/makefile @@ -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 @@ -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 .. From 0081fbb3b3ff0ef6fd570966b21f162350780894 Mon Sep 17 00:00:00 2001 From: Clancy Date: Thu, 23 Jul 2026 23:04:22 +0300 Subject: [PATCH 2/3] update lint.yml to add a go mod download step before golangci-lint-action runs --- .github/workflows/lint.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1c76d88..f4edd89 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,6 +24,11 @@ jobs: go-version-file: 'go.mod' cache: true + - name: Download Go modules + run: | + go mod download + cd integration && go mod download + - name: Run golangci-lint (root) uses: golangci/golangci-lint-action@v6 with: From 1e266960bddeeff81e992c120c04b189e9da3089 Mon Sep 17 00:00:00 2001 From: Clancy Date: Thu, 23 Jul 2026 23:09:30 +0300 Subject: [PATCH 3/3] restore golangci to use latest version, restore benchmark to run on master --- .github/workflows/benchmark.yml | 3 ++- .github/workflows/lint.yml | 17 ++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index aab0150..6829f72 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,8 +1,9 @@ name: Benchmark on: push: - branches: [main] + branches: [ "main", "master" ] pull_request: + branches: [ "main", "master" ] workflow_dispatch: concurrency: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f4edd89..add7a7f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,18 +24,13 @@ jobs: go-version-file: 'go.mod' cache: true - - name: Download Go modules - run: | - go mod download - cd integration && go mod download + - name: Install golangci-lint + run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - name: Run golangci-lint (root) - uses: golangci/golangci-lint-action@v6 - with: - version: v1.58.0 + run: $(go env GOPATH)/bin/golangci-lint run ./... - name: Run golangci-lint (integration) - uses: golangci/golangci-lint-action@v6 - with: - version: v1.58.0 - working-directory: integration + run: | + cd integration + $(go env GOPATH)/bin/golangci-lint run ./...