Skip to content

Commit 6237865

Browse files
committed
feat: add base
1 parent be212c2 commit 6237865

File tree

3 files changed

+127
-140
lines changed

3 files changed

+127
-140
lines changed

.github/workflows/go.yml

Lines changed: 80 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2,96 +2,93 @@ name: Go
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
10-
1110
build:
1211
name: Build
1312
runs-on: ubuntu-latest
1413
steps:
15-
16-
- name: Set up Go 1.x
17-
uses: actions/setup-go@v5
18-
with:
19-
go-version: "1.x"
20-
id: go
21-
22-
- name: Check out code into the Go module directory
23-
uses: actions/checkout@v4
24-
25-
- name: Build
26-
run: go build -race -v ./...
27-
28-
- name: Test
29-
run: go test -race -cover -coverprofile ./coverage.out ./...
30-
31-
- name: Coverage
32-
id: coverage
33-
run: |
34-
go tool cover -func ./coverage.out | tee -a coverage.txt
35-
echo "COVERAGE_CONTENT<<EOF" >> $GITHUB_ENV
36-
cat coverage.txt >> $GITHUB_ENV
37-
echo "EOF" >> $GITHUB_ENV
38-
39-
40-
- uses: actions/github-script@v4
41-
if: github.event_name == 'pull_request'
42-
continue-on-error: true
43-
env:
44-
COVERAGE_CONTENT: "${{ env.COVERAGE_CONTENT }}"
45-
with:
46-
github-token: ${{ secrets.GITHUB_TOKEN }}
47-
script: |
48-
const output = `Code Coverage\n
49-
\`\`\`\n
50-
${process.env.COVERAGE_CONTENT}
51-
\`\`\`
52-
53-
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
54-
55-
const response = await github.issues.listComments({
56-
owner: context.repo.owner,
57-
repo: context.repo.repo,
58-
issue_number: context.issue.number,
59-
});
60-
61-
var comments = response.data;
62-
63-
console.log(comments);
64-
65-
if (comments.length > 0) {
66-
comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
67-
}
68-
69-
if (comments.length > 0) {
70-
const comment = comments.shift();
71-
72-
github.issues.updateComment({
73-
issue_number: context.issue.number,
14+
- name: Set up Go 1.x
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: "1.x"
18+
id: go
19+
20+
- name: Check out code into the Go module directory
21+
uses: actions/checkout@v4
22+
23+
- name: Build
24+
run: go build -race -v ./...
25+
26+
- name: Test
27+
run: go test -race -cover -coverprofile ./coverage.out ./...
28+
29+
- name: Coverage
30+
id: coverage
31+
run: |
32+
go tool cover -func ./coverage.out | tee -a coverage.txt
33+
echo "COVERAGE_CONTENT<<EOF" >> $GITHUB_ENV
34+
cat coverage.txt >> $GITHUB_ENV
35+
echo "EOF" >> $GITHUB_ENV
36+
37+
- uses: actions/github-script@v4
38+
if: github.event_name == 'pull_request'
39+
continue-on-error: true
40+
env:
41+
COVERAGE_CONTENT: "${{ env.COVERAGE_CONTENT }}"
42+
with:
43+
github-token: ${{ secrets.GITHUB_TOKEN }}
44+
script: |
45+
const output = `Code Coverage\n
46+
\`\`\`\n
47+
${process.env.COVERAGE_CONTENT}
48+
\`\`\`
49+
50+
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
51+
52+
const response = await github.issues.listComments({
7453
owner: context.repo.owner,
7554
repo: context.repo.repo,
76-
comment_id: comment.id,
77-
body: output
78-
})
79-
} else {
80-
github.issues.createComment({
8155
issue_number: context.issue.number,
82-
owner: context.repo.owner,
83-
repo: context.repo.repo,
84-
body: output
85-
})
86-
}
87-
88-
- name: Run golangci-lint
89-
uses: golangci/golangci-lint-action@v4
90-
with:
91-
version: v1.52.2
92-
skip-pkg-cache: true
93-
94-
- name: Coveralls
95-
uses: shogo82148/actions-goveralls@v1
96-
with:
97-
path-to-profile: coverage.out
56+
});
57+
58+
var comments = response.data;
59+
60+
console.log(comments);
61+
62+
if (comments.length > 0) {
63+
comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
64+
}
65+
66+
if (comments.length > 0) {
67+
const comment = comments.shift();
68+
69+
github.issues.updateComment({
70+
issue_number: context.issue.number,
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
comment_id: comment.id,
74+
body: output
75+
})
76+
} else {
77+
github.issues.createComment({
78+
issue_number: context.issue.number,
79+
owner: context.repo.owner,
80+
repo: context.repo.repo,
81+
body: output
82+
})
83+
}
84+
85+
- name: Run golangci-lint
86+
uses: golangci/golangci-lint-action@v4
87+
with:
88+
version: v1.55.2
89+
skip-cache: true
90+
91+
- name: Coveralls
92+
uses: shogo82148/actions-goveralls@v1
93+
with:
94+
path-to-profile: coverage.out

.golangci.yml

Lines changed: 45 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,6 @@
1-
run:
2-
concurrency: 4
3-
deadline: 1m
4-
issues-exit-code: 1
5-
tests: false
6-
skip-files:
7-
- ".*_mock\\.go"
8-
- "mock_.*\\.go"
9-
- ".*/pkg/mod/.*$"
10-
11-
output:
12-
format: colored-line-number
13-
print-issued-lines: true
14-
print-linter-name: true
15-
16-
linters-settings:
17-
errcheck:
18-
check-type-assertions: false
19-
check-blank: false
20-
govet:
21-
check-shadowing: false
22-
revive:
23-
ignore-generated-header: true
24-
severity: warning
25-
gofmt:
26-
simplify: true
27-
gocyclo:
28-
min-complexity: 18
29-
maligned:
30-
suggest-new: true
31-
dupl:
32-
threshold: 80
33-
goconst:
34-
min-len: 4
35-
min-occurrences: 3
36-
depguard:
37-
list-type: blacklist
38-
include-go-root: false
39-
packages:
40-
- github.com/davecgh/go-spew/spew
41-
misspell:
42-
locale: US
43-
ignore-words:
44-
- cancelled
45-
goimports:
46-
local-prefixes: go.opentelemetry.io
47-
48-
491
linters:
502
disable-all: true
513
enable:
52-
- deadcode
53-
- depguard
544
- errcheck
555
- gas
566
- goconst
@@ -61,17 +11,14 @@ linters:
6111
- ineffassign
6212
- megacheck
6313
- misspell
64-
- structcheck
6514
- typecheck
6615
- unconvert
67-
- varcheck
6816
- gosimple
6917
- staticcheck
7018
- unused
7119
- asciicheck
7220
- bodyclose
7321
- dogsled
74-
- dupl
7522
- durationcheck
7623
- errorlint
7724
- exhaustive
@@ -81,15 +28,58 @@ linters:
8128
- gocritic
8229
- godot
8330
- gosec
84-
- ifshort
8531
- nestif
8632
- nilerr
8733
- nlreturn
8834
- noctx
8935
- prealloc
9036
- predeclared
9137
- sqlclosecheck
92-
- tagliatelle
9338
- whitespace
39+
- wrapcheck
9440
- wsl
9541
fast: false
42+
linters-settings:
43+
depguard:
44+
rules:
45+
main:
46+
allow:
47+
- $all
48+
dupl:
49+
threshold: 99
50+
errcheck:
51+
check-blank: false
52+
check-type-assertions: false
53+
goconst:
54+
min-len: 3
55+
min-occurrences: 2
56+
gocyclo:
57+
min-complexity: 18
58+
gofmt:
59+
simplify: true
60+
goimports:
61+
local-prefixes: go.opentelemetry.io
62+
govet:
63+
check-shadowing: false
64+
maligned:
65+
suggest-new: true
66+
misspell:
67+
ignore-words:
68+
- cancelled
69+
locale: US
70+
revive:
71+
ignore-generated-header: true
72+
severity: warning
73+
output:
74+
format: colored-line-number
75+
print-issued-lines: true
76+
print-linter-name: true
77+
run:
78+
concurrency: 4
79+
issues-exit-code: 1
80+
skip-files:
81+
- .*_mock\.go
82+
- mock_.*\.go
83+
- .*/pkg/mod/.*$
84+
tests: false
85+
timeout: 1m

filter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (f inputFilter) filterField(key string, value interface{}) (interface{}, er
7878
for _, filter := range filters {
7979
val, err = filter.Filter(val)
8080
if err != nil {
81-
return val, err
81+
return val, fmt.Errorf("filter error: %w", err)
8282
}
8383
}
8484

@@ -141,7 +141,7 @@ func (f inputFilter) filterFieldValues(key string, values []interface{}) ([]inte
141141
for _, filter := range filters {
142142
val, err = filter.Filter(val)
143143
if err != nil {
144-
return retvals, err
144+
return retvals, fmt.Errorf("filter error: %w", err)
145145
}
146146

147147
retvals[i] = val

0 commit comments

Comments
 (0)