GitHub Actions
This project uses GitHub Actions for CI/CD. This page describes how to run and test these actions locally to save time and avoid cluttering the commit history with fix ci commits.
Prerequisites
- Docker: Ensure Docker is installed and running on your machine.
- Act: We use gh act (an extension for the GitHub CLI) or the standalone act tool.
Installation
Install the GitHub CLI extension:
bashgh extension install https://github.com/nektos/gh-act(Or refer to the official documentation for other installation methods.)
Crucial Configuration:
To ensure act works with our workflow labels (like runs-on:
self-hosted), create a configuration file so you don't have to type long flags every time.Create or edit
~/.config/act/actrc(Linux/macOS) or%USERPROFILE%\.config\act\actrc(Windows) and add:plaintext-P self-hosted=catthehacker/ubuntu:act-latest -P linux=catthehacker/ubuntu:act-latest
Usage
Once configured, you can run actions from the repository root.
List available jobs
See which jobs are available to run from your current workflows:
gh act -lRun a specific job
To run a specific job (e.g. python-lint from .github/workflows/python-lint.yml):
gh act -j python-lintTo capture the logs of an action into a file use:
gh act -j python-lint > python-lint.log 2>&1Troubleshooting
Error: "Skipping unsupported platform" If you see this error, it means act doesn't know which Docker image to use for our custom runner labels. Ensure you have completed the Configuration step above to map self-hosted to a valid Docker image.