Skip to content

watany-dev/Raptor

Repository files navigation

Raptor

A lightweight CLI tool for running GitHub Actions workflows locally

Overview

Raptor is a CLI tool for running GitHub Actions workflow files (.github/workflows/*.yml) in your local environment. Test your CI pipelines locally before pushing.

Features

  • Native support for GitHub Actions workflow YAML
  • Job dependencies (needs) with automatic dependency resolution
  • Environment variables support at workflow/job/step levels
  • Dynamic environment variable propagation via GITHUB_ENV / GITHUB_PATH
  • Per-step working directory configuration
  • Lightweight and simple design

Installation

Download Binary (Recommended)

Download the binary for your platform from the releases page.

Linux (x86_64)

curl -LO https://github.com/watany-dev/raptor/releases/download/v0.2.0/raptor_0.2.0_Linux_x86_64.tar.gz
tar xzf raptor_0.2.0_Linux_x86_64.tar.gz
sudo mv raptor /usr/local/bin/
raptor --version

Linux (ARM64)

curl -LO https://github.com/watany-dev/raptor/releases/download/v0.2.0/raptor_0.2.0_Linux_arm64.tar.gz
tar xzf raptor_0.2.0_Linux_arm64.tar.gz
sudo mv raptor /usr/local/bin/
raptor --version

macOS (Apple Silicon)

curl -LO https://github.com/watany-dev/raptor/releases/download/v0.2.0/raptor_0.2.0_Darwin_arm64.tar.gz
tar xzf raptor_0.2.0_Darwin_arm64.tar.gz
sudo mv raptor /usr/local/bin/
raptor --version

macOS (Intel)

curl -LO https://github.com/watany-dev/raptor/releases/download/v0.2.0/raptor_0.2.0_Darwin_x86_64.tar.gz
tar xzf raptor_0.2.0_Darwin_x86_64.tar.gz
sudo mv raptor /usr/local/bin/
raptor --version

Go install

go install github.com/watany-dev/raptor/cmd/raptor@v0.2.0

Build from Source

git clone https://github.com/watany-dev/raptor.git
cd raptor
go build -o raptor ./cmd/raptor
sudo mv raptor /usr/local/bin/

Requirements

  • Supported platforms: Linux, macOS (Windows is not supported)
  • Runtime: Git 2.5 or later
  • Build from source only: Go 1.24 or later

Usage

Basic Usage

# Run a specific job
raptor run --workflow <workflow-file> --job <job-id>

# Run all jobs (omit --job)
raptor run --workflow <workflow-file>

Command Options

Option Short Description
--workflow -w Path to workflow file (required)
--job -j Job ID to run (runs all jobs if omitted)
--workdir -C Working directory (default: current directory)
--dry-run -n Preview without actually executing
--ignore-if-errors Ignore condition evaluation errors (legacy mode)

Note: All workflows are executed in isolated Git worktrees for security.

Dry-run Mode

Dry-run mode allows you to preview what will be executed without actually running the workflow. Useful for checking and debugging CI pipelines.

# Explicitly specify dry-run flag
raptor run -w ci.yml --dry-run
raptor run -w ci.yml -n

# Omit run subcommand for automatic dry-run mode
raptor -w ci.yml

Example dry-run output:

πŸ” DRY RUN MODE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Workflow: .github/workflows/ci.yml
Name: CI
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ“‹ Job: build
   Runs-on: ubuntu-latest

   [1] Build
       Command:
         echo "Building..."

πŸ“‹ Job: test
   Depends on: build
   Runs-on: ubuntu-latest

   [1] Test
       Command:
         echo "Testing..."

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
To execute this workflow, use: raptor run -w .github/workflows/ci.yml

Information displayed:

  • Workflow name and path
  • Job ID, name, and runs-on
  • Each step's name, working directory, conditions (if), number of environment variables, and command content

Examples

# Run the build job from CI workflow
raptor run --workflow .github/workflows/ci.yml --job build

# Use short form
raptor run -w ci.yml -j test

# Run all jobs in workflow
raptor run -w ci.yml

# Run with specified working directory
raptor run -w .github/workflows/ci.yml -j lint -C /path/to/project

Job Dependencies

When using -j to run a specific job, Raptor automatically resolves and executes all its dependencies first:

# If deploy needs test, and test needs build:
# This runs: build β†’ test β†’ deploy
raptor run -w ci.yml -j deploy

If a dependency fails, dependent jobs are automatically skipped:

INFO running job job_id=build
INFO running job job_id=test
INFO skipping job job_id=deploy reason="dependency 'test' failed"

Help

raptor help
raptor --help

Check Version

raptor version
raptor --version
raptor -v

Supported Features

Workflow Syntax

Currently supported GitHub Actions syntax:

Feature Support
name (workflow/job/step names) βœ…
needs (job dependencies) βœ…
env (environment variables) βœ…
run (shell commands) βœ…
working-directory βœ…
GITHUB_ENV βœ…
GITHUB_PATH βœ…
if (conditionals) βœ… (full support with AND/OR/NOT, string functions, hashFiles)
uses (actions) ❌
with (action inputs) ❌
matrix (matrix builds) ❌

Conditionals (if)

Conditional step execution is supported:

steps:
  - name: Always run
    if: true
    run: echo "This always runs"

  - name: Conditional
    if: ${{ env.MY_VAR == 'value' }}
    run: echo "Runs when MY_VAR is 'value'"

  - name: On failure
    if: failure()
    run: echo "Runs only if previous step failed"

  - name: Always (even on failure)
    if: always()
    run: echo "Cleanup step"

  - name: Complex conditions with AND/OR
    if: ${{ success() && env.DEPLOY_ENV == 'production' }}
    run: echo "Deploy to production"

  - name: String functions
    if: ${{ startsWith(env.BRANCH_NAME, 'feature/') }}
    run: echo "Feature branch detected"

  - name: File hash for caching
    if: ${{ hashFiles('package.json') != '' }}
    run: echo "package.json exists"

Supported conditional syntax:

Syntax Description
true / false Literal boolean values
success() All previous steps succeeded
failure() Any step failed
always() Always execute (continue after failure)
cancelled() Execute on cancellation (always false)
${{ env.VAR == 'value' }} Environment variable comparison
${{ env.VAR != 'value' }} Environment variable negation
${{ steps.ID.outcome == 'success' }} Step result reference
${{ expr1 && expr2 }} Logical AND operator
${{ expr1 || expr2 }} Logical OR operator
${{ !expr }} Logical NOT operator
${{ (expr) }} Grouping with parentheses
contains(search, item) Check if string/array contains value
startsWith(search, prefix) Check if string starts with prefix
endsWith(search, suffix) Check if string ends with suffix
hashFiles(pattern, ...) Calculate SHA-256 hash of files matching patterns

Error Handling:

By default, Raptor uses strict mode for condition evaluation. If a condition has syntax errors or evaluation errors, the workflow will stop with a clear error message. This helps catch typos and invalid expressions early.

# Default behavior: strict mode
raptor run -w workflow.yml
# Error: failed to evaluate if condition: condition parse error: unexpected token

# Legacy behavior: ignore errors and continue
raptor run -w workflow.yml --ignore-if-errors
# Warning: failed to evaluate if condition: parse error: ... (defaulting to true)

Sample Workflow

Example workflow that can be run with Raptor:

name: CI

env:
  GLOBAL_VAR: "global-value"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Build
        run: echo "Building..."

  test:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Test
        run: echo "Testing..."

  deploy:
    runs-on: ubuntu-latest
    needs: [build, test]
    steps:
      - name: Deploy
        if: success()
        run: echo "Deploying..."

Security

Since Raptor executes commands described in workflow files, only run trusted workflows.

Security Features

  • Isolated execution: All workflows run in isolated Git worktrees
  • Absolute path prohibition: Absolute paths cannot be used in working-directory
  • Environment variable protection: Dangerous environment variables like LD_PRELOAD are blocked
  • Input validation: Environment variable names and values are validated

See SECURITY.md for details.

Warnings

Raptor runs workflows with your user permissions. Malicious workflows can:

  • Delete or modify files
  • Access network
  • Send data externally

Always verify the content before running.

Development

Build

go build ./...

Run Tests

go test ./...

Test Coverage

go test -cover ./...

Project Structure

raptor/
β”œβ”€β”€ cmd/raptor/        # CLI entry point
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ cli/           # CLI flag parsing and runner
β”‚   β”œβ”€β”€ dag/           # Job dependency graph (topological sort)
β”‚   β”œβ”€β”€ envfiles/      # GITHUB_ENV/GITHUB_PATH parsing
β”‚   β”œβ”€β”€ executor/      # Command execution engine
β”‚   β”œβ”€β”€ expression/    # Expression evaluation (if conditions)
β”‚   β”œβ”€β”€ runtime/       # Environment variable merging
β”‚   β”œβ”€β”€ security/      # Security validation
β”‚   β”œβ”€β”€ util/          # Git operation utilities
β”‚   β”œβ”€β”€ workflow/      # Workflow YAML parsing
β”‚   └── worktree/      # Git worktree management
└── docs/              # Development documentation

License

Apache License 2.0

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •