From 2f1b55cd70bfa52d33e211c9eee2b069e92a4d4b Mon Sep 17 00:00:00 2001 From: Miroslav Shubernetskiy Date: Thu, 5 Oct 2023 22:40:27 -0400 Subject: [PATCH] test(lint): adding pre-commit hook for checking chalk version across files (#41) this will check chalk version matches across various files. currently we only check: * nimble file * base_keyspecs.c4m If the chalk version is updated in nimble file, all other files need to match it. --- .github/check_version.sh | 22 ++++++++++++++++++++++ .pre-commit-config.yaml | 10 ++++++++++ 2 files changed, 32 insertions(+) create mode 100755 .github/check_version.sh diff --git a/.github/check_version.sh b/.github/check_version.sh new file mode 100755 index 00000000..e6be909f --- /dev/null +++ b/.github/check_version.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -eEu +set -o pipefail + +FILEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$FILEDIR" 1> /dev/null 2>&1 + +# cd to root of the repo +cd .. + +KEYSPEC=src/configs/base_keyspecs.c4m +current_version=$(make version) +keyspec_version=$( + grep -E "chalk_version\s:=" $KEYSPEC \ + | cut -d'"' -f2 +) + +if [ "$current_version" != "$keyspec_version" ]; then + echo $KEYSPEC chalk_version does not match nimble chalk version + echo "$keyspec_version != $current_version" + exit 1 +fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67a2feab..f498244f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,6 +32,16 @@ repos: data/.* )$ + - repo: local + hooks: + - id: chalkversion + name: chalkversion + description: verify chalk version matches across all chalk files + entry: ./.github/check_version.sh + language: system + always_run: true + pass_filenames: false + - repo: https://github.com/tcort/markdown-link-check rev: v3.11.2 hooks: