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
67 changes: 67 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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@31f7c5463448f83528bd771c2d978d940080c9fd # unknown tag
with:
go-package: ./...

- name: Run unit tests
run: make unit

- name: Build
run: make build

# - name: Run FTs
# run: make functional
9 changes: 9 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -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/"
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -11,5 +23,15 @@ run: build
$(DIST_DIR)/$(BINARY_NAME) ./tests/...

## unit: run unit tests
unit:
unit: mocks
go test ./... -timeout 30s

lint: tools
golangci-lint run --config .golangci.yaml

## mocks: generate mocks
mocks:
mockery --config .mockery.yml

functional:
$(DIST_DIR)/$(BINARY_NAME) ./tests/...