Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
ref impl: Go linting + tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda committed Jan 10, 2022
1 parent 3fba61b commit d0fe4ac
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Go lint and test

on:
push:
branches:
- 'main'
- 'staging'
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.43.0 # version of golangci-lint, not the action
skip-go-installation: true
# rules: https://golangci-lint.run/usage/quick-start/
args: -E asciicheck,goimports
- name: Test
run: go test ./...
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- 'main'
- 'staging'
pull_request:
workflow_dispatch:

Expand Down
27 changes: 27 additions & 0 deletions meta/linting.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Linting

## Markdown

See

- [markdownlint rule reference](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md)
Expand All @@ -11,3 +13,28 @@ Justification for linting rules in [.markdownlint.json](/.markdownlint.json):
- *no-blanks-blockquote*: enable multiple consecutive blockquotes separated by white lines
- *single-title*: enable reusing `<h1>` for content
- *no-emphasis-as-heading*: enable emphasized paragraphs

```shell
yarn # Install dependencies
yarn lint # Run linter
```

## Go

See

- [golangci-lint docs](https://golangci-lint.run/usage/install/#local-installation)
- [golangci-lint github](https://github.com/golangci/golangci-lint)
- [github action github](https://github.com/golangci/golangci-lint-action)

Justification for linting rules:

- *asciicheck*: no symbol names with invisible unicode and such
- *goimports*: group local and external import

```shell
# Install linter globally (should not affect go.mod)
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0
# run linter, add --fix option to fix problems (where supported)
golangci-lint run -E asciicheck,goimports
```

0 comments on commit d0fe4ac

Please sign in to comment.