From af323c81aa8bcb80fe87e38b5f9366454e98be54 Mon Sep 17 00:00:00 2001 From: Christopher Wunder Date: Sun, 23 Nov 2025 10:52:52 +0100 Subject: [PATCH] Install CI We need a good ci workflow to maintain code quality and code correctness. Linting, static code check, unit tests, integration tests, build will help us do that. More checks may be added in the future. --- .github/workflows/ci.yml | 71 +++++++++++++++++++ .../postgres/postgres_integration_test.go | 2 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1775e8f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + - name: Run linter + uses: golangci/golangci-lint-action@v9 + with: + version: v2.6 + - name: Run go vet + run: go vet ./... + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@v0.6.1 + - name: Run staticcheck + run: staticcheck ./... + + 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: '1.22' + - name: Verify go modules + run: | + go mod tidy + go mod verify + - name: Build binaries + run: go build -v ./... + - name: Run unit tests with coverage + run: go test -v -coverprofile=coverage.out ./... + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage.out + + integration-test: + runs-on: ubuntu-latest + env: + SCIMA_TEST_ROOT_DIR: ${{ github.workspace }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + - name: Verify go modules + run: | + go mod tidy + go mod verify + - name: Build binaries + run: go build -v ./... + - name: Run integration tests + run: go test -v --tags=integration ./tests/integration/... diff --git a/tests/integration/postgres/postgres_integration_test.go b/tests/integration/postgres/postgres_integration_test.go index c5dd545..3e7a256 100644 --- a/tests/integration/postgres/postgres_integration_test.go +++ b/tests/integration/postgres/postgres_integration_test.go @@ -36,7 +36,7 @@ func TestPostgresMigrationsIntegration(t *testing.T) { // --------------------------------------------------------------------- ctx := context.Background() - rootDir := "/Users/I758791/github.com/scima" + rootDir := getenvDefault("SCIMA_TEST_ROOT_DIR", "/Users/I758791/github.com/scima") migDir := filepath.Join(rootDir, "tests", "integration", "postgres", "migrations") if _, err := os.Stat(migDir); os.IsNotExist(err) { t.Fatalf("migrations folder not found: %s", migDir)