

GitHub Actions is a common way to automate tests for a bioinformatics repository, but each run has to be pushed to GitHub and scheduled on a cloud runner, so the feedback loop is measured in minutes. act is a command-line tool that runs GitHub Actions workflows locally using Docker, which makes it possible to test a workflow before pushing it.
This post covers installation, the commands used most often, how secrets and environment variables are handled, the Docker images involved, and a few debugging techniques. The examples are generic pipelines; the same approach applies to a gene-expression or quality-control workflow.
The usual loop is:
With act, step 2 is replaced by a local run: the workflow is executed on the developer's machine, so several iterations can be completed before anything is pushed. The exact saving in time depends on the workflow and the machine, but the main benefit is that a broken workflow is often caught sooner.
act with PixiOne way to install act globally is with Pixi, a package manager that can install both Python packages and system tools:
pixi global install actPixi selects the correct binary for the operating system (macOS, Linux or Windows).
Verify the installation:
act --version# Output: act version 0.2.XReasons this can be convenient:
pixi global install actpixi global upgrade actmacOS (Homebrew)
brew install actLinux
# Debian/Ubuntucurl https://raw.githubusercontent.com/nektos/act/master/install.sh | bash
# Or with pacman (Arch)pacman -S actWindows (PowerShell)
choco install act# Or if using Scoop:scoop install actManual installation
$PATHact uses Docker to run workflows in containers, in a similar way to GitHub's cloud runners.
Option 1: Docker Desktop
Option 2: Install the Docker tools with Pixi
# Install Docker tools in your Pixi environmentpixi global install dockerOption 3: Linux system package
# Debian/Ubuntusudo apt-get install docker.io docker-composesudo usermod -aG docker $USER # Add current user to docker groupnewgrp docker # Activate group changesVerify the Docker installation:
docker --versiondocker run hello-world # Should complete successfullyTroubleshooting:
sudo systemctl start dockersudo usermod -aG docker $USERCheck that act can find the workflows in the repository:
cd /path/to/your/repoact --listExpected output:
Stage Job ID Job Name Workflow Name Workflow File Events0 test test test-workflow .github/workflows/test.yml pushIf no workflows appear, check that .github/workflows/ exists and contains .yml files.
If the project uses Pixi, act can be added as a task:
Add to pixi.toml:
[tasks]ci = "act push"ci-test = "act pull_request"ci-debug = "act -v push"Then run with Pixi:
pixi run ci # Run GitHub Actions locallypixi run ci-debug # With verbose outputCheck the Pixi setup:
pixi info# Should show: act is available globallyA small GitHub Actions workflow to test with act:
Create .github/workflows/test.yml:
name: Python Testson: push: branches: [main, develop]
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
- name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.12'
- name: Install dependencies run: | pip install pytest numpy pandas
- name: Run tests run: | pytest tests/ -vRun it locally:
act pushExpected output:
[Python Tests/test] π Start image pull...[Python Tests/test] π³ Docker pull requested ghcr.io/catthehacker/ubuntu:act-latest[Python Tests/test] β Image pull complete[Python Tests/test] π Start container...[Python Tests/test] β Run Main actions/checkout@v3[Python Tests/test] β Complete jobList the available workflows:
act --listRun a specific job:
act --job testRun a specific workflow:
act --workflow test.ymlSimulate a different event (for example, pull_request):
act pull_requestact provides several ways to pass variables.
Method 1: command-line flag
act -e event.jsonWhere event.json contains:
{ "repository": { "name": "my-repo", "owner": { "login": "myusername" } }}Method 2: .actrc file (in the repository root)
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest-lMethod 3: shell environment variables
export MY_VAR="value"export ANOTHER_VAR="another"act pushGitHub Actions uses secrets for sensitive data. With act, secrets can be passed locally.
Method 1: .secrets file (in the repository root)
MY_SECRET=super_secret_valueGITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxAPI_KEY=your_api_key_hereAdd .secrets to .gitignore so it is not committed:
echo ".secrets" >> .gitignoreMethod 2: command-line secret flag
act -s MY_SECRET=value -s GITHUB_TOKEN=tokenA workflow that uses secrets:
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
- name: Use secret run: | echo "API Key: ${{ secrets.API_KEY }}" echo "Token: ${{ secrets.GITHUB_TOKEN }}"Run with secrets:
act --secret-file .secretsThe echo example above prints a secret value to the log. It is shown here only to illustrate how secrets are referenced; avoid echoing real secrets in a workflow that runs anywhere but a disposable local container.
actact uses prebuilt Docker images that mimic GitHub's cloud runners. The default images are large, which improves compatibility with the tools a workflow expects.
Available images:
# Ubuntu (medium size, the default choice)ghcr.io/catthehacker/ubuntu:act-latest
# Full Ubuntu (largest, closest to a GitHub cloud runner)ghcr.io/catthehacker/ubuntu:full-latest
# Official Ubuntu (smallest, but only the base system)ubuntu:latest # Docker HubMethod 1: -P flag in the command
act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:full-latestMethod 2: .actrc file
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:full-latest-P windows-latest=ghcr.io/catthehacker/windows:full-latestSelecting the container architecture
act --container-architecture linux/amd64Large images take time on the first run. They can be pulled ahead of time:
# Pull the image oncedocker pull ghcr.io/catthehacker/ubuntu:act-latest
# Now act will use cached image (much faster)act pushDocker images consume space. Unused images can be removed with:
# Remove unused imagesdocker image prune -a
# Remove all containersdocker container prune -a
# Check disk usagedocker system dfThe catthehacker images are published in several sizes. A smaller image pulls and starts faster, but has fewer tools preinstalled, so startup may be quicker while setup steps take longer.
act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latestGitHub Actions supports caching, and act can use the same mechanism:
Workflow with caching:
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
- name: Cache pip dependencies uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip-
- name: Install Python dependencies run: pip install -r requirements.txt
- name: Run tests run: pytest tests/A cache hit typically skips most of the dependency installation.
By default, act runs jobs sequentially. Parallel execution can be enabled:
# Run all jobs in parallelact --parallel 4Workflow with multiple jobs:
jobs: unit-tests: runs-on: ubuntu-latest steps: - run: pytest tests/unit/
integration-tests: runs-on: ubuntu-latest steps: - run: pytest tests/integration/
lint: runs-on: ubuntu-latest steps: - run: pylint src/The wall-clock time then depends on the slowest job rather than the sum of all jobs.
act --listThis shows the jobs that would run, without executing them.
act --reuse-containers # Reuse running containersact --rebuild # Rebuild image from scratchThe following workflow illustrates a multi-version test matrix and a separate security job.
.github/workflows/ml-pipeline.ymlname: ML Pipeline - Gene Expression Analysison: push: branches: [main, develop] pull_request: branches: [main]
jobs: test: runs-on: ubuntu-latest strategy: matrix: python-version: ['3.10', '3.11', '3.12']
steps: - name: Checkout code uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }}
- name: Cache pip packages uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
- name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install pytest pytest-cov pytest-xdist
- name: Lint with pylint run: pylint src/ --exit-zero continue-on-error: true
- name: Run unit tests run: pytest tests/unit/ -v --cov=src --cov-report=xml
- name: Run integration tests run: pytest tests/integration/ -v
- name: Upload coverage reports uses: codecov/codecov-action@v3 if: matrix.python-version == '3.12' with: files: ./coverage.xml flags: unittests
security: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
- name: Run Bandit security check run: | pip install bandit bandit -r src/ -v --exit-code 0 continue-on-error: trueRun all jobs:
act pushRun a specific Python version:
act push --job test --matrix python-version=3.12Run only the security job:
act push --job securityact -v pushThis prints more detail, including Docker commands and environment variables.
If a step fails, the container can be inspected. A diagnostic step can be added to a workflow:
steps: - run: | echo "Debug info:" env | sort ls -laOr act can be run with the working directory bound into the container:
act -b # Bind the working directory into the container# View logsdocker ps -a
# Enter the containerdocker exec -it <container_id> /bin/bash"Cannot connect to Docker daemon"
# Solution: Start Dockersudo systemctl start docker # Linuxopen /Applications/Docker.app # macOS"Not enough space for Docker images"
# Solution: Clean updocker system prune -a --volumes"Workflow runs but tests fail locally but pass on GitHub"
# Solution: Check Python versions matchpython --versionact --list # Verify Python version in workflowThe table below is illustrative rather than a benchmark; actual times depend on the workflow, the machine and the network.
| Task | Local (act) |
GitHub Cloud |
|---|---|---|
| First run (image already pulled) | tens of seconds | several minutes |
| Subsequent runs (cached) | a few seconds | minutes |
| Development iteration | short loop | longer loop |
| Cost | machine time only | cloud runner minutes |
For a development session with many small iterations, the cumulative time saved can be substantial, mainly because a failing workflow is usually found before pushing.
act# Before git pushact push# If all pass, then:git push origin main# Use same image as GitHubact -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest.actrc, but never .secrets# .actrc (can be committed)-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:full-latest-l.secretsstrategy: matrix: python-version: ['3.10', '3.11', '3.12'] os: [ubuntu-latest, macos-latest]# requirements.txtpytest>=7.0.0numpy>=1.24.0pandas>=1.5.0scipy>=1.10.0If Pixi manages the project, global tools can live there too:
# Install act globally with Pixipixi global install act
# Update act easilypixi global upgrade act
# See all globally installed toolspixi global listA .pixi.toml for the project:
[dependencies]python = "3.12"pytest = ">=7.0.0"numpy = ">=1.24.0"pandas = ">=1.5.0"
[tasks]test = "pytest tests/ -v"lint = "pylint src/"ci = "act push" # Run GitHub Actions locallyThe team can then run:
pixi run test # Run testspixi run lint # Run linterpixi run ci # Run GitHub Actions locallyact runs GitHub Actions workflows locally, so a workflow can be tested before pushing.nektos/act repository: github.com/nektos/actact documentation: nektosact.comcatthehacker runner images: github.com/catthehacker/docker_images



