Testing GitHub Actions Locally with Act
Testing GitHub Actions Locally with Act
This guide explains how to test GitHub Actions workflows locally using act.
Prerequisites
-
Install act: https://github.com/nektos/act
- Windows:
choco install act-clior download from releases - macOS:
brew install act - Linux: See installation instructions on GitHub
- Windows:
-
Docker must be running: Act uses Docker to run workflows
Setup
-
Create secrets file:
cp .secrets.example .secrets ```typescript -
Fill in your secrets in
.secretsfile:PLAYWRIGHT_TEST_EMAIL=your-test-email@example.com PLAYWRIGHT_TEST_PASSWORD=your-test-password NEXT_PUBLIC_SUPABASE_URL=your-supabase-url NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key DATABASE_URL=your-database-url ```typescript
Running Tests
Run the Playwright workflow
act -W .github/workflows/playwright.act.yml --secret-file .secrets
```typescript
### Run a specific job
```bash
act -W .github/workflows/playwright.act.yml -j test --secret-file .secrets
```typescript
### List available workflows
```bash
act -l
```typescript
### Run with verbose output
```bash
act -W .github/workflows/playwright.act.yml --secret-file .secrets -v
```typescript
## Notes
- The workflow file `playwright.act.yml` uses `ubuntu-latest` instead of `self-hosted` for local testing
- Make sure Docker is running before executing act commands
- Act may take longer than GitHub Actions as it runs in Docker containers
- Some actions may not work perfectly in act (especially self-hosted runners)
## Troubleshooting
- **Docker not running**: Start Docker Desktop or Docker daemon
- **Secrets not loading**: Check that `.secrets` file exists and has correct format
- **Workflow not found**: Use `-W` flag to specify the workflow file path