-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup hello world and lint workflow (#1)
* Init Go module `go mod init github.com/anttharju/golangci-lint-updater` * Add hello world https://go.dev/play/ * Add golangci-lint workflow * Improve naming * Add .editorconfig * Read golangci-lint version from a file * Remove unnecessary names * Add a makefile target for installing the linter * Rename workflow to be more generic * Add make shellcheck and workflow step * Fix shellcheck issues * Separate shellcheck from golangci-lint job * Debug shellcheck * Remove which shellcheck It exists. Using find's -exex instead of xargs seemingly fixed the issue. * See if shellcheck catches issues in the action run * Revert "See if shellcheck catches issues in the action run" This reverts commit b8b5ae0. * Rename .golangci-version to .golangci.version Matches .golangci.yml better * Add make lint target See https://tech.davis-hansson.com/p/make/ * Add lint-fix target and rename install-linter to lint-install * Add golangci-lint config file This is not its final form, just something to start with. Pulled from an older (currently private) project of mine. * Remove forbidigo Wanted to see the golangci-lint job fail. I think this is enough for this PR. * Satisfy gosmopolitan Caught me off-guard. Oh well. * Add make ci for use with a pre-commit hook Don't like being caught off-guard. Tighter feedback loop. * Add make install-pre-commit-hook Easier for anyone using the repo to install it now.
- Loading branch information
Antti Harju
authored
Jul 19, 2024
1 parent
a9e53b1
commit 6e54d82
Showing
10 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
tab_width = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Lint | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
golangci-lint: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
- run: echo "GOLANGCI_LINT_VERSION=$(cat .golangci.version)" >> $GITHUB_ENV | ||
- uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: ${{ env.GOLANGCI_LINT_VERSION }} | ||
shellcheck: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: scripts/shellcheck.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v1.59.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
linters: | ||
enable: | ||
- copyloopvar | ||
- intrange | ||
- asasalint | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- containedctx | ||
- contextcheck | ||
- cyclop | ||
- decorder | ||
- dogsled | ||
- dupl | ||
- dupword | ||
- durationcheck | ||
- errcheck | ||
- errchkjson | ||
- errname | ||
- errorlint | ||
- exhaustive | ||
- exportloopref | ||
- forcetypeassert | ||
- funlen | ||
- gci | ||
- ginkgolinter | ||
- gocheckcompilerdirectives | ||
- gochecksumtype | ||
- gocognit | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- goheader | ||
- gomodguard | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- gosmopolitan | ||
- govet | ||
- grouper | ||
- importas | ||
- inamedparam | ||
- ineffassign | ||
- interfacebloat | ||
- ireturn | ||
- lll | ||
- loggercheck | ||
- maintidx | ||
- makezero | ||
- mirror | ||
- musttag | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- nilnil | ||
- nlreturn | ||
- noctx | ||
- nolintlint | ||
- nonamedreturns | ||
- nosprintfhostport | ||
- paralleltest | ||
- perfsprint | ||
- prealloc | ||
- predeclared | ||
- promlinter | ||
- reassign | ||
- revive | ||
- rowserrcheck | ||
- sloglint | ||
- spancheck | ||
- sqlclosecheck | ||
- staticcheck | ||
- stylecheck | ||
- tagliatelle | ||
- tenv | ||
- testableexamples | ||
- testifylint | ||
- thelper | ||
- tparallel | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- usestdlibvars | ||
- varnamelen | ||
- wastedassign | ||
- wrapcheck | ||
- wsl | ||
- zerologlint | ||
# https://peter.bourgon.org/blog/2017/06/09/theory-of-modern-go.html | ||
- gochecknoglobals | ||
- gochecknoinits | ||
# use make lint-fix | ||
- gofmt | ||
- gofumpt | ||
- goimports | ||
- misspell | ||
- protogetter | ||
- whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
SHELL := bash | ||
.ONESHELL: | ||
.SHELLFLAGS := -eu -o pipefail -c | ||
MAKEFLAGS += --warn-undefined-variables | ||
|
||
GOLANGCI_LINT_VERSION=$(shell cat .golangci.version) | ||
GOLANGCI_LINT_INSTALL_DIR=$(shell go env GOPATH)/bin | ||
|
||
.PHONY: install-pre-commit-hook | ||
install-pre-commit-hook: | ||
rm -f .git/hooks/pre-commit | ||
cp scripts/pre-commit.sh .git/hooks/pre-commit | ||
chmod +x .git/hooks/pre-commit | ||
|
||
.PHONY: install-lint | ||
install-lint: | ||
VERSION=$(GOLANGCI_LINT_VERSION) INSTALL_DIR=$(GOLANGCI_LINT_INSTALL_DIR) scripts/install-lint.sh | ||
|
||
.PHONY: lint | ||
lint: | ||
$(GOLANGCI_LINT_INSTALL_DIR)/golangci-lint run | ||
|
||
.PHONY: lint-fix | ||
lint-fix: | ||
$(GOLANGCI_LINT_INSTALL_DIR)/golangci-lint run --fix | ||
|
||
.PHONY: shellcheck | ||
shellcheck: | ||
scripts/shellcheck.sh | ||
|
||
.PHONY: ci | ||
ci: lint shellcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fmt.Println("Hello world!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/anttiharju/golangci-lint-updater | ||
|
||
go 1.22.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
mkdir -p "$INSTALL_DIR" | ||
cd "$INSTALL_DIR" || exit | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b . "$VERSION" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
# | ||
# To not be surprised by CI failures. | ||
|
||
make ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
find . -iname "*.sh" -exec shellcheck {} + |