Skip to content

Commit 0d401cc

Browse files
committed
chore: migrate travis to github actions
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent f8b4345 commit 0d401cc

File tree

4 files changed

+82
-47
lines changed

4 files changed

+82
-47
lines changed

.github/workflows/go.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Setup go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: '^1.16'
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
- name: Setup golangci-lint
22+
uses: golangci/golangci-lint-action@v2
23+
with:
24+
version: v1.42.0
25+
args: --verbose
26+
test:
27+
strategy:
28+
matrix:
29+
os: [ubuntu-latest, macos-latest]
30+
go: [1.13, 1.14, 1.15, 1.16, 1.17]
31+
include:
32+
- os: ubuntu-latest
33+
go-build: ~/.cache/go-build
34+
- os: macos-latest
35+
go-build: ~/Library/Caches/go-build
36+
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
37+
runs-on: ${{ matrix.os }}
38+
env:
39+
GO111MODULE: on
40+
GOPROXY: https://proxy.golang.org
41+
steps:
42+
- name: Set up Go ${{ matrix.go }}
43+
uses: actions/setup-go@v2
44+
with:
45+
go-version: ${{ matrix.go }}
46+
47+
- name: Checkout Code
48+
uses: actions/checkout@v2
49+
with:
50+
ref: ${{ github.ref }}
51+
52+
- uses: actions/cache@v2
53+
with:
54+
path: |
55+
${{ matrix.go-build }}
56+
~/go/pkg/mod
57+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
58+
restore-keys: |
59+
${{ runner.os }}-go-
60+
- name: Run Tests
61+
run: |
62+
go test -v -covermode=atomic -coverprofile=coverage.out
63+
64+
- name: Upload coverage to Codecov
65+
uses: codecov/codecov-action@v2
66+
with:
67+
flags: ${{ matrix.os }},go-${{ matrix.go }}

.travis.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ Limit size of POST requests for Gin framework
1010

1111
## Example
1212

13-
[embedmd]:# (example/main.go go)
1413
```go
1514
package main
1615

1716
import (
18-
"net/http"
19-
"github.com/gin-contrib/size"
20-
"github.com/gin-gonic/gin"
17+
"net/http"
18+
19+
"github.com/gin-contrib/size"
20+
"github.com/gin-gonic/gin"
2121
)
2222

2323
func handler(ctx *gin.Context) {
24-
val := ctx.PostForm("b")
25-
if len(ctx.Errors) > 0 {
26-
return
27-
}
28-
ctx.String(http.StatusOK, "got %s\n", val)
24+
val := ctx.PostForm("b")
25+
if len(ctx.Errors) > 0 {
26+
return
27+
}
28+
ctx.String(http.StatusOK, "got %s\n", val)
2929
}
3030

3131
func main() {
32-
rtr := gin.Default()
33-
rtr.Use(limits.RequestSizeLimiter(10))
34-
rtr.POST("/", handler)
35-
rtr.Run(":8080")
32+
rtr := gin.Default()
33+
rtr.Use(limits.RequestSizeLimiter(10))
34+
rtr.POST("/", handler)
35+
rtr.Run(":8080")
3636
}
3737
```

example/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package main
22

33
import (
44
"net/http"
5-
"github.com/gin-contrib/size"
5+
6+
limits "github.com/gin-contrib/size"
67
"github.com/gin-gonic/gin"
78
)
89

0 commit comments

Comments
 (0)