Contact Us | Stratusphere FinOps | StratusGrid Home | Blog
This repository contains standardized GitHub workflows and pre-commit configurations used across StratusGrid repositories. It provides a centralized location for maintaining consistent code quality checks, linting rules, and automated workflows.
- Pre-commit Workflows: Automated checks for code quality and consistency
- Terraform Linting: Standardized Terraform code validation
- Code Formatting: Consistent code style enforcement
- Automated Updates: Renovate configuration for dependency management
- Create a
.github/workflows
directory in your repository if it doesn't exist - Add the desired workflow file (e.g.,
pre-commit.yml
) - Reference the workflow from this repository
Example for pre-commit workflow:
name: Pre-Commit
on:
pull_request:
jobs:
build:
uses: StratusGrid/workflow-config/.github/workflows/pre-commit.yml@main
- Copy the following files from the
precommit-config
directory to your repository root:.pre-commit-config.yaml
.tflint.hcl
- Install pre-commit hooks:
pip install pre-commit pre-commit install
For easier usage, you can add this function to your shell configuration (e.g., ~/.bashrc
or ~/.zshrc
):
pre-commit-run() {
# Check if pre-commit is installed
if ! command -v pre-commit &> /dev/null; then
echo "Error: pre-commit is not installed. Please install it first:"
echo "pip install pre-commit"
return 1
fi
local branch=${1:-main}
local base_url="https://raw.githubusercontent.com/StratusGrid/workflow-config/$branch/precommit-config"
local files=(".pre-commit-config.yaml" ".tflint.hcl")
local temp_dir=$(mktemp -d)
echo "Downloading configuration files from branch: $branch"
# Download files
for file in "${files[@]}"; do
if ! curl -s -o "$temp_dir/$file" "$base_url/$file"; then
echo "Error: Failed to download $file"
rm -rf "$temp_dir"
return 1
fi
done
# Run pre-commit
echo "Running pre-commit checks..."
if pre-commit run -a --config "$temp_dir/.pre-commit-config.yaml"; then
echo "Pre-commit checks completed successfully"
else
echo "Pre-commit checks failed"
fi
# Cleanup
rm -rf "$temp_dir" ".pre-commit-trivy-cache"
}
# Optional: Create an alias for the default branch
alias pre-commit-run-main="pre-commit-run main"
Then you can run pre-commit checks in several ways:
# Use default branch (main)
pre-commit-run
# Specify a branch
pre-commit-run develop
# Use the alias for main branch
pre-commit-run-main
The pre-commit configuration includes:
- Terraform formatting and validation
- Linting for various file types
- Security checks
Run pre-commit checks manually:
pre-commit run --all-files
Or let them run automatically on git commit.
.pre-commit-config.yaml
: Defines pre-commit hooks and their configurations.tflint.hcl
: Terraform linter configurationrenovate.json
: Automated dependency update configuration