From 69671bc1dbf7e411d613cf973574e09281331f7e Mon Sep 17 00:00:00 2001 From: Igor Stepanenko Date: Sat, 16 May 2026 20:11:54 +0100 Subject: [PATCH 1/4] Add CI --- .github/workflows/ci.yaml | 68 +++++++++++++++++++++++++++++++++++++++ Makefile | 9 +++++- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..f34787a --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,68 @@ +name: CI + +on: + pull_request: + paths: + - "**.go" + - "go.mod" + - "go.sum" + - ".github/workflows/**" + + push: + branches: + - main + paths: + - "**.go" + - "go.mod" + - "go.sum" + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: {} + +jobs: + ci: + runs-on: ubuntu-24.04 + permissions: + contents: read # for code checkout + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Setup Go + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v 6.4.0 + with: + go-version-file: go.mod + cache: true + + # Cache build artifacts in addition to module cache + - name: Cache Go build + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: | + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-build- + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 + with: + version: v2.12 + + - name: Run vulnerability scan + uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4 + with: + go-version-input: 1.25.4 + go-package: ./... + + - name: Run unit tests + run: make unit + + - name: Build + run: make build + + # - name: Run FTs + # run: make functional diff --git a/Makefile b/Makefile index 20698b9..f8ea81d 100644 --- a/Makefile +++ b/Makefile @@ -11,5 +11,12 @@ run: build $(DIST_DIR)/$(BINARY_NAME) ./tests/... ## unit: run unit tests -unit: +unit: mocks go test ./... -timeout 30s + +## mocks: generate mocks +mocks: + mockery --config .mockery.yml + +functional: + $(DIST_DIR)/$(BINARY_NAME) ./tests/... From b98840212eb86f7d3c4c5ad7034ef56cdf421a40 Mon Sep 17 00:00:00 2001 From: Igor Stepanenko Date: Sun, 17 May 2026 13:01:25 +0100 Subject: [PATCH 2/4] Configure golangci lint --- .golangci.yaml | 9 +++++++++ Makefile | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 .golangci.yaml diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..c4b3a6e --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,9 @@ +version: "2" + +linters: + exclusions: + paths-except: + # Don't want to lint vendored code. + - "vendor/" + # There will be linting issues on purpose. + - "test/" diff --git a/Makefile b/Makefile index f8ea81d..0be1575 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,18 @@ CMD_DIR := ./cmd DIST_DIR := ./dist BINARY_NAME := dblinter +GOLANGCI_LINT := golangci-lint +GOLANGCI_VERSION := v2.12.2 # TODO: make this aligned with CI. + +## tools: installs necessary tools to run quality check +tools: + @if ! command -v $(GOLANGCI_LINT) >/dev/null 2>&1; then \ + echo "Installing $(GOLANGCI_LINT)..."; \ + curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $$(go env GOPATH)/bin $(GOLANGCI_VERSION); \ + else \ + echo "$(GOLANGCI_LINT) already installed"; \ + fi + ## build: build dblinter build: go build -o $(DIST_DIR)/$(BINARY_NAME) $(CMD_DIR)/$(BINARY_NAME) @@ -14,6 +26,9 @@ run: build unit: mocks go test ./... -timeout 30s +lint: tools + golangci-lint run --config .golangci.yaml + ## mocks: generate mocks mocks: mockery --config .mockery.yml From ba24cc952eaec19075502b0d085319cc9c39a9d8 Mon Sep 17 00:00:00 2001 From: Igor Stepanenko Date: Sun, 17 May 2026 13:09:28 +0100 Subject: [PATCH 3/4] remove go-version-input --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f34787a..d68a749 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -55,7 +55,6 @@ jobs: - name: Run vulnerability scan uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4 with: - go-version-input: 1.25.4 go-package: ./... - name: Run unit tests From 57546158549a6926f439cf4e739505fdd25b5cba Mon Sep 17 00:00:00 2001 From: Igor Stepanenko Date: Sun, 17 May 2026 13:12:47 +0100 Subject: [PATCH 4/4] Try latest SHA for govuln check --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d68a749..04a4469 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,7 +53,7 @@ jobs: version: v2.12 - name: Run vulnerability scan - uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4 + uses: golang/govulncheck-action@31f7c5463448f83528bd771c2d978d940080c9fd # unknown tag with: go-package: ./...