Skip to content

Commit

Permalink
Move tests over and add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
merschformann committed Feb 19, 2024
1 parent 936a079 commit 3159ab7
Show file tree
Hide file tree
Showing 121 changed files with 15,412 additions and 13 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: go lint
on: [push]
jobs:
sdk-go-lint:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: 1.21.6

- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.54.1
16 changes: 16 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: go test
on: [push]
jobs:
sdk-go-lint:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: 1.21.1

- name: go test
run: go test ./...
19 changes: 19 additions & 0 deletions .github/workflows/json-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: json lint
on: [push]
jobs:
sdk-json-lint:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4

- name: set up node
uses: actions/setup-node@v3
with:
node-version: 18.8

- name: install prettier
run: npm install [email protected] --global

- name: lint .json files with prettier
run: prettier -c "**/*.json"
12 changes: 12 additions & 0 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: markdown lint
on: [push]
jobs:
sdk-markdown-lint:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4

- uses: DavidAnson/markdownlint-cli2-action@v7
with:
globs: "**/*.md"
28 changes: 18 additions & 10 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ func main() {
}

type options struct {
Check check.Options
Model factory.Options
Solve nextroute.ParallelSolveOptions
Format nextroute.FormatOptions
Model factory.Options `json:"model,omitempty"`
Solve nextroute.ParallelSolveOptions `json:"solve,omitempty"`
Format nextroute.FormatOptions `json:"format,omitempty"`
Check check.Options `json:"check,omitempty"`
}

func solver(ctx context.Context,
func solver(
ctx context.Context,
input schema.Input,
options options,
) (runSchema.Output, error) {
Expand All @@ -39,21 +40,28 @@ func solver(ctx context.Context,
return runSchema.Output{}, err
}

parallelSolver, err := nextroute.NewParallelSolver(model)
solver, err := nextroute.NewParallelSolver(model)
if err != nil {
return runSchema.Output{}, err
}

solutions, err := parallelSolver.Solve(ctx, options.Solve)
solutions, err := solver.Solve(ctx, options.Solve)
if err != nil {
return runSchema.Output{}, err
}
last := solutions.Last()

return check.Format(
output, err := check.Format(
ctx,
options,
options.Check,
parallelSolver,
solutions.Last(),
solver,
last,
)
if err != nil {
return runSchema.Output{}, err
}
output.Statistics.Result.Custom = factory.DefaultCustomResultStatistics(last)

return output, nil
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/nextmv-io/nextroute
go 1.21

require (
github.com/nextmv-io/sdk v1.3.0-dev.3.0.20240208143157-d33884fc8dd1
github.com/nextmv-io/sdk v1.3.1-0.20240219215142-f91aa22e1377
gonum.org/v1/gonum v0.14.0
)

Expand All @@ -13,6 +13,7 @@ require (
github.com/gorilla/schema v1.2.0 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/itzg/go-flagsfiller v1.9.1 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/stretchr/testify v1.8.2 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nextmv-io/sdk v1.3.0-dev.3.0.20240208143157-d33884fc8dd1 h1:QwbBMLHwHyvXUjqi51khGNvIf5GorhBY2SIJok9GlHg=
github.com/nextmv-io/sdk v1.3.0-dev.3.0.20240208143157-d33884fc8dd1/go.mod h1:bvEm5ykrrr5H5whByCFwd9DXA4tUaSqCWmJfB4/zfjg=
github.com/nextmv-io/sdk v1.3.1-0.20240219145622-e1dff93c1b6d h1:XWN6IvUPRUqNZ8gcFzPwoBykUpHFt+OnS5snUSbBVq4=
github.com/nextmv-io/sdk v1.3.1-0.20240219145622-e1dff93c1b6d/go.mod h1:lA3YgE1vdclPwQfPH3jFo76WXx5snk9XOWX2PCMO8cc=
github.com/nextmv-io/sdk v1.3.1-0.20240219215142-f91aa22e1377 h1:+LyaM1mq5eOHE99CSDknMyZ99I2wGapbu5Nr3vLp63g=
github.com/nextmv-io/sdk v1.3.1-0.20240219215142-f91aa22e1377/go.mod h1:lA3YgE1vdclPwQfPH3jFo76WXx5snk9XOWX2PCMO8cc=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
Expand Down Expand Up @@ -334,6 +336,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sagikazarmark/crypt v0.4.0/go.mod h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand Down
39 changes: 39 additions & 0 deletions tests/check/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"stops": [
{
"id": "Fushimi Inari Taisha",
"location": { "lon": 135.772695, "lat": 34.967146 }
},
{
"id": "Kiyomizu-dera",
"location": { "lon": 135.78506, "lat": 34.994857 }
},
{
"id": "Nijō Castle",
"location": { "lon": 135.748134, "lat": 35.014239 }
},
{
"id": "Kyoto Imperial Palace",
"location": { "lon": 135.762057, "lat": 35.025431 }
},
{
"id": "Gionmachi",
"location": { "lon": 135.775682, "lat": 35.002457 }
},
{
"id": "Kinkaku-ji",
"location": { "lon": 135.728898, "lat": 35.039705 }
},
{
"id": "Arashiyama Bamboo Forest",
"location": { "lon": 135.672009, "lat": 35.017209 }
}
],
"vehicles": [
{
"id": "v1",
"start_location": { "lon": 135.672009, "lat": 35.017209 },
"speed": 20
}
]
}
Loading

0 comments on commit 3159ab7

Please sign in to comment.