Skip to content

Commit 3bec49a

Browse files
Initial commit
0 parents  commit 3bec49a

File tree

12 files changed

+818
-0
lines changed

12 files changed

+818
-0
lines changed

.assets/icon.png

23.9 KB
Loading

.github/workflows/go-cross.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Go Matrix
2+
on: [push, pull_request]
3+
4+
jobs:
5+
6+
cross:
7+
name: Go
8+
runs-on: ${{ matrix.os }}
9+
env:
10+
CGO_ENABLED: 0
11+
12+
strategy:
13+
matrix:
14+
go-version: [ 1.19, 1.x ]
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
17+
steps:
18+
# https://github.com/marketplace/actions/setup-go-environment
19+
- name: Set up Go ${{ matrix.go-version }}
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
24+
# https://github.com/marketplace/actions/checkout
25+
- name: Checkout code
26+
uses: actions/checkout@v2
27+
28+
# https://github.com/marketplace/actions/cache
29+
- name: Cache Go modules
30+
uses: actions/cache@v3
31+
with:
32+
# In order:
33+
# * Module download cache
34+
# * Build cache (Linux)
35+
# * Build cache (Mac)
36+
# * Build cache (Windows)
37+
path: |
38+
~/go/pkg/mod
39+
~/.cache/go-build
40+
~/Library/Caches/go-build
41+
%LocalAppData%\go-build
42+
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
43+
restore-keys: |
44+
${{ runner.os }}-${{ matrix.go-version }}-go-
45+
46+
- name: Test
47+
run: go test -v -cover ./...

.github/workflows/main.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
11+
main:
12+
name: Main Process
13+
runs-on: ubuntu-latest
14+
env:
15+
GO_VERSION: 1.19
16+
GOLANGCI_LINT_VERSION: v1.50.0
17+
YAEGI_VERSION: v0.14.2
18+
CGO_ENABLED: 0
19+
defaults:
20+
run:
21+
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
22+
23+
steps:
24+
25+
# https://github.com/marketplace/actions/setup-go-environment
26+
- name: Set up Go ${{ env.GO_VERSION }}
27+
uses: actions/setup-go@v2
28+
with:
29+
go-version: ${{ env.GO_VERSION }}
30+
31+
# https://github.com/marketplace/actions/checkout
32+
- name: Check out code
33+
uses: actions/checkout@v2
34+
with:
35+
path: go/src/github.com/${{ github.repository }}
36+
fetch-depth: 0
37+
38+
# https://github.com/marketplace/actions/cache
39+
- name: Cache Go modules
40+
uses: actions/cache@v3
41+
with:
42+
path: ${{ github.workspace }}/go/pkg/mod
43+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
44+
restore-keys: |
45+
${{ runner.os }}-go-
46+
47+
# https://golangci-lint.run/usage/install#other-ci
48+
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
49+
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
50+
51+
- name: Install Yaegi ${{ env.YAEGI_VERSION }}
52+
run: curl -sfL https://raw.githubusercontent.com/traefik/yaegi/master/install.sh | bash -s -- -b $(go env GOPATH)/bin ${YAEGI_VERSION}
53+
54+
- name: Setup GOPATH
55+
run: go env -w GOPATH=${{ github.workspace }}/go
56+
57+
- name: Check and get dependencies
58+
run: |
59+
go mod tidy
60+
git diff --exit-code go.mod
61+
# git diff --exit-code go.sum
62+
go mod download
63+
go mod vendor
64+
# git diff --exit-code ./vendor/
65+
66+
- name: Lint and Tests
67+
run: make
68+
69+
- name: Run tests with Yaegi
70+
run: make yaegi_test
71+
env:
72+
GOPATH: ${{ github.workspace }}/go

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
.DS_Store

.golangci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
run:
2+
timeout: 3m
3+
skip-files: []
4+
skip-dirs: []
5+
6+
linters-settings:
7+
govet:
8+
enable-all: true
9+
disable:
10+
- fieldalignment
11+
golint:
12+
min-confidence: 0
13+
gocyclo:
14+
min-complexity: 12
15+
goconst:
16+
min-len: 5
17+
min-occurrences: 4
18+
misspell:
19+
locale: US
20+
funlen:
21+
lines: -1
22+
statements: 50
23+
godox:
24+
keywords:
25+
- FIXME
26+
gofumpt:
27+
extra-rules: true
28+
29+
linters:
30+
enable-all: true
31+
disable:
32+
- deadcode # deprecated
33+
- exhaustivestruct # deprecated
34+
- golint # deprecated
35+
- ifshort # deprecated
36+
- interfacer # deprecated
37+
- maligned # deprecated
38+
- nosnakecase # deprecated
39+
- scopelint # deprecated
40+
- scopelint # deprecated
41+
- structcheck # deprecated
42+
- varcheck # deprecated
43+
- sqlclosecheck # not relevant (SQL)
44+
- rowserrcheck # not relevant (SQL)
45+
- execinquery # not relevant (SQL)
46+
- cyclop # duplicate of gocyclo
47+
- bodyclose # Too many false positives: https://github.com/timakin/bodyclose/issues/30
48+
- dupl
49+
- testpackage
50+
- tparallel
51+
- paralleltest
52+
- nlreturn
53+
- wsl
54+
- exhaustive
55+
- exhaustruct
56+
- goerr113
57+
- wrapcheck
58+
- ifshort
59+
- noctx
60+
- lll
61+
- gomnd
62+
- forbidigo
63+
- varnamelen
64+
65+
issues:
66+
exclude-use-default: false
67+
max-per-linter: 0
68+
max-same-issues: 0
69+
exclude: []
70+
exclude-rules:
71+
- path: (.+)_test.go
72+
linters:
73+
- goconst
74+
- funlen
75+
- godot

.traefik.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
displayName: Demo Plugin
2+
type: middleware
3+
iconPath: .assets/icon.png
4+
5+
import: github.com/traefik/plugindemo
6+
7+
summary: '[Demo] Add Request Header'
8+
9+
testData:
10+
Headers:
11+
X-Demo: test
12+
X-URL: '{{URL}}'

0 commit comments

Comments
 (0)