From afbe611e4788ffffb2c48d94d65786ff6b36c85d Mon Sep 17 00:00:00 2001 From: Yusuke Asai Date: Sun, 31 Aug 2025 08:58:57 +0900 Subject: [PATCH] add peg as a tool dependency --- .github/dependabot.yml | 12 ++++++++++++ .github/workflows/test.yml | 7 +++++++ go.mod | 4 +++- go.sum | 2 ++ internal/depends/depends.go | 6 ++++++ internal/grammer/generate.go | 3 +++ .../{syntax/jsonpath.peg => grammer/grammar.peg} | 0 internal/syntax/{jsonpath.peg.go => grammar.go} | 2 +- 8 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 internal/depends/depends.go create mode 100644 internal/grammer/generate.go rename internal/{syntax/jsonpath.peg => grammer/grammar.peg} (100%) rename internal/syntax/{jsonpath.peg.go => grammar.go} (99%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6269e59 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 5 + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 5 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c199ced..b3495de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,13 @@ jobs: with: go-version-file: 'go.mod' + - name: Generate parser (peg) + run: go generate ./... + + - name: Check generated files up-to-date + run: | + git --no-pager diff --exit-code || (echo "Run 'go generate ./...' and commit generated changes" && exit 1) + - name: Run Unit tests run: go test -race -covermode atomic -coverprofile=covprofile -coverpkg=.,./config,./errors,./internal/syntax ./... diff --git a/go.mod b/go.mod index ec6dcb9..003ea1a 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/AsaiYusuke/jsonpath/v2 -go 1.24 +go 1.25 + +require github.com/pointlander/peg v1.0.2-0.20250815145649-e7926250bae5 diff --git a/go.sum b/go.sum index e69de29..738938f 100644 --- a/go.sum +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/pointlander/peg v1.0.2-0.20250815145649-e7926250bae5 h1:HpP/2mYdqYYy33qBhgkJtordzBMQivEO4yKh2TsPFis= +github.com/pointlander/peg v1.0.2-0.20250815145649-e7926250bae5/go.mod h1:jOjW+bhmjY4xlK6MReHcgyq470+kgM+74DE4xP6G86Y= diff --git a/internal/depends/depends.go b/internal/depends/depends.go new file mode 100644 index 0000000..e4b4598 --- /dev/null +++ b/internal/depends/depends.go @@ -0,0 +1,6 @@ +//go:build depends +// +build depends + +package depends + +import _ "github.com/pointlander/peg" diff --git a/internal/grammer/generate.go b/internal/grammer/generate.go new file mode 100644 index 0000000..f640a07 --- /dev/null +++ b/internal/grammer/generate.go @@ -0,0 +1,3 @@ +package grammer + +//go:generate go run github.com/pointlander/peg -inline -switch -output ../syntax/grammar.go grammar.peg diff --git a/internal/syntax/jsonpath.peg b/internal/grammer/grammar.peg similarity index 100% rename from internal/syntax/jsonpath.peg rename to internal/grammer/grammar.peg diff --git a/internal/syntax/jsonpath.peg.go b/internal/syntax/grammar.go similarity index 99% rename from internal/syntax/jsonpath.peg.go rename to internal/syntax/grammar.go index c7bd056..e105da3 100644 --- a/internal/syntax/jsonpath.peg.go +++ b/internal/syntax/grammar.go @@ -1,4 +1,4 @@ -// Code generated by peg -inline -switch internal/syntax/jsonpath.peg. DO NOT EDIT. +// Code generated by peg -inline -switch -output ../syntax/grammar.go grammar.peg. DO NOT EDIT. package syntax