Skip to content

Commit

Permalink
Adopting my more standard ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilner committed Oct 7, 2020
1 parent c11ed4d commit c026dd8
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 13 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: lint
on:
push:
tags:
- v*
branches:
- main
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.31

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
19 changes: 19 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on: [push, pull_request]
name: tests
jobs:
test:
strategy:
matrix:
go-version: [1.15.x]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: go test ./...

6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
linters:
enable:
- goimports
linters-settings:
goimports:
local-prefixes: github.com/jwilner/rte
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test test-cover bench gen check
.PHONY: test test-cover bench gen check lint fix

MAX-VARS := 8

Expand All @@ -19,3 +19,9 @@ gen:

check:
devscripts/check.sh ${MAX-VARS}

lint:
@golangci-lint run

fix:
@golangci-lint run --fix
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# rte - routing table extraordinaire

[![Build Status](https://travis-ci.com/jwilner/rte.svg?branch=master)](https://travis-ci.com/jwilner/rte)
[![Go Report Card](https://goreportcard.com/badge/github.com/jwilner/rte)](https://goreportcard.com/report/github.com/jwilner/rte)
[![Tests](https://github.com/jwilner/rte/workflows/tests/badge.svg)](https://github.com/jwilner/rte/actions?query=workflow%3Atests+branch%3Amain)
[![Lint](https://github.com/jwilner/rte/workflows/lint/badge.svg)](https://github.com/jwilner/rte/actions?query=workflow%3Alint+branch%3Amain)
[![GoDoc](https://godoc.org/github.com/jwilner/rte?status.svg)](https://godoc.org/github.com/jwilner/rte)
[![Coverage Status](https://coveralls.io/repos/github/jwilner/rte/badge.svg?branch=coverage)](https://coveralls.io/github/jwilner/rte?branch=coverage)
[![Coverage](https://coveralls.io/repos/github/jwilner/rte/badge.svg?branch=coverage)](https://coveralls.io/github/jwilner/rte?branch=coverage)

Simple, opinionated, performant routing.

Expand Down
3 changes: 2 additions & 1 deletion examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package rte_test

import (
"fmt"
"github.com/jwilner/rte"
"net/http"
"net/http/httptest"

"github.com/jwilner/rte"
)

func ExampleMiddlewareFunc() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/jwilner/rte

go 1.12
go 1.15
5 changes: 3 additions & 2 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package rte

import (
"fmt"
"github.com/jwilner/rte/internal/funcs"
"net/http"
"strings"

"github.com/jwilner/rte/internal/funcs"
)

// Routes is a vanity constructor for constructing literal routing tables. It enforces types at runtime. An invocation
Expand Down Expand Up @@ -62,7 +63,7 @@ func Routes(is ...interface{}) []Route {
switch v := is[idxHandler].(type) {
case []Route:
if len(reqLine) == 0 || reqLine[0] != '/' {
panic(fmt.Sprintf("rte.Routes: if providing []Route as a target, reqLine must be a prefix"))
panic("rte.Routes: if providing []Route as a target, reqLine must be a prefix")
}
newRoutes = Prefix(reqLine, v)
default:
Expand Down
3 changes: 2 additions & 1 deletion helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package rte_test
import (
"bytes"
"fmt"
"github.com/jwilner/rte"
"log"
"net/http"
"net/http/httptest"
"reflect"
"testing"

"github.com/jwilner/rte"
)

type mockH bool
Expand Down
4 changes: 2 additions & 2 deletions rte.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ package rte

import (
"fmt"
"github.com/jwilner/rte/internal/funcs"
"net/http"
"regexp"
"strings"

"github.com/jwilner/rte/internal/funcs"
)

const (
Expand Down Expand Up @@ -324,7 +325,6 @@ func applyMiddleware(h funcs.Handler, mw Middleware) funcs.Handler {
type Table struct {
Default http.Handler
root *node
maxParams int
methods []string
methodMask uint
}
Expand Down
5 changes: 3 additions & 2 deletions rte_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package rte_test
import (
"encoding/json"
"fmt"
"github.com/jwilner/rte"
"github.com/jwilner/rte/internal/funcs"
"net/http"
"net/http/httptest"
"reflect"
"strconv"
"strings"
"testing"

"github.com/jwilner/rte"
"github.com/jwilner/rte/internal/funcs"
)

func TestNew(t *testing.T) {
Expand Down

0 comments on commit c026dd8

Please sign in to comment.