Skip to content

Commit

Permalink
feat: new workflow add
Browse files Browse the repository at this point in the history
  • Loading branch information
waldirborbajr committed Feb 28, 2024
1 parent 70b76f4 commit 9db7865
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Lint
on:
push:
paths:
- "**.go"
- go.mod
- go.sum
pull_request:
paths:
- "**.go"
- go.mod
- go.sum

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Check out code
uses: actions/checkout@v4

- name: Restore Go modules cache
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: go-${{ runner.os }}-${{ hashFiles('go.mod') }}
restore-keys: |
go-${{ runner.os }}-
- name: Verify dependencies
run: |
go mod verify
go mod download
LINT_VERSION=1.54.1
curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v${LINT_VERSION}/golangci-lint-${LINT_VERSION}-linux-amd64.tar.gz | \
tar xz --strip-components 1 --wildcards \*/golangci-lint
mkdir -p bin && mv golangci-lint bin/
- name: Run checks
run: |
STATUS=0
assert-nothing-changed() {
local diff
"$@" >/dev/null || return 1
if ! diff="$(git diff -U1 --color --exit-code)"; then
printf '\e[31mError: running `\e[1m%s\e[22m` results in modifications that you must check into version control:\e[0m\n%s\n\n' "$*" "$diff" >&2
git checkout -- .
STATUS=1
fi
}
assert-nothing-changed go fmt ./...
assert-nothing-changed go mod tidy
bin/golangci-lint run --out-format=github-actions --timeout=3m || STATUS=$?
exit $STATUS
14 changes: 14 additions & 0 deletions .github/workflows/typo-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Typo Check

on: [workflow_call]

jobs:
typocheck:
name: "Typo Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: typos-action
uses: crate-ci/typos@v1.18.2

28 changes: 28 additions & 0 deletions .github/workflows/update_contributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Update CONTRIBUTORS file
on:
schedule:
- cron: "0 0 1 * *"
workflow_dispatch:
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: minicli/action-contributors@v3
name: "Update a projects CONTRIBUTORS file"
env:
CONTRIB_REPOSITORY: 'waldirborbajr/kvstok'
CONTRIB_OUTPUT_FILE: 'CONTRIBUTORS.md'
- name: Create a PR
uses: peter-evans/create-pull-request@v6
with:
commit-message: Update Contributors
title: "[automated] Update Contributors File"
token: ${{ secrets.GITHUB_TOKEN }}

# - name: Update resources
# uses: test-room-7/action-update-file@v1
# with:
# file-path: 'CONTRIBUTORS.md'
# commit-msg: Update Contributors
# github-token: ${{ secrets.GITHUB_TOKEN }}
69 changes: 69 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
run:
timeout: 5m

linters:
enable-all: false
disable:
disable-all: true
presets:
fast: false
enable:
- gocritic
- ineffassign
- staticcheck
- stylecheck
- unused
- govet
- gofmt
- typecheck
- goimports
- gosec

issues:
max-same-issues: 0
max-same: 0
new: false
exclude-use-default: false
fix: true
exclude:
- "G304: Potential file inclusion via variable"
- "G204: Subprocess launched with variable"
- "G104: Errors unhandled"
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
# unparam warns that return value is always nil for functions that have an obligatory error return value but cannot produce an error
- .*result 0 \(error\) is always nil

linters-settings:
errcheck:
check-type-assertions: false
check-blank: true
gocyclo:
min-complexity: 10
golint:
min-confidence: 0.8
govet:
check-shadowing: true
stylecheck:
checks: [
"ST1019", # Importing the same package multiple times.
]
staticcheck:
checks: [
"all",
"-SA1019", # TODO(fix) Using a deprecated function, variable, constant or field
"-SA2002" # TODO(fix) Called testing.T.FailNow or SkipNow in a goroutine, which isn’t allowed
]
gocritic:
enabled-checks:
- equalFold
- boolExprSimplify

output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

0 comments on commit 9db7865

Please sign in to comment.