Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
run:
timeout: 5m
modules-download-mode: readonly

linters:
disable:
- errcheck
Expand Down
8 changes: 7 additions & 1 deletion doc/coding-ghost.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Getting started with gh-ost development is simple!

- First obtain the repository with `git clone` or `go get`.
- From inside of the repository run `script/cibuild`
- From inside of the repository run `script/cibuild`.
- This will bootstrap the environment if needed, format the code, build the code, and then run the unit test.

## CI build workflow
Expand All @@ -14,6 +14,12 @@ Getting started with gh-ost development is simple!

If additional steps are needed, please add them into this workflow so that the workflow remains simple.

## `golang-ci` linter

To enfore best-practices, Pull Requests are automatically linted by [`golang-ci`](https://golangci-lint.run/). The linter config is located at [`.golangci.yml`](https://github.com/github/gh-ost/blob/master/.golangci.yml) and the `golangci-lint` GitHub Action is located at [`.github/workflows/golangci-lint.yml`](https://github.com/github/gh-ost/blob/master/.github/workflows/golangci-lint.yml).

To run the `golang-ci` linters locally _(recommended before push)_, use `script/lint`.

## Notes:

Currently, `script/ensure-go-installed` will install `go` for Mac OS X and Linux. We welcome PR's to add other platforms.
17 changes: 17 additions & 0 deletions script/ensure-golangci-lint-installed
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# See https://github.com/golangci/golangci-lint/releases
GOLANGCI_RELEASE=v1.46.2
GOLANGCI_INSTALL_SCRIPT=https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh

if [ -z "$GOPATH" ]; then
echo "GOPATH must be set"
exit 1
fi

if [ ! -x "$GOPATH/bin/golangci-lint" ]; then
echo "Installing golangci-lint $GOLANGCI_RELEASE using script: $GOLANGCI_INSTALL_SCRIPT"
curl -sSfL $GOLANGCI_INSTALL_SCRIPT | sh -s -- -b $(go env GOPATH)/bin $GOLANGCI_RELEASE
fi

$GOPATH/bin/golangci-lint --version
15 changes: 15 additions & 0 deletions script/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

. script/ensure-go-installed
. script/ensure-golangci-lint-installed

if [ -x "$GOPATH/bin/golangci-lint" ]; then
echo "Running golangci-lint run"
$GOPATH/bin/golangci-lint run --config=.golangci.yml
echo "Done, exit code: $?"
else
echo "ERROR: cannot find golangci-lint at $GOPATH/bin"
exit 1
fi