Skip to content

Commit

Permalink
feat: Update to major version v3
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Nützi <[email protected]>
  • Loading branch information
gabyx committed Apr 22, 2024
2 parents d594235 + 8131edd commit 1288121
Show file tree
Hide file tree
Showing 273 changed files with 4,705 additions and 2,643 deletions.
13 changes: 10 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ jobs:
description: "The test script name"
default: "test-alpine"
type: string
seq:
description: "The sequence of tests"
default: ""
type: string
executor:
size: medium
name: win/server-2022
version: 2023.04.1
version: 2023.11.1
steps:
- checkout
- run:
command: "& 'C:/Program Files/Git/bin/sh.exe' tests/<<parameters.test>>.sh"
no_output_timeout: 30m
command: "& 'C:/Program Files/Git/bin/bash.exe' -c 'tests/<<parameters.test>>.sh --seq <<parameters.seq>>'"

workflows:
version: 2
Expand All @@ -43,7 +49,7 @@ workflows:
"test-alpine",
"test-alpine-nolfs",
"test-alpine-user",
"test-corehookspath",
"test-centralized",
"test-whitespace",
"test-unittests",
"test-unittests-podman",
Expand All @@ -69,4 +75,5 @@ workflows:
matrix:
parameters:
test: ["test-windows"]
seq: ["{001..040}", "{041..080}", "{081..120}", "{120..200}"]
filters: *filters
14 changes: 7 additions & 7 deletions .githooks/pre-commit/.export-staged
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env bash

assertStaged() {
# Export if run without githooks...
if [ -z "${STAGED_FILES:-}" ]; then
CHANGED_FILES=$(git diff --cached --diff-filter=ACMR --name-only)
# Export if run without githooks...
if [ -z "${STAGED_FILES:-}" ]; then
CHANGED_FILES=$(git diff --cached --diff-filter=ACMR --name-only)

# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
STAGED_FILES="$CHANGED_FILES"
fi
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then
STAGED_FILES="$CHANGED_FILES"
fi
fi
}
2 changes: 0 additions & 2 deletions .githooks/pre-commit/cli-docs-up-to-date
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ for file in $STAGED_FILES; do
exit 1
}

git add "$repoDir/docs/cli/"*

echo "* Docs regenerated." >&2
else
echo "! You need to regenerate the CLI docs (its too old)!" >&2
Expand Down
20 changes: 10 additions & 10 deletions .githooks/pre-commit/gofmt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ set -e
set -u

if ! command -v gofmt >/dev/null 2>&1; then
echo "! Skipping gofmt - not installed" >&2
exit 0
echo "! Skipping gofmt - not installed" >&2
exit 0
fi

SUCCESS=0

