Skip to content

Commit 1a489d1

Browse files
authored
feat: add Justfile validation via embedded go-just module (#454)
Adds Justfile as the 16th supported file type. Validates .just files and known filenames (justfile, Justfile, .justfile) using a pure Go parser embedded as a nested module at pkg/validator/justfile/. The nested module has its own go.mod and can be extracted to a standalone repo later by updating the replace directive. CI pipelines updated to run vet, fmt, lint, and tests on both the root module and the nested go-just module.
1 parent 0148f45 commit 1a489d1

46 files changed

Lines changed: 9368 additions & 8 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/go.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ jobs:
5050
go-version: "1.26"
5151

5252
- name: Static Analysis
53-
run: go vet ./...
53+
run: |
54+
go vet ./...
55+
cd pkg/validator/justfile && go vet ./...
5456
5557
- name: Check Formatting
56-
run: test -z "$(gofmt -s -l -e .)"
58+
run: |
59+
test -z "$(gofmt -s -l -e .)"
60+
cd pkg/validator/justfile && test -z "$(gofmt -s -l -e .)"
5761
5862
- name: Check generated files are up to date
5963
run: |
@@ -106,7 +110,9 @@ jobs:
106110
go-version: "1.26"
107111

108112
- name: Unit test
109-
run: go test -v -cover -coverprofile coverage.out ./...
113+
run: |
114+
go test -v -cover -coverprofile coverage.out ./...
115+
cd pkg/validator/justfile && go test -v -count=1 ./...
110116
111117
- name: Check coverage
112118
id: check-coverage

.github/workflows/golangci-lint.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ jobs:
5252
# The location of the configuration file can be changed by using `--config=`
5353
args: --timeout=10m
5454

55-
# Optional: show only new issues if it's a pull request. The default value is `false`.
56-
# only-new-issues: true
55+
install-mode: "goinstall"
5756

58-
# Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
57+
- name: golangci-lint (go-just nested module)
58+
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
59+
with:
60+
version: v2.11.4
61+
working-directory: pkg/validator/justfile
62+
args: --timeout=10m
5963
install-mode: "goinstall"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Justfile syntax validation (`.just`, `justfile`, `Justfile`, `.justfile`) via embedded [go-just](https://github.com/Boeing/go-just) parser
1213
- `--gitignore` flag to skip files and directories matched by `.gitignore` patterns, including nested `.gitignore` files, `.git/info/exclude`, and global git ignore config. Supported via CLI flag, `CFV_GITIGNORE` env var, and `gitignore = true` in `.cfv.toml`.
1314
- Automatic file type detection from GitHub Linguist's `languages.yml` via `go generate`
1415
- ~90 known filenames auto-detected (`.babelrc`, `tsconfig.json`, `Pipfile`, `pom.xml`, `.gitconfig`, etc.)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
Config File Validator is a cross-platform CLI tool that validates configuration files in your project. Catch syntax errors, schema violations, and misconfigurations across all your config files — with one tool.
4242

4343
- **Single binary, zero dependencies** — no runtimes, no package managers, just one executable
44-
- **15 file formats** — JSON, JSONC, YAML, TOML, XML, HCL, INI, HOCON, ENV, CSV, Properties, EDITORCONFIG, PList, SARIF, and TOON
44+
- **16 file formats** — JSON, JSONC, YAML, TOML, XML, HCL, INI, HOCON, ENV, CSV, Properties, EDITORCONFIG, Justfile, PList, SARIF, and TOON
4545
- **Syntax + schema validation** — validates structure with [JSON Schema](https://json-schema.org/) and XSD, with automatic [SchemaStore](https://www.schemastore.org/) integration
4646
- **CI/CD ready** — JSON, JUnit, and SARIF output for GitHub Actions, GitLab CI, Jenkins, and more
4747
- **Configurable** — project-level `.cfv.toml` config files, glob patterns, schema mappings, and environment variables
@@ -74,6 +74,7 @@ Config File Validator is a cross-platform CLI tool that validates configuration
7474
| HCL |||
7575
| HOCON |||
7676
| INI |||
77+
| Justfile |||
7778
| JSON |||
7879
| JSONC |||
7980
| Properties |||
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Justfile syntax validation
2+
! exec validator project
3+
stdout '✓.*valid.just'
4+
stdout '×.*invalid.just'
5+
6+
# Known filenames detected without extension
7+
exec validator knownfile
8+
stdout '✓.*justfile'
9+
10+
-- project/valid.just --
11+
default:
12+
echo "hello"
13+
14+
build:
15+
echo "building"
16+
-- project/invalid.just --
17+
this is not valid {{{
18+
-- knownfile/justfile --
19+
greet name:
20+
echo "hi {{name}}"

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ require (
2626
)
2727

2828
require (
29+
github.com/Boeing/go-just v0.0.0
2930
github.com/agext/levenshtein v1.2.1 // indirect
3031
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
3132
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
@@ -50,3 +51,5 @@ require (
5051
golang.org/x/tools v0.43.0 // indirect
5152
gopkg.in/warnings.v0 v0.1.2 // indirect
5253
)
54+
55+
replace github.com/Boeing/go-just => ./pkg/validator/justfile

index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ canonical_url: https://boeing.github.io/config-file-validator/
4141
Config File Validator is a cross-platform CLI tool that validates configuration files in your project. Catch syntax errors, schema violations, and misconfigurations across all your config files — with one tool.
4242

4343
- **Single binary, zero dependencies** — no runtimes, no package managers, just one executable
44-
- **15 file formats** — JSON, JSONC, YAML, TOML, XML, HCL, INI, HOCON, ENV, CSV, Properties, EDITORCONFIG, PList, SARIF, and TOON
44+
- **16 file formats** — JSON, JSONC, YAML, TOML, XML, HCL, INI, HOCON, ENV, CSV, Properties, EDITORCONFIG, Justfile, PList, SARIF, and TOON
4545
- **Syntax + schema validation** — validates structure with [JSON Schema](https://json-schema.org/) and XSD, with automatic [SchemaStore](https://www.schemastore.org/) integration
4646
- **CI/CD ready** — JSON, JUnit, and SARIF output for GitHub Actions, GitLab CI, Jenkins, and more
4747
- **Configurable** — project-level `.cfv.toml` config files, glob patterns, schema mappings, and environment variables
@@ -74,6 +74,7 @@ Config File Validator is a cross-platform CLI tool that validates configuration
7474
| HCL |||
7575
| HOCON |||
7676
| INI |||
77+
| Justfile |||
7778
| JSON |||
7879
| JSONC |||
7980
| Properties |||

pkg/filetype/file_type.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,22 @@ var JSONCFileType = FileType{
147147
Validator: validator.JSONCValidator{},
148148
}
149149

150+
var JustfileFileType = FileType{
151+
Name: "justfile",
152+
Extensions: arrToMap("just"),
153+
Validator: validator.JustfileValidator{},
154+
}
155+
150156
// extraKnownFiles contains manual entries not covered by Linguist.
151157
var extraKnownFiles = map[string][]string{
152158
"ini": {
153159
".shellcheckrc",
154160
},
161+
"justfile": {
162+
"justfile",
163+
"Justfile",
164+
".justfile",
165+
},
155166
}
156167

157168
// fileTypeRegistry maps file type names to their package-level variables.
@@ -170,6 +181,7 @@ var fileTypeRegistry = map[string]*FileType{
170181
"env": &EnvFileType,
171182
"toon": &ToonFileType,
172183
"sarif": &SarifFileType,
184+
"justfile": &JustfileFileType,
173185
}
174186

175187
// excludeKnownFiles lists Linguist entries to skip because we have
@@ -240,6 +252,7 @@ func init() {
240252
ToonFileType,
241253
SarifFileType,
242254
JSONCFileType,
255+
JustfileFileType,
243256
}
244257
}
245258

pkg/validator/justfile.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package validator
2+
3+
import (
4+
"errors"
5+
6+
"github.com/Boeing/go-just"
7+
)
8+
9+
type JustfileValidator struct{}
10+
11+
var _ Validator = JustfileValidator{}
12+
13+
func (JustfileValidator) ValidateSyntax(b []byte) (bool, error) {
14+
jf, err := gojust.Parse(b)
15+
if err != nil {
16+
var pe *gojust.ParseError
17+
if errors.As(err, &pe) {
18+
return false, &ValidationError{
19+
Err: errors.New(pe.Message),
20+
Line: pe.Pos.Line,
21+
Column: pe.Pos.Column,
22+
}
23+
}
24+
return false, err
25+
}
26+
27+
diags := jf.Validate()
28+
for _, d := range diags {
29+
if d.Severity == gojust.SeverityError {
30+
return false, &ValidationError{
31+
Err: errors.New(d.Message),
32+
Line: d.Pos.Line,
33+
Column: d.Pos.Column,
34+
}
35+
}
36+
}
37+
38+
return true, nil
39+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "2"
2+
3+
linters:
4+
settings:
5+
gosec:
6+
excludes:
7+
- G101

0 commit comments

Comments
 (0)