-
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.
Merge pull request #17 from rise8-us/drew/6
neverl8 #6 - Added linter and pre commits hooks.
- Loading branch information
Showing
21 changed files
with
648 additions
and
318 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,6 @@ | ||
DB_HOST=localhost | ||
DB_PORT=5432 | ||
DB_USER=postgres | ||
DB_PASSWORD=password | ||
DB_NAME=meetings | ||
DB_SSLMODE=disable |
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,41 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- '**' | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.22 | ||
- uses: golangci/golangci-lint-action@v3 | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: lint | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.22 | ||
- run: go test -v ./... | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.22 | ||
- uses: go-semantic-release/action@v1 | ||
with: | ||
hooks: goreleaser | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 @@ | ||
# Binary executable | ||
/build/ | ||
|
||
# Dependency directories | ||
/node_modules/ | ||
|
||
# Environment files | ||
.env | ||
|
||
# OS generated files | ||
.DS_Store # macOS | ||
|
||
# Editor directories and files | ||
.vscode/ | ||
.idea/ | ||
*.swp | ||
*.swo | ||
|
||
# Log files | ||
*.log | ||
|
||
# Coverage directory | ||
/coverage/ | ||
|
||
# Temporary files | ||
*.tmp | ||
*.temp |
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 @@ | ||
[general] | ||
contrib = contrib-title-conventional-commits | ||
|
||
[body-max-line-length] | ||
line-length=120 |
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,162 @@ | ||
linters-settings: | ||
depguard: | ||
rules: | ||
logger: | ||
deny: | ||
# logging is allowed only by logutils.Log, | ||
# logrus is allowed to use only in logutils package. | ||
- pkg: "github.com/sirupsen/logrus" | ||
desc: logging is allowed only by logutils.Log. | ||
- pkg: "github.com/pkg/errors" | ||
desc: Should be replaced by standard lib errors package. | ||
- pkg: "github.com/instana/testify" | ||
desc: It's a fork of github.com/stretchr/testify. | ||
dupl: | ||
threshold: 100 | ||
funlen: | ||
lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner. | ||
statements: 50 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 3 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- whyNoLint | ||
gocyclo: | ||
min-complexity: 15 | ||
gofmt: | ||
rewrite-rules: | ||
- pattern: 'interface{}' | ||
replacement: 'any' | ||
goimports: | ||
local-prefixes: github.com/golangci/golangci-lint | ||
gomnd: | ||
# don't include the "operation" and "assign" | ||
checks: | ||
- argument | ||
- case | ||
- condition | ||
- return | ||
ignored-numbers: | ||
- '0' | ||
- '1' | ||
- '2' | ||
- '3' | ||
ignored-functions: | ||
- strings.SplitN | ||
govet: | ||
settings: | ||
printf: | ||
funcs: | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf | ||
enable: | ||
- nilness | ||
- shadow | ||
errorlint: | ||
asserts: false | ||
lll: | ||
line-length: 140 | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
allow-unused: false # report any unused nolint directives | ||
require-explanation: false # don't require an explanation for nolint directives | ||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped | ||
revive: | ||
rules: | ||
- name: unexported-return | ||
disabled: true | ||
- name: unused-parameter | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- depguard | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- errorlint | ||
- exportloopref | ||
- funlen | ||
- gocheckcompilerdirectives | ||
- gochecknoinits | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- gomnd | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- lll | ||
- misspell | ||
- nakedret | ||
- noctx | ||
- nolintlint | ||
- revive | ||
- staticcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
|
||
# don't enable: | ||
# - asciicheck | ||
# - gochecknoglobals | ||
# - gocognit | ||
# - godot | ||
# - godox | ||
# - goerr113 | ||
# - nestif | ||
# - prealloc | ||
# - testpackage | ||
# - wsl | ||
|
||
issues: | ||
# Excluding configuration per-path, per-linter, per-text and per-source | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- gomnd | ||
|
||
- path: pkg/golinters/errcheck.go | ||
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead" | ||
- path: pkg/commands/run.go | ||
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead" | ||
|
||
- path: pkg/golinters/gofumpt.go | ||
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead." | ||
- path: pkg/golinters/staticcheck_common.go | ||
text: "SA1019: settings.GoVersion is deprecated: use the global `run.go` instead." | ||
- path: pkg/lint/lintersdb/manager.go | ||
text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead." | ||
- path: pkg/golinters/unused.go | ||
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)" | ||
- path: test/(fix|linters)_test.go | ||
text: "string `gocritic.go` has 3 occurrences, make it a constant" | ||
|
||
run: | ||
timeout: 5m | ||
skip-dirs: | ||
- test/testdata_etc # test files | ||
- internal/cache # extracted from Go code | ||
- internal/renameio # extracted from Go code | ||
- internal/robustio # extracted from Go code |
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,17 @@ | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
targets: | ||
- linux_amd64 | ||
- darwin_amd64 | ||
- darwin_arm64 | ||
main: ./ | ||
flags: | ||
- -trimpath | ||
- -buildvcs=false | ||
ldflags: | ||
- -extldflags '-static' | ||
- -s -w | ||
- -X main.version={{.Version}} | ||
- -X main.commitSHA={{.FullCommit}} | ||
- -X main.buildDate={{.Date}} |
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,20 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
- repo: https://github.com/dnephin/pre-commit-golang | ||
rev: v0.5.0 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-imports | ||
- id: no-go-testing | ||
- id: golangci-lint | ||
- id: go-unit-tests | ||
- repo: https://github.com/jorisroovers/gitlint | ||
rev: v0.19.1 | ||
hooks: | ||
- id: gitlint |
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 |
---|---|---|
@@ -1,30 +1,58 @@ | ||
neverl8 | ||
# neverl8 | ||
|
||
This is a simple Go application built with Go-Chi router and GORM ORM, demonstrating basic CRUD operations with PostgreSQL. | ||
**neverl8** is a streamlined Go application utilizing the Go-Chi router, GORM ORM, showcasing calendar operations within a PostgreSQL environment. Designed for simplicity and efficiency, this project will serve as the essential scheduler for Rise8. | ||
|
||
Prerequisites | ||
## Prerequisites | ||
|
||
Before you begin, ensure you have the following installed on your machine: | ||
To get the most out of **neverl8**, please ensure you have the following installed on your system: | ||
|
||
Go programming language (version 1.16 or higher), | ||
PostgreSQL database, | ||
Git | ||
- **Go programming language** (version 1.16 or higher) for the backend logic. | ||
- **PostgreSQL database** for data persistence. | ||
- **Git** for version control and collaboration. | ||
|
||
Installation: | ||
## Installation | ||
|
||
Clone the repository: | ||
Follow these simple steps to get **neverl8** up and running on your machine: | ||
|
||
git clone https://github.com/drewfugate/neverl8.git | ||
1. **Clone the repository** to your local machine: | ||
```bash | ||
git clone https://github.com/rise8-us/neverl8.git | ||
``` | ||
2. **Navigate to the project directory**. | ||
3. **Launch the application**: | ||
```bash | ||
go run main.go | ||
``` | ||
Congratulations! The application should now be accessible at http://localhost:8080. | ||
|
||
Navigate to the project directory: | ||
## Development Setup | ||
|
||
cd src | ||
**neverl8** leverages pre-commit for managing git hooks, aiding in maintaining high code quality and consistency across contributions. | ||
|
||
go run main.go | ||
### Setting Up Pre-commit | ||
|
||
The application should now be running on http://localhost:8080. | ||
To integrate pre-commit into your development workflow: | ||
|
||
Testing | ||
1. **Install pre-commit** on your local machine. Refer to the [official installation guide](https://pre-commit.com/#install) for detailed instructions. | ||
2. **Clone this repository** and navigate to the project root. | ||
3. **Activate pre-commit** by running: | ||
```bash | ||
pre-commit install | ||
``` | ||
|
||
To run unit tests, execute the following command: | ||
go test | ||
With these steps completed, pre-commit hooks will automatically execute on every git commit, enhancing your code quality checks. | ||
|
||
### Using golangci-lint | ||
|
||
**neverl8** also incorporates `golangci-lint` for enforcing Go best practices and code styles. To use `golangci-lint` in your development process: | ||
|
||
1. **Install golangci-lint** on your local machine. You can follow the [official golangci-lint installation instructions](https://golangci-lint.run/usage/install/). | ||
2. Once installed, you can run `golangci-lint run` in the project directory to analyze your code. | ||
|
||
## Testing | ||
|
||
**neverl8** embraces testing as a fundamental part of the development process. To run the unit tests and ensure your setup is correctly configured: | ||
```bash | ||
go test ./... | ||
``` | ||
This command triggers all the unit tests within the project, verifying the integrity and functionality of your code. |
Oops, something went wrong.