Skip to main content

Prerequisites

Before starting, make sure you have installed envcheck.

Your First Environment Check

Let’s create your first environment validation in just a few steps.
1

Navigate to Your Project

Open a terminal and navigate to your project directory:
2

Initialize Configuration

Generate a default .envcheck.yaml configuration file:
You should see:
This creates a .envcheck.yaml file with sensible defaults:
3

Run Your First Check

Execute envcheck to validate your environment:
You’ll see output showing which checks passed and which failed:
4

Fix Any Issues

Address any failing checks. For example, if .env is missing:
Then run envcheck again:
When all checks pass:

Customize Your Configuration

Now let’s customize the configuration for your specific project needs.

Example: Node.js Project

For a typical Node.js web application:

Example: Go Project

For a Go application:

Advanced Usage

Custom Configuration Path

Use a configuration file from a different location:

Verbose Output

Get detailed information about what envcheck is doing:

JSON Output for CI/CD

Export results in JSON format for integration with CI/CD pipelines:
Example JSON output:

Exit Codes

envcheck returns appropriate exit codes for scripting:
  • 0 - All checks passed
  • Non-zero - One or more checks failed
This makes it perfect for pre-commit hooks and CI/CD:

Integration Examples

Git Pre-commit Hook

Add envcheck to your pre-commit hook (.git/hooks/pre-commit):
Make it executable:

GitHub Actions

Integrate envcheck into your CI pipeline:

Docker

Validate the environment inside Docker containers:

Configuration Reference

Tools Section

Validate installed tools and their versions:
Supported semver operators: >=, <=, >, <, =, ^, ~

Environment Variables Section

Check environment variables:

Ports Section

Verify port availability:

Files Section

Validate file and directory existence:

Network Section

Check network connectivity:

Tips and Best Practices

Start Simple

Begin with basic checks (tools and files) and gradually add more validators as your project grows.

Version Control

Always commit .envcheck.yaml to version control so all team members use the same validation rules.

Optional vs Required

Use required: false for optional tools or files that enhance development but aren’t strictly necessary.

Semver Ranges

Use flexible version ranges (e.g., >=18.0.0) rather than exact versions to avoid unnecessary failures.

Common Validation Patterns

Microservices

Each service can have its own configuration:

Monorepo

Use a root configuration for common requirements:

Next Steps

Configuration Guide

Learn about all available configuration options

CLI Commands

Explore all CLI commands and options

CI/CD Integration

Integrate envcheck into your pipelines

Examples

Browse example configurations for different project types