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
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.4.0
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
go-version: 1.24.x

- name: Install tools
run: make tools
Expand All @@ -42,7 +37,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
go-version: 1.24.x

- name: Check formatting
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
go-version: 1.24.x

- name: Install dependencies
run: make deps
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
go-version: 1.24.x

- name: Install dependencies
run: make deps
Expand All @@ -75,7 +75,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x
go-version: 1.24.x

- name: Check go.mod
run: make check-mod
54 changes: 14 additions & 40 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint
name: golangci-lint

on:
push:
Expand All @@ -8,49 +8,23 @@ on:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.23.x

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.4.0
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH

- name: Run golangci-lint
run: |
# For PRs, only check new issues
if [ "${{ github.event_name }}" = "pull_request" ]; then
golangci-lint run --new-from-rev=${{ github.event.pull_request.base.sha }}
else
golangci-lint run
fi
env:
# Ensure colored output for better readability
FORCE_COLOR: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24.x'
# Cache disabled because golangci-lint-action has its own caching
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.6.2
# On PRs, only check new issues introduced by the PR
only-new-issues: ${{ github.event_name == 'pull_request' }}
args: --timeout=30m
79 changes: 39 additions & 40 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
version: "2"

linters-settings:
gocyclo:
min-complexity: 15
staticcheck:
checks: "all"
goimports:
local-prefixes: github.com/osteele/liquid
goconst:
min-len: 3
min-occurrences: 3
dupl:
threshold: 150
errcheck:
check-type-assertions: true
check-blank: false
gosec:
excludes: []
govet:
enable-all: true
disable:
- fieldalignment # Too noisy for most projects
misspell:
locale: US
run:
timeout: 5m
tests: true
build-tags:
- integration

linters:
enable:
Expand Down Expand Up @@ -51,16 +33,15 @@ linters:
# Style (minimal, non-controversial)
- whitespace

# Explicitly disable overly strict linters
disable:
- gochecknoglobals # Too restrictive
- err113 # Too strict for error handling (was goerr113)
- wrapcheck # Too strict for error handling
- exhaustruct # Too noisy
- funlen # Function length is contextual
- goconst # Too many false positives
- depguard # Can be too restrictive

# v2 format for exclusions
exclusions:
paths:
- vendor
Expand Down Expand Up @@ -92,7 +73,6 @@ linters:
- misspell
- gosec
- whitespace
- godot

# Exclude third party, builtin, examples
- path: (third_party|builtin|examples|vendor)/
Expand Down Expand Up @@ -162,23 +142,42 @@ linters:
- text: "Error return value of .((Close|Write|Flush))` is not checked"
linters: [errcheck]

run:
timeout: 5m
tests: true # Include test files
build-tags:
- integration
# Type assertions where we know the type is correct (pre-existing code)
- path: values/
text: "Error return value is not checked"
linters: [errcheck]

settings:
gocyclo:
min-complexity: 20
goconst:
min-len: 3
min-occurrences: 3
dupl:
threshold: 150
errcheck:
check-type-assertions: false # Too noisy for pre-existing code
check-blank: false
gosec:
excludes: []
govet:
enable-all: true
disable:
- fieldalignment # Too noisy for most projects
misspell:
locale: US

issues:
fix: true # Auto-fix what can be fixed
max-same-issues: 3 # Show at most 3 issues of the same type
max-issues-per-linter: 50

output:
formats:
text:
path: stdout
colors: true
print-linter-name: true
print-issued-lines: true
sort-results: true
uniq-by-line: true
formatters:
enable:
- gofmt
- goimports

settings:
goimports:
local-prefixes:
- github.com/osteele/liquid
18 changes: 6 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ PACKAGES := $(shell $(GOCMD) list ./... | grep -v /vendor/)
COVERAGE_FILE := coverage.out
COVERAGE_HTML := coverage.html

# Tools - installed via tools.go
# Tools - installed via tools.go or go.mod tool directive
TOOLS_DIR := $(shell $(GOCMD) env GOPATH)/bin
GOYACC := $(TOOLS_DIR)/goyacc
STRINGER := $(TOOLS_DIR)/stringer
GOLANGCI_LINT := golangci-lint # Use system-installed version
GOLANGCI_LINT := $(GOCMD) tool golangci-lint # Use version from go.mod

# Colors for output
RED := \033[0;31m
Expand Down Expand Up @@ -101,13 +101,13 @@ benchmark: ## Run benchmarks
##@ Code Quality

.PHONY: lint
lint: check-golangci-lint ## Run linter
lint: ## Run linter
@echo "Running linter..."
$(GOLANGCI_LINT) run
@echo "${GREEN}✓ Lint passed${NC}"

.PHONY: lint-fix
lint-fix: check-golangci-lint ## Run linter with auto-fix
lint-fix: ## Run linter with auto-fix
$(GOLANGCI_LINT) run --fix

.PHONY: fmt
Expand Down Expand Up @@ -156,10 +156,8 @@ tools: ## Install development tools
@$(GOCMD) install golang.org/x/tools/cmd/stringer@latest
@echo "${GREEN}✓ Tools installed${NC}"
@echo ""
@echo "${YELLOW}Note: golangci-lint should be installed separately:${NC}"
@echo " brew install golangci-lint"
@echo " or"
@echo " curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s"
@echo "${YELLOW}Note: golangci-lint is managed via go.mod tool directive${NC}"
@echo "Run 'go tool golangci-lint' to use it"

.PHONY: install-hooks
install-hooks: ## Install pre-commit hooks
Expand All @@ -182,10 +180,6 @@ run-hooks: ## Run pre-commit hooks on all files
update-hooks: ## Update pre-commit hooks to latest versions
@pre-commit autoupdate

.PHONY: check-golangci-lint
check-golangci-lint:
@which $(GOLANGCI_LINT) > /dev/null 2>&1 || (echo "${RED}Error: golangci-lint is not installed${NC}" && echo "Run 'make tools' for installation instructions" && exit 1)

##@ CI/CD

.PHONY: ci
Expand Down
3 changes: 2 additions & 1 deletion engine_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"strings"
"testing"

"github.com/osteele/liquid/render"
"github.com/stretchr/testify/require"

"github.com/osteele/liquid/render"
)

func Example() {
Expand Down
3 changes: 2 additions & 1 deletion expressions/expressions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"strings"
"testing"

"github.com/osteele/liquid/values"
"github.com/stretchr/testify/require"

"github.com/osteele/liquid/values"
)

var evaluatorTests = []struct {
Expand Down
3 changes: 2 additions & 1 deletion expressions/filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"fmt"
"testing"

"github.com/osteele/liquid/values"
"github.com/stretchr/testify/require"

"github.com/osteele/liquid/values"
)

func TestContext_AddFilter(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion expressions/parser.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//go:generate ragel -Z scanner.rl
//go:generate sed -i '1i// Code generated by ragel. DO NOT EDIT.' scanner.go
//go:generate sh -c "{ echo '// Code generated by ragel. DO NOT EDIT.'; cat scanner.go; } > scanner.go.tmp && mv scanner.go.tmp scanner.go"
//go:generate gofmt -w scanner.go
//go:generate goyacc expressions.y

package expressions
Expand Down
3 changes: 2 additions & 1 deletion filters/standard_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
"time"
"unicode"

"github.com/osteele/liquid/values"
"github.com/osteele/tuesday"

"github.com/osteele/liquid/values"
)

var errDivisionByZero = errors.New("division by zero")
Expand Down
3 changes: 2 additions & 1 deletion filters/standard_filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

yaml "gopkg.in/yaml.v2"

"github.com/osteele/liquid/expressions"
"github.com/stretchr/testify/require"

"github.com/osteele/liquid/expressions"
)

var filterTests = []struct {
Expand Down
Loading