Skip to content

Commit

Permalink
Merge pull request #1 from nextmv-io/feature/templates
Browse files Browse the repository at this point in the history
Add the code from templates
  • Loading branch information
sebastian-quintero authored Jan 17, 2024
2 parents fbb7e8e + 2a4ca61 commit 5bc5f09
Show file tree
Hide file tree
Showing 43 changed files with 5,409 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: go lint
on: [push]
jobs:
community-apps-go-lint:
runs-on: ubuntu-latest
# Use a matrix strategy to test all the modules simultaneously.
strategy:
fail-fast: false
matrix:
MOD_PATH: [./mip, ./nextroute, ./shift-scheduling]
steps:
- name: set up go
uses: actions/setup-go@v5
with:
go-version: 1.19.3
id: go

- name: git clone
uses: actions/checkout@v4

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.1
working-directory: ${{ matrix.MOD_PATH }}
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:
community-apps-json-lint:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4

- name: set up node
uses: actions/setup-node@v4
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:
community-apps-markdown-lint:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4

- uses: DavidAnson/markdownlint-cli2-action@v14
with:
globs: "**/*.md"
21 changes: 21 additions & 0 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: python lint
on: [push]
jobs:
community-apps-python-lint:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4

- name: set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff==0.1.6
- name: lint with ruff
run: ruff check --output-format=github .
176 changes: 176 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Options for analysis running. Details: https://golangci-lint.run/usage/configuration/#run-configuration
run:
timeout: 5m
go: "1.19"

# Configures linters. Details: https://golangci-lint.run/usage/linters
linters-settings:
# Pick up duplicate code after severe repetition.
dupl:
threshold: 200
# Only allow certain modules to be imported.
gomodguard:
allowed:
modules:
- github.com/nextmv-io/sdk
- github.com/nextmv-io/sdk/route
- github.com/nextmv-io/sdk/route/osrm
- github.com/nextmv-io/sdk/route/here
- github.com/nextmv-io/sdk/route/google
- github.com/nextmv-io/sdk/route/routingkit
- github.com/nextmv-io/sdk/measure/here
- github.com/nextmv-io/sdk/measure/osrm
- github.com/nextmv-io/sdk/measure/google
- github.com/nextmv-io/sdk/measure/routingkit
- googlemaps.github.io/maps
- github.com/dgraph-io/ristretto
- go.uber.org/mock
- github.com/google/go-cmp
- github.com/hashicorp/golang-lru
- github.com/nextmv-io/go-routingkit
- github.com/twpayne/go-polyline
- googlemaps.github.io/maps
- github.com/itzg/go-flagsfiller
- github.com/gorilla/schema
- github.com/google/uuid
- github.com/xeipuuv/gojsonschema
- github.com/danielgtaylor/huma
# Functions cannot exceed this cyclomatic complexity.
gocyclo:
min-complexity: 20
# Set correct go version.
gosimple:
go: "1.19"
staticcheck:
go: "1.19"
stylecheck:
go: "1.19"
# Check case of struct tags
tagliatelle:
case:
use-field-name: true
rules:
json: snake
# Check line length
lll:
line-length: 120

# Specifies which linters are enabled. Full list: https://golangci-lint.run/usage/linters/
linters:
# Some linters are just too strict.
disable-all: true
enable:
# Checks whether HTTP response body is closed successfully.
- bodyclose
# containedctx is a linter that detects struct contained context.Context field.
- containedctx
# Check the function whether use a non-inherited context.
- contextcheck
# Finds unused code. WARN [runner] The linter 'deadcode' is deprecated
# (since v1.49.0) due to: The owner seems to have abandoned the linter.
# Replaced by unused.
# - deadcode
# check declaration order and count of types, constants, variables and functions.
- decorder
# Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
- dogsled
# Tool for code clone detection
- dupl
# Errcheck is a program for checking for unchecked errors in go programs.
# These unchecked errors can be critical bugs in some cases.
- errcheck
# Gci controls golang package import order and makes it always deterministic.
- gci
# Finds repeated strings that could be replaced by a constant.
- goconst
# Provides diagnostics that check for bugs, performance and style issues.
# Extensible without recompilation through dynamic rules. Dynamic rules are
# written declaratively with AST patterns, filters, report message and
# optional suggestion.
- gocritic
# Computes and checks the cyclomatic complexity of functions.
- gocyclo
# Check if comments end in a period.
- godot
# Gofmt checks whether code was gofmt-ed. By default this tool runs with -s
# option to check for code simplification.
- gofmt
# In addition to fixing imports, goimports also formats your code in the
# same style as gofmt.
- goimports
# Allow and block list linter for direct Go module dependencies. This is
# different from depguard where there are different block types for example
# version constraints and module recommendations.
- gomodguard
# gosec offers another set of security checks in addition to govet
- gosec
# Linter for Go source code that specializes in simplifying a code.
- gosimple
# Vet examines Go source code and reports suspicious constructs, such as
# Printf calls whose arguments do not align with the format string.
- govet
# Enforces consistent import aliases.
- importas
# Detects when assignments to existing variables are not used.
- ineffassign
# Reports long lines.
- lll
# Finds commonly misspelled English words in comments.
- misspell
# Finds naked returns in functions greater than a specified function length.
- nakedret
# Reports deeply nested if statements.
- nestif
# Finds the code that returns nil even if it checks that the error is not nil.
- nilerr
# noctx finds sending http request without context.Context.
- noctx
# Finds slice declarations that could potentially be preallocated.
- prealloc
# Find code that shadows one of Go's predeclared identifiers.
- predeclared
# Fast, configurable, extensible, flexible, and beautiful linter for Go.
# Drop-in replacement of golint.
- revive
# Staticcheck is a go vet on steroids, applying a ton of static analysis checks.
- staticcheck
# Finds unused struct fields. WARN [runner] The linter 'structcheck' is
# deprecated (since v1.49.0) due to: The owner seems to have abandoned the
# linter. Replaced by unused.
# - structcheck
# Stylecheck is a replacement for golint.
- stylecheck
# Checks the struct tags.
- tagliatelle
# Like the front-end of a Go compiler, parses and type-checks Go code.
- typecheck
# Remove unnecessary type conversions.
- unconvert
# Reports unused function parameters.
- unparam
# Checks Go code for unused constants, variables, functions and types.
- unused
# Finds unused global variables and constants. WARN [runner] The linter
# 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have
# abandoned the linter. Replaced by unused.
# - varcheck
# wastedassign finds wasted assignment statements.
- wastedassign
# Tool for detection of leading and trailing whitespace.
- whitespace

# List of regexps of issue texts to exclude. Details: https://golangci-lint.run/usage/configuration/#issues-configuration
issues:
# Disable default exclude patterns to surface commonly-ignored linting errors.
exclude-use-default: false
exclude-rules:
- path: shift-scheduling/main\.go
linters:
- gocyclo
- nestif
# json tags are too long and unmarshal does not throw an error where one is
# needed for the signature of the function.
- path: shift-scheduling/schema\.go
linters:
- lll
- unparam
1 change: 1 addition & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tabWidth: 2
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# community-apps
Pre-built decision models serving as the base for Marketplace subscription apps.
# Nextmv community apps

Pre-built decision models serving as the base for [Marketplace subscription
apps][subscription-apps]. Each app is standalone and can be executed following
the instructions in the README.

Before starting:

1. [Sign up][signup] for a Nextmv account.
2. [Install][installation] the Nextmv Platform.

Visit the [docs][docs] for more information.

* [`mip`][mip]: use the Nextmv Go SDK to solve Mixed Integer Programming
problems. Contains a knapsack problem as an example.
* [`nextroute`][nextroute]: use the Nextmv Go SDK to solve vehicle routing
problems.
* [`ortools`][ortools]: use Python and Google OR-Tools for various optimization
problems. Contains a knapsack problem as an example.
* [`pyomo`][pyomo]: use Python and Pyomo to solve various optimization
problems. Contains a knapsack problem as an example.
* [`shift-scheduling`][shift-scheduling]: use the Nextmv Go SDK to solve shift
scheduling problems.
* [`xpress`][xpress]: use FICO-Xpress to solve various optimization problems.
Contains a knapsack problem as an example.

[subscription-apps]: https://nextmv.io/docs/platform/deploy-app/subscription-apps
[installation]: https://nextmv.io/docs/platform/installation
[docs]: https://nextmv.io/docs
[signup]: https://cloud.nextmv.io
[mip]: /mip/README.md
[nextroute]: /nextroute/README.md
[ortools]: /ortools/README.md
[pyomo]: /pyomo/README.md
[shift-scheduling]: /shift-scheduling/README.md
[xpress]: /xpress/README.md
Loading

0 comments on commit 5bc5f09

Please sign in to comment.