Skip to content
Open
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
31 changes: 31 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
s3:
- bucket/*
- bucket/**/*

file:
- file/*
- file/**/*

internal:
- internal/*
- internal/**/*

reader:
- reader/*
- reader/**/*

sftp:
- sftp/*
- sftp/**/*

vector:
- vector/*
- vector/**/*

writer:
- writer/*
- writer/**/*

ci:
- .github/*
- .github/**/*
61 changes: 61 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Continues Integration

on:
push:
branches: [master]
pull_request:
branches:
- master
- feature/*
- bugfix/*
- refactor/*
- chore/*

jobs:
label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/labeler@v3

test:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '>=1.20.0'

- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Running Tests
run: chmod -R +rw ./testdata && make ci_tests

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.52.x
args: --timeout 5m0s
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
bench*
gen*
chunk_*.tsv
bin/
bin/
*.csv
*.tsv
*.gz
coverage.out
testdata/chunks/*.csv
testdata/chunks/*.tsv
testdata/chunks/*.gz
208 changes: 111 additions & 97 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,120 @@
linters-settings:
govet:
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
enable:
- fieldalignment
# golint:
# min-confidence: 0
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
goconst:
min-len: 2
min-occurrences: 2
# misspell: # disabled as it was breaking interfaces with FinaliZe
# locale: UK
lll:
line-length: 140
goimports:
local-prefixes: github.com/golangci/golangci-lint
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
funlen:
lines: 100
statements: 50
godot:
capital: true
unparam:
check-exported: true
cyclop:
skip-tests: true
max-complexity: 15
exhaustive:
default-signifies-exhaustive: true
funlen:
lines: 110
statements: 70
gci:
sections:
- standard
- default
- prefix(github.com/askiada)
- localmodule
custom-order: true
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
gocyclo:
min-complexity: 15
godot:
capital: true
goimports:
local-prefixes: github.com/askiada/external-sort
govet:
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
disable:
- fieldalignment
lll:
line-length: 140
misspell:
locale: UK
paralleltest:
ignore-missing-subtests: true # Unfortunately, we can't write t.Run("success", testSuccess)
unparam:
check-exported: true
varnamelen:
min-name-length: 2
max-distance: 15

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gosec # security check is not impoerant in tests
- dupl # we usualy duplicate code in tests
- bodyclose
- unparam
fix: true
errcheck:
exclude-functions:
- (*io.PipeWriter).Close

run:
skip-dirs:
- model
- tmp
- bin
- scripts
wrapcheck:
ignoreSigs:
- .Errorf(
- errors.New(
- errors.Unwrap(
- errors.Join(
- .Wrap(
- .Wrapf(
- .WithMessage(
- .WithMessagef(
- .WithStack(
- status.Error(
- Group).Wait()

tests: true
build-tags:
- integration
nlreturn:
block-size: 2

linters:
disable-all: true
fast: true
enable:
- asciicheck
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- bodyclose
- deadcode
- dogsled
- depguard
- dupl
- errorlint
- gocognit
- goconst
- contextcheck
- dupl # we usually duplicate code in tests
- errcheck
- exhaustive
- funlen
- gocritic
- gocyclo
- godot
- godox
- golint
- goprintffuncname
- gosec
- gosimple
- gosec # security check is not important in tests
- govet
# - misspell # disabled as it was breaking interfaces with FinaliZe
- nakedret
- nestif
- prealloc
- rowserrcheck
- scopelint
- staticcheck
- stylecheck
- unconvert
# - unparam # Too many false positives on Task interface implementation.
- unused
- whitespace
# - wrapcheck
- tparallel
- maintidx
- nlreturn
- revive
- unparam
- varnamelen
- wrapcheck
- wsl
- path: testing
linters:
- errcheck
fix: true
exclude-use-default: false
exclude-dirs:
- model
- tmp
- bin
- scripts

# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.38.x
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
run:
allow-parallel-runners: true
tests: true
build-tags:
- integration

linters:
enable-all: true
disable:
- depguard # because I don't want to write a dedicated config file.
- execinquery #Marked as deprecated by golangci-lint.
- gomnd # Marked as deprecated by golangci-lint. Replaced with mnd
- nonamedreturns # Conflicts with unnamedResult linter.
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ docker_image=askiada/external-sort
include ./env.list
export $(shell sed 's/=.*//' ./env.list)

.PHONY: lint
lint:
gofumpt -w -l .
golangci-lint run ./...

.PHONY: test
test:
Expand All @@ -17,9 +21,13 @@ test:
test_race:
go test -race ./...

.PHONY: run
run: build
./bin/external-sort
.PHONY: run_sort
run_sort: build
./bin/external-sort sort

.PHONY: run_shuffle
run_shuffle: build
./bin/external-sort shuffle

.PHONY: build
build:
Expand All @@ -29,4 +37,8 @@ build:
build_docker: ## Build a docker image from current git sha
@docker build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
-t $(docker_image):$(tag) .
-t $(docker_image):$(tag) .

.PHONY: ci_tests
ci_tests: ## Run tests for CI environment.
go test -trimpath --timeout=10m -failfast -v -race -covermode=atomic -coverprofile=coverage.out ./...
Loading