Skip to content

Commit

Permalink
feature(pre-commit): add precommit and commitlint
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Malusev <[email protected]>
  • Loading branch information
CodeLieutenant committed Nov 17, 2024
1 parent 9b15797 commit c606262
Show file tree
Hide file tree
Showing 17 changed files with 587 additions and 196 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
workflow_call:
inputs:
version:
default: ""
required: true
default: "dev"
required: false
type: string
workflow_dispatch:
inputs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.23.3'

# Needed for ARM64 Docker builds
- name: Set up QEMU
Expand All @@ -42,7 +42,7 @@ jobs:
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "v2.3.1"
version: "v2.4.5"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cmd/gemini/dist/
/gemini
.idea
.vscode
bin/
coverage.txt
dist/
24 changes: 11 additions & 13 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
version: 2

env:
- GO111MODULE=on
# ARM crypto extension for RANDOM Number generation
- GOARM64=v8.0,crypto
- CFLAGS="-O3"
- CXXFLAGS="-O3"

before:
hooks:
- go mod download
report_sizes: true

builds:
- env:
- CGO_ENABLED=0
- id: gemini
goos:
- linux
ldflags: -s -w
binary: gemini
no_unique_dist_dir: false
env:
- CGO_ENABLED=0
- CFLAGS="-O3"
- CXXFLAGS="-O3"
goarch:
- amd64
- arm64
main: ./cmd/gemini
goamd64:
- v3 # v3 Enables AMD64 SIMD (SSE4.x,AVX2) optimizations
goarm64:
- v8.3 # ARM crypto extension for RANDOM Number generation

