Hex.pm Hex Docs Hex.pm Downloads CI

A parallel code quality checker for Elixir projects. Runs format, compile, credo, dialyzer, and tests concurrently with smart test partitioning.

Features

  • Parallel Execution - all checks run concurrently to maximize CPU utilization
  • Test Partitioning - splits test suite across multiple partitions
  • Coverage Merging - combines partition coverage into a single report with caching
  • Modified Tests - run only tests changed on your branch (granular line-level or whole modules)
  • Failed Test Rerun - re-run only previously failed tests
  • Auto-fix - configurable fix commands for format and credo issues
  • Real-time Progress - animated status lines with test counts and spinner
  • Configurable - .check.json for all settings, builtin: checks for Elixir-powered logic

Installation

Add al_check to your list of dependencies in mix.exs:

def deps do
  [
    {:al_check, "~> 0.1.0"}
  ]
end

Then install globally:

mix deps.get
mix check.install
# if you use asdf
asdf reshim

Usage

check                                # Run default checks
check -v                             # Show version
check --init                         # Create .check.json with defaults
check --help                         # Show help
check --fast                         # Run only fast checks (format, compile, credo)
check --only format,test             # Run specific checks
check --only modified_tests          # Run only modified/new tests vs base branch
check --only modified_test_modules   # Run whole test files modified on branch
check --partitions 4                 # Run tests with 4 partitions
check --dir test/foo,test/bar        # Run tests from specific directories
check --failed                       # Re-run only failed tests from previous run
check --fix                          # Apply auto-fixes
check --watch                        # Monitor test partition files in real-time
check --coverage                     # Show coverage report (cached if unchanged)
check --verbose                      # Print test output directly
check --test-args --exclude slow     # Pass custom args to mix test
check --repeat 10                    # Run tests with --repeat-until-failure

Available Checks

CheckCommand
formatmix format --check-formatted
compilemix compile --warnings-as-errors
compile_testMIX_ENV=test mix compile --warnings-as-errors
dialyzermix dialyzer
credomix credo --all
credo_strictmix credo --strict --only readability --all
testmix test (with parallel partitioning)
modified_testsRuns only changed test lines vs base branch (builtin)
modified_test_modulesRuns whole modified test files vs base branch (builtin)

Workflows

Failed Test Workflow

check --only test     # Run tests, failures saved automatically
check --failed        # Re-run only the failed tests

Auto-fix Workflow

check --only format,credo  # Run checks and store output
check --fix                # Apply fixes from stored output

Modified Tests Workflow

check --only modified_tests           # Run only changed test lines
check --only modified_test_modules    # Run whole changed test files
check --only modified_tests --repeat 5  # Repeat modified tests

modified_tests detects:

  • Setup/describe changed -> runs the whole file
  • Test body changed -> runs only that specific test line
  • Module-level change -> runs the whole file

Coverage Workflow

check --coverage    # Show coverage report (cached if cover/ unchanged)

Configuration

Create a .check.json in your project root (check --init generates one with defaults):

{
  "run": ["format", "compile", "compile_test", "dialyzer", "credo", "credo_strict", "test"],
  "fast": ["format", "compile", "compile_test", "credo", "credo_strict"],
  "partitions": 3,
  "max_concurrency": 10,
  "test_args": "--warnings-as-errors",
  "default_repeat": 100,
  "base_branch": "main",
  "coverage": {
    "mod": "native",
    "limit": 80,
    "html": false,
    "baseline_cmd": "git show origin/main:coverage.txt"
  },
  "fix": [
    {"run": "mix format"},
    {"run": "mix recode", "on_credo_files": true}
  ],
  "checks": {
    "format": {"name": "Formatting", "run": "mix format --check-formatted"},
    "compile": {"name": "Compile", "run": "mix compile --warnings-as-errors"},
    "credo": {"name": "Credo", "run": "mix credo --all"},
    "modified_tests": {"name": "Modified Tests", "run": "builtin:modified_tests"},
    "modified_test_modules": {"name": "Modified Test Modules", "run": "builtin:modified_test_modules"}
  }
}

All fields are optional. CLI flags override config values.

Key config options

KeyDescription
runChecks to run by default (without --only or --fast)
fastChecks to run with --fast
base_branchGit branch for modified test detection (auto-detects main/master if not set)
checksCustom check definitions (replaces built-in checks, test partitions always added)
fixCommands to run with --fix

Custom checks

Each check has a run string (shell command) and optional name:

"sobelow": {"name": "Security", "run": "mix sobelow --config"}

Use builtin: prefix for Elixir-powered checks:

"modified_tests": {"run": "builtin:modified_tests"}

Use {base_branch} placeholder in shell commands — replaced at runtime:

"my_check": {"run": "git diff {base_branch}... --stat"}

Coverage

"coverage": {
  "mod": "native",
  "limit": 80,
  "html": false,
  "baseline_cmd": "git show origin/main:coverage.txt"
}
KeyDescription
mod"native" (built-in --cover) or "coveralls" (excoveralls)
limitMinimum coverage %. Fails if below
htmlGenerate full HTML report (default: false, kills early after getting %)
baseline_cmdShell command returning baseline coverage % for delta comparison

Fix commands

"fix": [
  {"run": "mix format"},
  {"run": "mix recode", "on_credo_files": true}
]

on_credo_files: true runs the command only on files that had credo issues in the previous run.

Output Files

AlCheck creates a .check/ directory:

FileDescription
.check/credo.txtCredo output for auto-fix
.check/credo_strict.txtStrict credo output for auto-fix
.check/check_tests.txtMerged test output from all partitions
.check/test_partition_N.txtIndividual partition outputs
.check/failed_tests.txtFailed test locations
.check/coverage_cache.*Cached coverage results
.check/test_args.txtSaved test args for --failed

Requirements

  • Elixir ~> 1.18
  • Mix build tool

Documentation

Full documentation is available at https://hexdocs.pm/al_check.

License

This project is licensed under the MIT License - see the LICENSE file for details.