diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index f652580..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,13 +0,0 @@ -[bumpversion] -current_version = 0.11.0 -commit = True -message = chore: bump version to {new_version} -tag = True -tag_name = v{new_version} -tag_message = Version {new_version} - -[bumpversion:file:VERSION] - -[bumpversion:file:README.md] -search = rev: v{current_version} -replace = rev: v{new_version} diff --git a/.bumpversion.toml b/.bumpversion.toml new file mode 100644 index 0000000..8da8341 --- /dev/null +++ b/.bumpversion.toml @@ -0,0 +1,15 @@ +[tool.bumpversion] +current_version = "0.11.0" +commit = true +message = "chore: bump version to {new_version}" +tag = true +tag_name = "v{new_version}" +tag_message = "Version {new_version}" + +[[tool.bumpversion.files]] +filename = "VERSION" + +[[tool.bumpversion.files]] +filename = "README.md" +search = "rev: v{current_version}" +replace = "rev: v{new_version}" diff --git a/.editorconfig b/.editorconfig index 4ffee16..2c47a8b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,17 +8,23 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true -[*.{nomad,hcl,tf,tfvars,tpl}] +[*.{hcl,tf,tfvars}{,.erb}] indent_size = 2 -max_line_length = 80 +max_line_length = 120 -[*.{json,yml,yaml}] +[*.{json,toml,yml,yaml}{,.tpl,.tftpl,.erb}] indent_size = 2 +[{go.mod,*.go}] +indent_style = tab + [*.md] indent_size = 2 -max_line_length = 120 +max_line_length = 100 trim_trailing_whitespace = false +[*.rb{,.erb}] +indent_size = 2 + [Makefile] indent_style = tab diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9001457 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +--- +version: 2 + +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 52b3d95..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -name: Lint - -# yamllint disable-line rule:truthy -on: [push] - -jobs: - pre-commit: - name: pre-commit - runs-on: ubuntu-latest - container: - image: flaudisio/pre-commit:latest - steps: - - uses: actions/checkout@v2 - - name: Install hook dependencies - run: | - SHELLCHECK_VERSION="$( grep '^shellcheck ' .tool-versions | awk '{ print $2 }' )" - wget -q -O - https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION}/shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz \ - | tar -xvJ -f - shellcheck-v${SHELLCHECK_VERSION}/shellcheck - mv -v shellcheck-*/shellcheck /usr/local/bin/shellcheck - chmod -v 755 /usr/local/bin/shellcheck - - name: Check dependencies - run: | - shellcheck --version - pre-commit --version - - name: Run pre-commit - run: | - pre-commit run --all-files --verbose --show-diff-on-failure --color always diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..038b447 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,21 @@ +--- +name: pre-commit + +# yamllint disable-line rule:truthy +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - uses: jdx/mise-action@v2 + - uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files --verbose diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b21d50 --- /dev/null +++ b/.gitignore @@ -0,0 +1,263 @@ +# Created by https://www.toptal.com/developers/gitignore/api/vim,linux,macos,windows,intellij,sublimetext,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=vim,linux,macos,windows,intellij,sublimetext,visualstudiocode + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### SublimeText ### +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json +sftp-config-alt*.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/vim,linux,macos,windows,intellij,sublimetext,visualstudiocode diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d92fdf..0d84ffd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-executables-have-shebangs @@ -15,11 +15,11 @@ repos: - id: trailing-whitespace args: [--markdown-linebreak-ext=md] - repo: https://github.com/adrienverge/yamllint - rev: v1.30.0 + rev: v1.37.1 hooks: - id: yamllint entry: yamllint --strict - repo: https://github.com/gruntwork-io/pre-commit - rev: v0.1.21 + rev: v0.1.30 hooks: - id: shellcheck diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index d7703a9..0000000 --- a/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -shellcheck 0.9.0 diff --git a/.yamllint b/.yamllint.yaml similarity index 82% rename from .yamllint rename to .yamllint.yaml index 13701e0..87160e9 100644 --- a/.yamllint +++ b/.yamllint.yaml @@ -8,9 +8,10 @@ rules: brackets: max-spaces-inside: 1 level: error + comments-indentation: disable empty-lines: max: 1 indentation: spaces: 2 line-length: - max: 180 + max: 140 diff --git a/Makefile b/Makefile deleted file mode 100644 index 7badf9a..0000000 --- a/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -.PHONY: help lint bump-version/major bump-version/minor bump-version/patch - -help: ## Show available commands - @echo "Available commands:" - @echo - @sed -n -E -e 's|^([A-Za-z0-9/_-]+):.+## (.+)|\1@\2|p' $(MAKEFILE_LIST) | column -s '@' -t - -lint: ## Run lint commands - pre-commit run --all-files --verbose --show-diff-on-failure --color always - -bump-version/major: ## Increment the major version (X.y.z) - bump2version major - -bump-version/minor: ## Increment the minor version (x.Y.z) - bump2version minor - -bump-version/patch: ## Increment the patch version (x.y.Z) - bump2version patch diff --git a/README.md b/README.md index 24f4cc6..725acca 100644 --- a/README.md +++ b/README.md @@ -7,49 +7,48 @@ Miscellaneous hooks for [pre-commit](https://pre-commit.com/). - `check-zero-width-spaces` - Forbid files which have one or more zero width spaces (U+200B). - `hadolint` - Run [Hadolint](https://github.com/hadolint/hadolint) on Dockerfiles. - - You may use any Hadolint CLI argument, e.g. [`--config example.yaml`][hadolint-configure], [`--ignore RULE`][hadolint-rules], - `--trusted-registry REGISTRY`, etc. See the [example](#full-example) below. + - You may use any Hadolint CLI argument, e.g. [`--config example.yaml`][https://github.com/hadolint/hadolint#configure], + [`--ignore RULE`][https://github.com/hadolint/hadolint#rules], `--trusted-registry REGISTRY`, etc + See the [example](#full-example) below. -- `nomad-fmt` - Run [`nomad fmt`](https://developer.hashicorp.com/nomad/docs/commands/fmt) on Nomad manifests. +- `nomad-fmt` - Run [`nomad fmt`](https://developer.hashicorp.com/nomad/commands/fmt) on Nomad manifests. -- `packer-validate` - Run [`packer validate`](https://www.packer.io/docs/commands/validate.html) on JSON files. - -[hadolint-configure]: https://github.com/hadolint/hadolint#configure -[hadolint-rules]: https://github.com/hadolint/hadolint#rules +- `packer-validate` - Run [`packer validate`](https://developer.hashicorp.com/packer/docs/commands/validate) + on JSON files. ## How to install 1. Install dependencies: - [pre-commit](https://pre-commit.com/#install) - [Hadolint](https://github.com/hadolint/hadolint/releases) (for `hadolint`) - - [Packer](https://www.packer.io/downloads/) (for `packer-validate`) + - [Nomad](https://developer.hashicorp.com/nomad/install) (for `nomad-fmt`) + - [Packer](https://developer.hashicorp.com/packer/install) (for `packer-validate`) -2. Install the pre-commit hook globally: +1. Install the pre-commit hook globally: - ```console - $ pre-commit init-templatedir -t pre-commit ~/.git-template + ```bash + pre-commit init-templatedir -t pre-commit ~/.git-template ``` -3. Create the `.pre-commit-config.yaml` file: +1. Create the `.pre-commit-config.yaml` file: - ```console - $ cd /path/to/my/repo/ - $ vim .pre-commit-config.yaml + ```bash + cd /path/to/my/repo/ + vim .pre-commit-config.yaml ``` **Tip:** use the example from the next section as a start point. -4. Run: +1. Run: - ```console - $ pre-commit run -a + ```bash + pre-commit run -a ``` ## Full example ```yaml # .pre-commit-config.yaml - repos: - repo: https://github.com/flaudisio/pre-commit-hooks rev: v0.11.0 diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..b6a1f9b --- /dev/null +++ b/mise.toml @@ -0,0 +1,30 @@ +[tools] +"pipx:bump-my-version" = "1" +shellcheck = "0.10" + +[tasks.pre-commit] +description = "Run pre-commit" +run = "pre-commit run --all-files --verbose --show-diff-on-failure --color always" + +[tasks."bump-version:major"] +description = "Increment the major version (X.y.z)" +run = "bump-my-version bump major" +depends_post = ["git-show"] + +[tasks."bump-version:minor"] +description = "Increment the minor version (x.Y.z)" +run = "bump-my-version bump minor" +depends_post = ["git-show"] + +[tasks."bump-version:patch"] +description = "Increment the patch version (x.y.Z)" +run = "bump-my-version bump patch" +depends_post = ["git-show"] + +[tasks.git-show] +hide = true +run = "git show" + +[tasks.git-push] +description = "Push the current branch and related tags" +run = "git push --follow-tags origin HEAD"