feat: add resource collector for Forgejo runners
Add Go application that collects CPU and RAM metrics from /proc filesystem: - Parse /proc/[pid]/stat for CPU usage (user/system time) - Parse /proc/[pid]/status for memory usage (RSS, VmSize, etc.) - Aggregate metrics across all processes - Output via structured logging (JSON/text) - Continuous collection with configurable interval Designed for monitoring pipeline runner resource utilization to enable dynamic runner sizing.
This commit is contained in:
commit
219d26959f
14 changed files with 1252 additions and 0 deletions
54
scripts/hooks/commit-msg
Normal file
54
scripts/hooks/commit-msg
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash
|
||||
# ABOUTME: Commit-msg hook that validates commit messages follow conventional commit format.
|
||||
# ABOUTME: Install with `make install-hooks`.
|
||||
|
||||
set -e
|
||||
|
||||
COMMIT_MSG_FILE="$1"
|
||||
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
|
||||
|
||||
# Pattern for conventional commits: type(scope)?: message
|
||||
# Types: feat, fix, chore, docs, style, refactor, perf, test, build, ci
|
||||
PATTERN='^(feat|fix|chore|docs|style|refactor|perf|test|build|ci)(\([[:alnum:]_-]+\))?!?:.+$'
|
||||
|
||||
# Get the first line (subject) of the commit message
|
||||
FIRST_LINE=$(echo "$COMMIT_MSG" | head -n 1)
|
||||
|
||||
# Skip validation for merge commits
|
||||
if echo "$FIRST_LINE" | grep -qE '^Merge '; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Skip validation for revert commits
|
||||
if echo "$FIRST_LINE" | grep -qE '^Revert '; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! echo "$FIRST_LINE" | grep -qE "$PATTERN"; then
|
||||
echo "Error: Invalid commit message format."
|
||||
echo ""
|
||||
echo "Commit message: '$FIRST_LINE'"
|
||||
echo ""
|
||||
echo "Expected format: <type>(<scope>)?: <description>"
|
||||
echo ""
|
||||
echo "Valid types:"
|
||||
echo " feat - A new feature"
|
||||
echo " fix - A bug fix"
|
||||
echo " chore - Maintenance tasks"
|
||||
echo " docs - Documentation changes"
|
||||
echo " style - Code style changes (formatting, etc.)"
|
||||
echo " refactor - Code refactoring"
|
||||
echo " perf - Performance improvements"
|
||||
echo " test - Adding or updating tests"
|
||||
echo " build - Build system changes"
|
||||
echo " ci - CI configuration changes"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " feat: add user authentication"
|
||||
echo " fix(auth): resolve token expiration issue"
|
||||
echo " chore(deps): update dependencies"
|
||||
echo " feat!: breaking change in API"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Commit message format valid."
|
||||
28
scripts/hooks/pre-commit
Executable file
28
scripts/hooks/pre-commit
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
# ABOUTME: Pre-commit hook that runs formatting and linting checks.
|
||||
# ABOUTME: Install with `make install-hooks`.
|
||||
|
||||
set -e
|
||||
|
||||
echo "Running pre-commit checks..."
|
||||
|
||||
# Run go fmt and check if there are any changes
|
||||
echo "Checking formatting..."
|
||||
UNFORMATTED=$(gofmt -l .)
|
||||
if [ -n "$UNFORMATTED" ]; then
|
||||
echo "Error: The following files are not formatted:"
|
||||
echo "$UNFORMATTED"
|
||||
echo ""
|
||||
echo "Run 'make fmt' to format them."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run linter
|
||||
echo "Running linter..."
|
||||
make lint
|
||||
|
||||
# Check for secrets with gitleaks
|
||||
echo "Checking for secrets..."
|
||||
make gitleaks
|
||||
|
||||
echo "Pre-commit checks passed!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue