Skip to content

Commit

Permalink
feat: update golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
euskadi31 committed Jan 29, 2024
1 parent cc73980 commit 73e3841
Show file tree
Hide file tree
Showing 2 changed files with 217 additions and 149 deletions.
269 changes: 133 additions & 136 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,152 +2,149 @@ name: Go

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.17
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Build
run: go build -race -v ./...

- name: Test
run: go test -race -cover -coverprofile ./coverage.out ./...

- name: Coverage
id: coverage
run: |
go tool cover -func ./coverage.out | tee -a coverage.txt
echo "COVERAGE_CONTENT<<EOF" >> $GITHUB_ENV
cat coverage.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: actions/github-script@v4
if: github.event_name == 'pull_request'
continue-on-error: true
env:
COVERAGE_CONTENT: "${{ env.COVERAGE_CONTENT }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `Code Coverage\n
\`\`\`\n
${process.env.COVERAGE_CONTENT}
\`\`\`
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
const response = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
var comments = response.data;
console.log(comments);
if (comments.length > 0) {
comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
}
if (comments.length > 0) {
const comment = comments.shift();
github.issues.updateComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
body: output
})
} else {
github.issues.createComment({
issue_number: context.issue.number,
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.17
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Build
run: go build -race -v ./...

- name: Test
run: go test -race -cover -coverprofile ./coverage.out ./...

- name: Coverage
id: coverage
run: |
go tool cover -func ./coverage.out | tee -a coverage.txt
echo "COVERAGE_CONTENT<<EOF" >> $GITHUB_ENV
cat coverage.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: actions/github-script@v4
if: github.event_name == 'pull_request'
continue-on-error: true
env:
COVERAGE_CONTENT: "${{ env.COVERAGE_CONTENT }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `Code Coverage\n
\`\`\`\n
${process.env.COVERAGE_CONTENT}
\`\`\`
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
const response = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}
- name: Benchmark
id: benchmark
run: |
go test -benchmem -bench . | tee -a benchmark.txt
echo "BENCHMARK_CONTENT<<EOF" >> $GITHUB_ENV
cat benchmark.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: actions/github-script@v4
if: github.event_name == 'pull_request'
continue-on-error: true
env:
BENCHMARK_CONTENT: "${{ env.BENCHMARK_CONTENT }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `Benchmark\n
\`\`\`\n
${process.env.BENCHMARK_CONTENT}
\`\`\`
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
const response = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
var comments = response.data;
console.log(comments);
if (comments.length > 0) {
comments = comments.filter(comment => comment.body.includes('Benchmark') && comment.user.type === 'Bot');
}
if (comments.length > 0) {
const comment = comments.shift();
github.issues.updateComment({
issue_number: context.issue.number,
});
var comments = response.data;
console.log(comments);
if (comments.length > 0) {
comments = comments.filter(comment => comment.body.includes('Code Coverage') && comment.user.type === 'Bot');
}
if (comments.length > 0) {
const comment = comments.shift();
github.issues.updateComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
body: output
})
} else {
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}
- name: Benchmark
id: benchmark
run: |
go test -benchmem -bench . | tee -a benchmark.txt
echo "BENCHMARK_CONTENT<<EOF" >> $GITHUB_ENV
cat benchmark.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: actions/github-script@v4
if: github.event_name == 'pull_request'
continue-on-error: true
env:
BENCHMARK_CONTENT: "${{ env.BENCHMARK_CONTENT }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `Benchmark\n
\`\`\`\n
${process.env.BENCHMARK_CONTENT}
\`\`\`
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
const response = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
body: output
})
} else {
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3.7.0
with:
version: v1.46.2
skip-pkg-cache: true

- name: Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
});
var comments = response.data;
console.log(comments);
if (comments.length > 0) {
comments = comments.filter(comment => comment.body.includes('Benchmark') && comment.user.type === 'Bot');
}
if (comments.length > 0) {
const comment = comments.shift();
github.issues.updateComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
body: output
})
} else {
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
}
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3.7.0
with:
version: v1.55.2
skip-pkg-cache: true

- name: Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
97 changes: 84 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,85 @@
run:
concurrency: 4
deadline: 3m
issues-exit-code: 1
tests: false
skip-files:
- ".*_mock\\.go"
- "mock_.*\\.go"

linters:
disable-all: true
enable:
- errcheck
- gas
- goconst
- gocyclo
- gofmt
- revive
- govet
- ineffassign
- megacheck
- misspell
- typecheck
- unconvert
- gosimple
- staticcheck
- unused
- asciicheck
- bodyclose
- dogsled
- durationcheck
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- gocritic
- godot
- gosec
- nestif
- nilerr
- nlreturn
- noctx
- prealloc
- predeclared
- sqlclosecheck
- whitespace
- wrapcheck
- wsl
fast: false
linters-settings:
depguard:
rules:
main:
allow:
- $all
dupl:
threshold: 99
errcheck:
check-blank: false
check-type-assertions: false
goconst:
min-len: 3
min-occurrences: 2
gocyclo:
min-complexity: 18
gofmt:
simplify: true
goimports:
local-prefixes: go.opentelemetry.io
govet:
check-shadowing: false
maligned:
suggest-new: true
misspell:
ignore-words:
- cancelled
locale: US
revive:
ignore-generated-header: true
severity: warning
output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true

format: colored-line-number
print-issued-lines: true
print-linter-name: true
run:
concurrency: 4
issues-exit-code: 1
skip-files:
- .*_mock\.go
- mock_.*\.go
- .*/pkg/mod/.*$
tests: false
timeout: 1m

0 comments on commit 73e3841

Please sign in to comment.