for PKG_DIR in githooks/*; do
if ! [ -d "$PKG_DIR" ] || echo "$PKG_DIR" | grep -q "vendor"; then
continue
fi
if ! [ -d "$PKG_DIR" ] || echo "$PKG_DIR" | grep -q "vendor"; then
continue
fi

if ! gofmt -l "$PKG_DIR"; then
SUCCESS=1
fi
if ! gofmt -l "$PKG_DIR"; then
SUCCESS=1
fi
done

if [ "$SUCCESS" = "0" ]; then
echo "* gofmt is OK." >&2
echo "* gofmt is OK." >&2
else
exit "$SUCCESS"
exit "$SUCCESS"
fi
18 changes: 11 additions & 7 deletions .githooks/pre-commit/golint
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ set -e
set -u

if ! command -v golangci-lint >/dev/null 2>&1; then
echo "! golangci-lint - not installed" >&2
exit 1
echo "! golangci-lint - not installed" >&2
exit 1
fi

cd githooks || exit 1

if CGO_ENABLED=0 golangci-lint run -E godot \
if
CGO_ENABLED=0 golangci-lint run \
--exclude-dirs /usr/local/go \
-E godot \
-E gomnd \
-E goconst \
-E gochecknoinits \
Expand All @@ -18,9 +21,10 @@ if CGO_ENABLED=0 golangci-lint run -E godot \
-E lll \
-E exportloopref \
-E gocritic \
--max-same-issues 0 ./...; then
echo "* golangci-lint OK" >&2
--max-same-issues 0 ./...
then
echo "* golangci-lint OK" >&2
else
echo "! golangci-lint problems detected" >&2
exit 1
echo "! golangci-lint problems detected" >&2
exit 1
fi
22 changes: 11 additions & 11 deletions .githooks/pre-commit/no-tabs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ assertStaged
success=0

checkTab() {
local lines
lines=$(grep -rnH "$(printf '\t')" "$1") || true
local lines
lines=$(grep -rnH "$(printf '\t')" "$1") || true

if [ -n "$lines" ]; then
echo "! Tab character found in: $lines" >&2
success=1
fi
if [ -n "$lines" ]; then
echo "! Tab character found in: $lines" >&2
success=1
fi
}

for file in $STAGED_FILES; do
if echo "$file" | grep -qvE "(githooks|docs)/.*$"; then
checkTab "$file"
fi
if echo "$file" | grep -qvE "(githooks|docs)/.*$"; then
checkTab "$file"
fi
done

if [ "$success" = "0" ]; then
echo "* No tab characters detected" >&2
echo "* No tab characters detected" >&2
else
exit "$success"
exit "$success"
fi
22 changes: 11 additions & 11 deletions .githooks/pre-commit/no-todo-or-fixme
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ assertStaged
success=0

checkTodo() {
local lines
lines=$(grep -rnHE "(TODO|FIXME)" "$1") || true
local lines
lines=$(grep -rnHE "(TODO|FIXME)" "$1") || true

if [ -n "$lines" ]; then
echo "! TODO or FIXME found in: $lines" >&2
success=1
fi
if [ -n "$lines" ]; then
echo "! TODO or FIXME found in: $lines" >&2
success=1
fi
}

for file in $STAGED_FILES; do
if echo "$file" | grep -qvE '(cover/|pre-commit/no-todo-or-fixme|\.md|\.devcontainer/\.p10k)'; then
checkTodo "$file"
fi
if echo "$file" | grep -qvE '(cover/|pre-commit/no-todo-or-fixme|\.md|\.devcontainer/\.p10k)'; then
checkTodo "$file"
fi
done

if [ "$success" = "0" ]; then
echo "* No TODO or FIXME detected" >&2
echo "* No TODO or FIXME detected" >&2
else
exit "$success"
exit "$success"
fi
51 changes: 26 additions & 25 deletions .githooks/pre-commit/update-templates
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,47 @@ set -e
set -u

if command -v gsed &>/dev/null; then
SED="gsed"
SED="gsed"
else
SED="sed"
SED="sed"
fi

if ! $SED --version 2>&1 | grep -q "GNU"; then
echo "! Install GNU sed for updating the templates." >&2
exit 1
echo "! Install GNU sed for updating the templates." >&2
exit 1
fi

# Patch the hooks
# shellcheck disable=SC2016
hook_names=$($SED -E '1,/ManagedHookNames.*\{/d;/\}/,$d ; s/\s+"(.*)",/\1/' githooks/hooks/githooks.go) ||
{
echo "update-templates:: Replacement command failed!" >&2
exit 1
}
{
echo "update-templates:: Replacement command failed!" >&2
exit 1
}

for hook_name in $hook_names; do
# shellcheck disable=SC2015
$SED -e "s|GITHOOKS_RUNNER=.*|GITHOOKS_RUNNER=\"\$(cd \"\$(dirname \"\$0\")/../\" \&\& pwd)/githooks/bin/runner\"|" \
-e "s|\(various Git triggers.*\)|\1\n#\n# This file is auto-generated, do not edit!|" \
<githooks/build/embedded/run-wrapper.sh >"hooks/$hook_name" &&
chmod u+x "hooks/$hook_name" &&
git add hooks/* ||
{
echo "Failed to update \`hooks/$hook_name\`" >&2
exit 2
}
# shellcheck disable=SC2015
$SED -e "s|GITHOOKS_RUNNER=.*|GITHOOKS_RUNNER=\"\$(cd \"\$(dirname \"\$0\")/../\" \&\& pwd)/githooks/bin/githooks-runner\"|" \
-e "/echo \" .*/d" \
-e "s|echo \"! .*|echo \"! The runner '\$GITHOOKS_RUNNER' is not existing\" \>\&2\n|g" \
-e "s|\(various Git triggers.*\)|\1\n#\n# This file is auto-generated, do not edit!|" \
<githooks/build/embedded/run-wrapper.sh >"hooks/$hook_name" &&
chmod u+x "hooks/$hook_name" ||
{
echo "Failed to update 'hooks/$hook_name'" >&2
exit 2
}
done

# Delete all files not in `$hook_name`
for hook_file in hooks/*; do
name=$(basename "$hook_file")
if ! echo "$hook_names" | grep -q "$name"; then
git rm "$hook_file" >/dev/null 2>&1 || {
echo "Failed to delete obsolete hook \`$hook_file\`" >&2
exit 3
}
fi
name=$(basename "$hook_file")
if ! echo "$hook_names" | grep -q "$name"; then
git rm "$hook_file" >/dev/null 2>&1 || {
echo "Failed to delete obsolete hook \`$hook_file\`" >&2
exit 3
}
fi
done

echo "* Updated all hooks in 'hooks/*'" >&2
Expand Down
Loading

0 comments on commit 1288121

Please sign in to comment.