Rubezh
рубеж — Enforces external test packages in Go

Rubezh is a Go linter that requires test files to use an external test package whose name ends in _test (for example, package foo_test).
This keeps tests
focused on the package's public API instead of its unexported implementation.
Rubezh accepts both Go source files and Go package patterns:
rubezh foo_test.go bar_test.go
rubezh ./...
When no arguments are provided, Rubezh checks ./....
The conventional export_test.go file may use the package under test without the _test suffix.
Configuration
Rubezh automatically loads .rubezh.yaml, .rubezh.yml, or .rubezh.json from the current directory. Use --config (or -c) to specify another file.
Files and packages can be excluded with glob patterns. File patterns are relative to the directory containing the configuration file. Package patterns match either a Go import path or a package name.
exclude:
files:
- "**/generated_test.go"
- "internal/legacy/*_test.go"
packages:
- "github.com/example/project/generated/**"
- "legacy"
The equivalent JSON structure is also supported:
{
"exclude": {
"files": ["**/generated_test.go"],
"packages": ["github.com/example/project/generated/**"]
}
}
How to install
You can download the latest release from the release page.
If you have Go installed, you can also install Rubezh using the following command:
go install github.com/aethiopicuschan/rubezh@latest
If you want to build Rubezh from source, you can clone the repository and run the following commands:
git clone https://github.com/aethiopicuschan/rubezh.git
cd rubezh
go build -o rubezh
GitHub Actions
Add Rubezh to your workflow after checking out the repository:
name: Rubezh
on:
pull_request:
push:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aethiopicuschan/rubezh@v1