Skip to content

Commit

Permalink
replaces travis ci by github actions and adds quality tools (#44)
Browse files Browse the repository at this point in the history
* replaces travis ci by github actions

* adds codecov.yml file
  • Loading branch information
sangarbe authored Sep 14, 2021
1 parent 3e4f196 commit 456ee1f
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 28 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: ci

on: [push, pull_request]

jobs:

build:
name: ci-build
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
go:
- '1.17'
- '1.16'
- '1.15'
- '1.14'
- '1.13'
- '1.12'
- '1.11'
- '1.10'
runs-on: ${{ matrix.os }}
steps:

- name: Set up Go runtime
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Check out repository code
uses: actions/checkout@v2

- name: Get dependencies
run: go get -v -t -d ./...

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2

- name: Test
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...

- name: Send coverage metrics to Codecov
if: ${{ matrix.go == '1.17' }}
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
fail_ci_if_error: false

21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/golossus/routing)](https://goreportcard.com/report/github.com/golossus/routing)
[![Build Status](https://travis-ci.com/golossus/routing.svg?branch=master)](https://travis-ci.com/golossus/routing)
![ci workflow](https://github.com/golossus/routing/actions/workflows/ci.yml/badge.svg)
[![codecov](https://codecov.io/gh/golossus/routing/branch/master/graph/badge.svg?token=R4RDS0JM4X)](https://codecov.io/gh/golossus/routing)
[![Go Report Card](https://goreportcard.com/badge/github.com/golossus/routing)](https://goreportcard.com/report/github.com/golossus/routing)
[![CodeFactor](https://www.codefactor.io/repository/github/golossus/routing/badge)](https://www.codefactor.io/repository/github/golossus/routing)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=golossus_routing&metric=alert_status)](https://sonarcloud.io/dashboard?id=golossus_routing)


<p align="center">
<a href="https://www.golossus.com" target="_blank">
Expand Down
4 changes: 2 additions & 2 deletions bench_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func BenchmarkRouter_GenerateURL(b *testing.B) {
paramsKey.add("id", "2")
paramsKey.add("name", "john")
for i := 0; i < b.N; i++ {
mainRouter.GenerateURL("path1.id.name", paramsKey)
_, _ = mainRouter.GenerateURL("path1.id.name", paramsKey)
}
}

Expand All @@ -202,7 +202,7 @@ func benchRouter(b *testing.B, prioritizeByWeight bool) {
before := m.HeapAlloc
handler := func(response http.ResponseWriter, request *http.Request) {}
for _, routes := range testRoutes {
router.Register(http.MethodGet, routes, handler)
_ = router.Register(http.MethodGet, routes, handler)
}
if prioritizeByWeight {
router.PrioritizeByWeight()
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
codecov:
require_ci_to_pass: no
3 changes: 2 additions & 1 deletion fixtures/test.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
Expand Down
4 changes: 2 additions & 2 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ func (r *Router) Register(verb, path string, handler http.HandlerFunc, options .
r.routes[rname] = leaf

if r.config.EnableAutoMethodHead && verb == http.MethodGet {
err = r.Register(http.MethodHead, path, handler, options...)
_ = r.Register(http.MethodHead, path, handler, options...)
}

if r.config.EnableAutoMethodOptions && verb != http.MethodOptions {
err = r.Register(http.MethodOptions, path, getAutoMethodOptionsHandler(r), options...)
_ = r.Register(http.MethodOptions, path, getAutoMethodOptionsHandler(r), options...)
}

return nil
Expand Down

0 comments on commit 456ee1f

Please sign in to comment.