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
30 changes: 0 additions & 30 deletions .github/workflows/coverage.yaml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/lint.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
name: Test
name: Pull Requests
on:
push:
branches:
- main
- develop
paths:
- '**.go'
- 'go.mod'
pull_request:
branches:
- main
Expand Down Expand Up @@ -35,3 +28,23 @@ jobs:
- name: Run Test
run: |
go test -v -count=10 ./...
lint:
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
go install golang.org/x/lint/golint@latest
go mod download
- name: Run Lint
run: |
golint -set_exit_status=1 ./...
81 changes: 81 additions & 0 deletions .github/workflows/push_main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Push Main
on:
push:
branches:
- main
paths:
- '**.go'
- 'go.mod'
jobs:
test:
strategy:
matrix:
go-version: ['1.17']
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
go version
go mod download
- name: Run Test
run: |
go test -v -count=10 ./...
lint:
strategy:
matrix:
go-version: ['1.17']
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
go install golang.org/x/lint/golint@latest
go mod download
- name: Run Lint
run: |
golint -set_exit_status=1 ./...
coverage:
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17'
- name: Install dependencies
run: |
go install golang.org/x/lint/golint@latest
go mod download
- name: Run Test
run: |
go test -v -coverprofile=coverage.txt -covermode=atomic -count=10 ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
fail_ci_if_error: true
verbose: true
release:
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- uses: actions/checkout@master
- uses: go-semantic-release/action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-initial-development-versions: true
force-bump-patch-version: true
18 changes: 0 additions & 18 deletions .github/workflows/release.yaml

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[![codecov](https://codecov.io/gh/evilmonkeyinc/jsonpath/branch/main/graph/badge.svg?token=4PU85I7J2R)](https://codecov.io/gh/evilmonkeyinc/jsonpath)
[![main](https://github.com/evilmonkeyinc/jsonpath/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/evilmonkeyinc/jsonpath/actions/workflows/test.yaml)
[![develop](https://github.com/evilmonkeyinc/jsonpath/actions/workflows/test.yaml/badge.svg?branch=develop)](https://github.com/evilmonkeyinc/jsonpath/actions/workflows/test.yaml)
[![Go Reference](https://pkg.go.dev/badge/github.com/evilmonkeyinc/jsonpath.svg)](https://pkg.go.dev/github.com/evilmonkeyinc/jsonpath)

> This library is on the unstable version v0.X.X, which means there is a chance that any minor update may introduce a breaking change. Where I will endeavor to avoid this, care should be taken updating your dependency on this library until the first stable release v1.0.0 at which point any future breaking changes will result in a new major release.
Expand Down
10 changes: 5 additions & 5 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,17 @@ This implementation would be closer to the 'Scalar consensus' as it does not alw
|`$[?(@.key>42 && @.key<44)]`|`[ {"key": 42}, {"key": 43}, {"key": 44} ]`|`[{"key":43}]`|`[{"key":43}]`|:white_check_mark:|
|`$[?(@.key>0 && false)]`|`[ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ]`|none|`[]`|:question:|
|`$[?(@.key>0 && true)]`|`[ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ]`|none|`[{"key":1},{"key":3}]`|:question:|
|`$[?(@.key>43 || @.key<43)]`|`[ {"key": 42}, {"key": 43}, {"key": 44} ]`|`[{"key":42},{"key":44}]`|`[{"key":42},{"key":44}]`|:white_check_mark:|
|`$[?(@.key>0 || false)]`|`[ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ]`|none|`[{"key":1},{"key":3}]`|:question:|
|`$[?(@.key>0 || true)]`|`[ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ]`|none|`[{"key":1},{"key":3},{"key":-1},{"key":0}]`|:question:|
|`$[?(@.key>43 \|\| @.key<43)]`|`[ {"key": 42}, {"key": 43}, {"key": 44} ]`|`[{"key":42},{"key":44}]`|`[{"key":42},{"key":44}]`|:white_check_mark:|
|`$[?(@.key>0 \|\| false)]`|`[ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ]`|none|`[{"key":1},{"key":3}]`|:question:|
|`$[?(@.key>0 \|\| true)]`|`[ {"key": 1}, {"key": 3}, {"key": "nice"}, {"key": true}, {"key": null}, {"key": false}, {"key": {}}, {"key": []}, {"key": -1}, {"key": 0}, {"key": ""} ]`|none|`[{"key":1},{"key":3},{"key":-1},{"key":0}]`|:question:|
|`$[?(@['key']==42)]`|`[ {"key": 0}, {"key": 42}, {"key": -1}, {"key": 41}, {"key": 43}, {"key": 42.0001}, {"key": 41.9999}, {"key": 100}, {"some": "value"} ]`|`[{"key":42}]`|`[{"key":42}]`|:white_check_mark:|
|`$[?(@['@key']==42)]`|`[ {"@key": 0}, {"@key": 42}, {"key": 42}, {"@key": 43}, {"some": "value"} ]`|`[{"@key":42}]`|`[{"@key":42}]`|:white_check_mark:|
|`$[?(@[-1]==2)]`|`[[2, 3], ["a"], [0, 2], [2]]`|none|`[[0,2],[2]]`|:question:|
|`$[?(@[1]=='b')]`|`[["a", "b"], ["x", "y"]]`|`[["a","b"]]`|`[["a","b"]]`|:white_check_mark:|
|`$[?(@[1]=='b')]`|`{"1": ["a", "b"], "2": ["x", "y"]}`|none|`[["a","b"]]`|:question:|
|`$[?(@)]`|`[ "some value", null, "value", 0, 1, -1, "", [], {}, false, true ]`|none|`["some value","value",0,1,-1,true]`|:question:|
|`$[?(@.a && (@.b || @.c))]`|`[ { "a": true }, { "a": true, "b": true }, { "a": true, "b": true, "c": true }, { "b": true, "c": true }, { "a": true, "c": true }, { "c": true }, { "b": true } ]`|none|`[]`|:question:|
|`[?(@.a && @.b || @.c)]`|`[ { "a": true, "b": true }, { "a": true, "b": true, "c": true }, { "b": true, "c": true }, { "a": true, "c": true }, { "a": true }, { "b": true }, { "c": true }, { "d": true }, {} ]`|none|`null`|:question:|
|`$[?(@.a && (@.b \|\| @.c))]`|`[ { "a": true }, { "a": true, "b": true }, { "a": true, "b": true, "c": true }, { "b": true, "c": true }, { "a": true, "c": true }, { "c": true }, { "b": true } ]`|none|`[]`|:question:|
|`[?(@.a && @.b \|\| @.c)]`|`[ { "a": true, "b": true }, { "a": true, "b": true, "c": true }, { "b": true, "c": true }, { "a": true, "c": true }, { "a": true }, { "b": true }, { "c": true }, { "d": true }, {} ]`|none|`null`|:question:|
|`$[?(@.key/10==5)]`|`[{"key": 60}, {"key": 50}, {"key": 10}, {"key": -50}, {"key/10": 5}]`|none|`[{"key":50}]`|:question:|
|`$[?(@.key-dash == 'value')]`|`[ { "key-dash": "value" } ]`|none|`[]`|:question:|
|`$[?(@.2 == 'second')]`|`[{"a": "first", "2": "second", "b": "third"}]`|none|`[{"2":"second","a":"first","b":"third"}]`|:question:|
Expand Down
10 changes: 8 additions & 2 deletions test/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"os"
"reflect"
"strings"
"testing"

"github.com/evilmonkeyinc/jsonpath"
Expand Down Expand Up @@ -110,6 +111,11 @@ func printConsensusMatrix(writer io.Writer, tests []testData) {
fmt.Fprintf(writer, "|query|data|consensus|actual|match|\n")
fmt.Fprintf(writer, "|---|---|---|---|---|\n")
for _, test := range tests {

query := test.query
// escape | so format doesnt break
query = strings.ReplaceAll(query, "|", "\\|")

expected := test.expected
if expected == nil {
expected = "null"
Expand All @@ -119,7 +125,7 @@ func printConsensusMatrix(writer io.Writer, tests []testData) {
}

if test.consensus == consensusNone {
fmt.Fprintf(writer, "|`%s`|`%v`|%s|`%v`|%s|\n", test.query, test.data, "none", expected, ":question:")
fmt.Fprintf(writer, "|`%s`|`%v`|%s|`%v`|%s|\n", query, test.data, "none", expected, ":question:")
continue
}

Expand All @@ -136,6 +142,6 @@ func printConsensusMatrix(writer io.Writer, tests []testData) {
symbol = ":white_check_mark:"
}

fmt.Fprintf(writer, "|`%s`|`%v`|`%v`|`%v`|%s|\n", test.query, test.data, consensus, expected, symbol)
fmt.Fprintf(writer, "|`%s`|`%v`|`%v`|`%v`|%s|\n", query, test.data, consensus, expected, symbol)
}
}