Skip to content

Commit

Permalink
Add golangci-lint (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
varfrog authored Jul 11, 2024
1 parent bb36be7 commit 0d7ebac
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
run:
go: '1.19'

linters:
disable-all: true
enable:
- gofumpt

issues:
# Show only new issues: if there are unstaged changes or untracked files,
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
# It's a super-useful option for integration of golangci-lint into existing large codebase.
# It's not practical to fix all existing issues at the moment of integration:
# much better don't allow issues in new code.
#
# Default: false
new: true
35 changes: 35 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: golangci-lint
on:
push:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Find base branch
id: find_base_branch
run: |
BASE_BRANCH=$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)")
if [ -z "$BASE_BRANCH" ]; then
echo "BASE_BRANCH=origin/main" >> $GITHUB_ENV # Default to main if no upstream is set
else
echo "BASE_BRANCH=$BASE_BRANCH" >> $GITHUB_ENV
fi
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
args: --config .github/workflows/.golangci.yml --new-from-rev ${{ env.BASE_BRANCH }}

0 comments on commit 0d7ebac

Please sign in to comment.