This document describes the development workflow, pre-commit hooks, and CI/CD pipeline for this repository.
We use pre-commit hooks to ensure code quality and consistency. The hooks are automatically installed when you enter the development shell.
-
Enter the development shell:
nix develop
-
Install pre-commit hooks:
make install-hooks # or manually: pre-commit install
Pre-commit hooks run automatically on git commit. You can also run them manually:
# Run on all files
make run-hooks
# or
pre-commit run --all-files
# Run on staged files only
pre-commit run- Nix formatting:
nixpkgs-fmtfor consistent Nix code formatting - Shell linting:
shellcheckfor shell script quality - Shell formatting:
shfmtfor consistent shell script formatting - Python formatting:
blackfor Python code formatting - Python linting:
flake8for Python code quality - General checks: trailing whitespace, end-of-file, YAML/JSON validation
- Custom checks: Our own
fmt.shandlint.shscripts
All development scripts are available as Nix packages and in the development shell:
cex: Curl and Execute scripts from shared repositoryfmt: Format code files (Go, JS/TS, Python, Shell, Nix)lint: Lint code files (Go, JS/TS, Python, Shell, Nix)tidy: Clean up and organize codeupgrade: Upgrade dependencies and toolsfuzz: Run fuzzing tests
# Enter development shell
nix develop
# List available scripts
cex --list
# Format all code
fmt.sh
# or
make fmt
# Lint all code
lint.sh
# or
make lint
# Run comprehensive checks
make quick # format + lint + flake check
make validate # full validation suiteWe provide a comprehensive Makefile for common development tasks:
make help # Show available targets
make check # Run nix flake check
make build # Build all packages
make fmt # Format all code
make lint # Lint all code
make test # Run all tests
make clean # Clean build artifacts
make install-hooks # Install pre-commit hooks
make update # Update flake inputs
make ci-local # Run CI checks locally
make validate # Run full validation suiteWe have several workflows for comprehensive CI/CD:
Runs on every push and pull request:
- Nix Flake Checks: Validates flake syntax and structure
- Build Scripts: Builds all individual scripts and tests basic functionality
- Test Dev Shells: Validates all development shell environments
- Lint and Format: Ensures code quality and consistency
- Pre-commit Checks: Runs all pre-commit hooks
- Security Checks: Scans for vulnerabilities
- Package Sets: Builds all package combinations
- Final Validation: Comprehensive validation and reporting
- Cachix Integration: Automatically pushes built packages to binary cache
Runs weekly and on-demand:
- Update Flake Inputs: Automatically updates dependencies
- Security Audit: Regular vulnerability scanning
- Lint Scripts: Comprehensive script validation
- Test Package Builds: Ensures all packages build correctly
- Generate Documentation: Auto-generates documentation
- Cachix Push: Pushes updated packages to cache
Runs daily and on main branch pushes:
- Build All Packages: Builds every script and package set
- Build Dev Shells: Ensures all development environments are cached
- Push to Cachix: Uploads all builds to the binary cache for faster access
Runs on every push to main when relevant files change:
- Automatic Pushing: Builds and pushes all packages immediately on changes
- Smart Triggers: Only runs when flake files or scripts are modified
- Validation: Tests that pushed packages are available from cache
- Summary Reports: Provides detailed success summaries
We use Cachix to provide pre-built packages for faster development and CI/CD.
The cache is automatically configured in flake.nix. Users get faster builds automatically:
# These commands will use cached builds when available
nix develop
nix build .#cex
nix shell github:devnw/flakes#fmt- Get an auth token from Cachix
- Set up authentication:
export CACHIX_AUTH_TOKEN=your_token_here
make setup-cachix# Push all packages and scripts (recommended)
make push-cachix
# Push everything including dev shell dependencies (comprehensive)
make push-all-cachix
# Push individual scripts only
make push-scripts-cachix
# Manual push
nix build .#cex | cachix push oss-devnwFor the CI/CD pipeline to push to Cachix, set the CACHIX_AUTH_TOKEN secret in your repository settings.
- Test Dev Shells: Validates all development shell environments
- Lint and Format: Ensures code quality and consistency
- Pre-commit Checks: Runs all pre-commit hooks
- Security Checks: Scans for vulnerabilities
- Package Sets: Builds all package combinations
- Final Validation: Comprehensive validation and reporting
Runs weekly and on-demand:
- Update Flake Inputs: Automatically updates dependencies
- Security Audit: Regular vulnerability scanning
- Lint Scripts: Comprehensive script validation
- Test Package Builds: Ensures all packages build correctly
- Generate Documentation: Auto-generates documentation
Before pushing changes, run local CI checks:
make ci-localThis will run the same checks as the CI pipeline locally.
Multiple specialized development environments are available:
nix develop # Default (full environment)
nix develop .#go # Go development
nix develop .#ansible # Ansible environment
nix develop .#terraform # Terraform environment
nix develop .#nix # Nix development
nix develop .#node # Node.js environment
nix develop .#ui # UI development
nix develop .#zig # Zig developmentEach environment includes:
- Common tools (git, curl, editors, etc.)
- Linting tools (shellcheck, yamllint, etc.)
- Environment-specific tools
- All custom scripts
- Pre-commit hooks catch issues before commit
- CI pipeline validates every change
- Security scanning identifies vulnerabilities
- Dependency updates keep packages current
# Quick development cycle
make quick
# Full validation
make validate
# Test specific functionality
make build-scripts
make test-shells- Fork the repository
- Create a feature branch
- Make changes
- Run
make ci-localto validate - Commit (pre-commit hooks will run)
- Push and create a pull request
The CI pipeline will automatically validate your changes and provide feedback.
If pre-commit hooks fail:
# Check what failed
pre-commit run --all-files
# Fix formatting issues
make fmt
# Fix linting issues
make lint
# Re-run checks
make run-hooksIf builds fail:
# Clean and rebuild
make clean
make build
# Check flake syntax
make check
# Update dependencies
make updateIf development shell has issues:
# Test specific shell
nix develop .#go --command echo "test"
# Rebuild shell
nix develop --refresh
# Check for conflicts
nix flake check