archives:
- name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
Expand Down Expand Up @@ -86,3 +83,4 @@ release:
make_latest: true
prerelease: auto
skip_upload: false
include_meta: true
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.9.0-1
hooks:
- id: shfmt
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: go-build-repo-mod
- id: go-mod-tidy-repo
- id: go-vet-repo-mod
- id: go-sec-repo-mod
- id: go-fumpt-repo
- id: golangci-lint-repo-mod
args: ['--fix']
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.18.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-conventional']
25 changes: 25 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"recommendations": [
"ms-vscode-remote.remote-containers",
"ms-azuretools.vscode-docker",
"p1c2u.docker-compose",
"usernamehw.errorlens",
"github.vscode-github-actions",
"eamodio.gitlens",
"golang.go",
"mongodb.mongodb-vscode",
"christian-kohler.path-intellisense",
"foxundermoon.shell-format",
"timonwong.shellcheck",
"JordanHury.sqltools-cassandra",
"wayou.vscode-todo-highlight",
"tooltitudeteam.tooltitude",
"pflannery.vscode-versionlens",
"redhat.vscode-yaml",
"ms-vscode.test-adapter-converter",
"GitHub.vscode-pull-request-github",
"ms-vscode.remote-repositories",
"ms-vsliveshare.vsliveshare",
"aaron-bond.better-comments",
],
}
59 changes: 59 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Gemini",
"type": "go",
"buildFlags": [
"-gcflags=all=\"-N -l\""
],
"request": "launch",
"mode": "exec",
"program": "${workspaceFolder}/bin/gemini",
"cwd": "${workspaceFolder}/bin",
"backend": "lldb",
"apiVersion": 2,
"args": [
"--consistency=LOCAL_QUORUM",
"--test-host-selection-policy=token-aware",
"--oracle-host-selection-policy=token-aware",
"--test-cluster=192.168.100.3",
"--oracle-cluster=192.168.100.2",
"--dataset-size=large",
"--seed=60",
"--schema-seed=60",
"--cql-features=all",
"--duration=5m",
"--warmup=10s",
"--drop-schema=true",
"--fail-fast",
"--level=info",
"--materialized-views=true",
"--outfile=${workspaceFolder}/results/gemini_result.log",
"--mode=mixed",
"--non-interactive",
"--request-timeout=180s",
"--connect-timeout=120s",
"--consistency=LOCAL_QUORUM",
"--use-server-timestamps=false",
"--async-objects-stabilization-attempts=10",
"--async-objects-stabilization-backoff=1000ms",
"--replication-strategy=\"{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}\"",
"--oracle-replication-strategy=\"{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}\"",
"--max-mutation-retries=5",
"--max-mutation-retries-backoff=1000ms",
"--concurrency=4",
"--tracing-outfile=${workspaceFolder}/results/gemini_tracing.log",
],
"logOutput": "debugger",
"suppressMultipleSessionWarning": true,
"coreFilePath": "${workspaceFolder}",
"output": "${workspaceFolder}/bin/gemini",
"showLog": true,
"showGlobalVariables": true,
"showRegisters": true,
"hideSystemGoroutines": true,
"internalConsoleOptions": "openOnFirstSessionStart",
},
]
}
195 changes: 195 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"editor.formatOnSave": true,
"editor.quickSuggestions": {
"comments": true,
"strings": true,
"other": true
},
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"[dockerfile]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
},
"git.allowForcePush": true,
"git.alwaysSignOff": true,
"git.autofetch": true,
"git.ignoreLimitWarning": true,
"github.gitProtocol": "ssh",
"makefile.configureOnOpen": false,
"go.diagnostic.vulncheck": "Imports",
"go.disableConcurrentTests": false,
"go.coverOnSave": true,
"go.coverOnSingleTest": true,
"go.coverOnSingleTestFile": true,
"go.inlayHints.compositeLiteralTypes": false,
"go.inlayHints.parameterNames": true,
"go.useLanguageServer": true,
"go.inferGopath": true,
"go.vetOnSave": "workspace",
"go.coverMode": "default",
"go.addTags": {
"tags": "json,bson,yaml",
"promptForTags": true
},
"go.coverageDecorator": {
"type": "gutter",
"coveredHighlightColor": "rgba(64,128,128,0.5)",
"uncoveredHighlightColor": "rgba(128,64,64,0.25)",
"coveredGutterStyle": "blockgreen",
"uncoveredGutterStyle": "blockred"
},
"go.formatTool": "gofumpt",
"go.coverShowCounts": true,
"go.enableCodeLens": {
"runtest": true,
},
"gopls": {
"ui.codelenses": {
"gc_details": true,
"upgrade_dependency": true,
"generate": true,
"regenerate_cgo": true,
"test": true,
"tidy": true,
"run_govulncheck": true,
"vendor": true
},
"ui.diagnostic.analyses": {
"asmdecl": true,
"nilness": true,
"assign": true,
"atomic": true,
"atomicalign": true,
"bools": true,
"buildtags": true,
"cgocall": true,
"composites": true,
"copylocks": true,
"buildtag": true,
"errorsas": true,
"fieldalignment": true,
"deepequalerrors": true,
"fillreturns": true,
"fillstruct": true,
"nilfunc": true,
"ifaceassert": true,
"httpresponse": true,
"infertypeargs": true,
"lostcancel": true,
"loopclosure": true,
"printf": true,
"simplifycompositelit": true,
"stdmethods": true,
"shadow": true,
"structtag": true,
"timeformat": true,
"unmarshal": true,
"unreachable": true,
"unusedwrite": true,
"unusedvariable": true,
"unsafeptr": true,
"unusedresult": true,
"embed": true,
"nonewvars": true,
"noresultvalues": true,
"shift": true,
"simplifyrange": true,
"simplifyslice": true,
"sortslice": true,
"stringintconv": true,
"stubmethods": true,
"testinggoroutine": true,
"tests": true,
"undeclaredname": true,
"unusedparams": false
},
"ui.semanticTokens": true,
"ui.completion.experimentalPostfixCompletions": true,
"ui.completion.usePlaceholders": false,
"ui.completion.matcher": "Fuzzy",
"ui.diagnostic.staticcheck": true,
"ui.diagnostic.annotations": {
"bounds": true,
"escape": true,
"inline": true,
"nil": true
},
"ui.navigation.importShortcut": "Both",
"ui.noSemanticNumber": true,
"ui.navigation.symbolStyle": "Full",
"ui.noSemanticString": true,
"ui.documentation.linksInHover": false,
"ui.navigation.symbolMatcher": "FastFuzzy",
"ui.documentation.hoverKind": "FullDocumentation",
"ui.documentation.linkTarget": "pkg.go.dev",
"ui.completion.completionBudget": "500ms",
"ui.navigation.symbolScope": "all",
"ui.diagnostic.diagnosticsDelay": "600ms",
"gofumpt": true,
},
"go.lintTool": "golangci-lint",
"go.lintFlags": [
"--verbose"
],
"go.toolsManagement.autoUpdate": true,
"go.coverageOptions": "showCoveredCodeOnly",
"go.inlayHints.compositeLiteralFields": true,
"go.lintOnSave": "workspace",
"go.inlayHints.constantValues": true,
"go.inlayHints.assignVariableTypes": true,
"go.coverOnTestPackage": true,
"go.toolsManagement.go": "1.23",
"go.generateTestsFlags": [
"-v"
],
"go.delveConfig": {
"apiVersion": 2,
"debugAdapter": "dlv-dap",
"showLog": true,
"hideSystemGoroutines": true,
"showGlobalVariables": true,
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 256,
"maxArrayValues": 256,
"maxStructFields": -1,
},
"dlvFlags": [
"--accept-multiclient",
"--listen=0.0.0.0:2345",
"--allow-non-terminal-interactive"
],
"logOutput": "debugger",
"showRegisters": true
},
"go.editorContextMenuCommands": {
"removeTags": true,
"fillStruct": true,
"testFile": true,
"testPackage": true,
"generateTestForFile": true,
"generateTestForPackage": true,
"benchmarkAtCursor": true,
"addImport": true,
"addTags": true,
"testCoverage": true,
"generateTestForFunction": true,
},
"go.inlayHints.functionTypeParameters": true,
"go.inlayHints.rangeVariableTypes": true,
"go.installDependenciesWhenBuilding": true,
"go.testExplorer.showOutput": true,
"go.testExplorer.packageDisplayMode": "nested",
"go.testExplorer.showDynamicSubtestsInEditor": true,
"go.terminal.activateEnvironment": true,
"go.testTimeout": "5m",
"go.testExplorer.enable": true,
"go.testExplorer.concatenateMessages": true,
"go.removeTags": {
"tags": "",
"options": "",
"promptForTags": true
},
}
Loading

0 comments on commit c606262

Please sign in to comment.