fix: Use nektos/act instead of gitea/act_runner for local testing
gitea/act_runner is a runner daemon that needs to connect to a Gitea instance, not a local testing tool. nektos/act is the correct tool for running workflows locally, and it's compatible with both GitHub Actions and Gitea Actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
## test-ci-locally.sh
|
## test-ci-locally.sh
|
||||||
|
|
||||||
Tests the Gitea Actions workflow locally using `act_runner` in Docker.
|
Tests the Gitea Actions workflow locally using `act` (nektos/act) in Docker.
|
||||||
|
|
||||||
### Purpose
|
### Purpose
|
||||||
|
|
||||||
When CI tests fail, this script allows you to run the **exact same workflow** (`.gitea/workflows/magnitude.yml`) locally to debug issues without repeatedly pushing to trigger CI runs. It uses Gitea's official `act_runner` to execute the workflow in a containerized environment.
|
When CI tests fail, this script allows you to run the **exact same workflow** (`.gitea/workflows/magnitude.yml`) locally to debug issues without repeatedly pushing to trigger CI runs. It uses `nektos/act` to execute the workflow in a containerized environment, just like GitHub Actions or Gitea Actions would.
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
@@ -17,11 +17,11 @@ When CI tests fail, this script allows you to run the **exact same workflow** (`
|
|||||||
### What it does
|
### What it does
|
||||||
|
|
||||||
1. Loads environment variables from `.env` file
|
1. Loads environment variables from `.env` file
|
||||||
2. Runs `gitea/act_runner:latest` Docker container with:
|
2. Runs `nektos/act:latest` Docker container with:
|
||||||
- Docker socket mounted (so act_runner can create containers)
|
- Docker socket mounted (so act can create containers)
|
||||||
- Current directory mounted as workspace
|
- Current directory mounted as workspace
|
||||||
- Secrets passed from `.env` file
|
- Secrets passed from `.env` file
|
||||||
3. Executes `.gitea/workflows/magnitude.yml` using act_runner's `exec` command
|
3. Executes `.gitea/workflows/magnitude.yml` using act
|
||||||
4. The workflow then runs its steps:
|
4. The workflow then runs its steps:
|
||||||
- Checkout code
|
- Checkout code
|
||||||
- Create .env file with secrets
|
- Create .env file with secrets
|
||||||
@@ -38,10 +38,10 @@ When CI tests fail, this script allows you to run the **exact same workflow** (`
|
|||||||
|
|
||||||
### How It Works
|
### How It Works
|
||||||
|
|
||||||
The script uses Gitea's act_runner to execute the workflow YAML file. Act_runner creates containers according to the workflow definition, which in turn uses `docker-compose.ci.yml` to set up the test environment:
|
The script uses `nektos/act` to execute the workflow YAML file. Act is compatible with both GitHub Actions and Gitea Actions workflows. It creates containers according to the workflow definition, which in turn uses `docker-compose.ci.yml` to set up the test environment:
|
||||||
|
|
||||||
```
|
```
|
||||||
act_runner (Docker container)
|
act (nektos/act Docker container)
|
||||||
↓ executes .gitea/workflows/magnitude.yml
|
↓ executes .gitea/workflows/magnitude.yml
|
||||||
↓ which runs docker-compose with:
|
↓ which runs docker-compose with:
|
||||||
magnitude (Playwright container)
|
magnitude (Playwright container)
|
||||||
@@ -51,6 +51,12 @@ nextjs (Node.js container running pnpm dev)
|
|||||||
surrealdb (SurrealDB container)
|
surrealdb (SurrealDB container)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Note on nektos/act vs gitea/act_runner
|
||||||
|
|
||||||
|
- `nektos/act` is designed for local workflow testing and is compatible with both GitHub Actions and Gitea Actions
|
||||||
|
- `gitea/act_runner` is a runner daemon that needs to connect to a Gitea instance and is not designed for offline local testing
|
||||||
|
- This script uses `nektos/act` which provides the local testing experience similar to running workflows in CI
|
||||||
|
|
||||||
### Debugging CI Failures
|
### Debugging CI Failures
|
||||||
|
|
||||||
If Gitea Actions fail:
|
If Gitea Actions fail:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Script to test Gitea Actions workflow locally using act_runner
|
# Script to test Gitea Actions workflow locally using act (nektos/act)
|
||||||
# This runs the actual .gitea/workflows/magnitude.yml file in a containerized environment
|
# This runs the actual .gitea/workflows/magnitude.yml file in a containerized environment
|
||||||
|
|
||||||
set -e # Exit on error
|
set -e # Exit on error
|
||||||
@@ -25,7 +25,7 @@ fi
|
|||||||
echo -e "${YELLOW}Loading environment variables from .env${NC}"
|
echo -e "${YELLOW}Loading environment variables from .env${NC}"
|
||||||
export $(cat .env | grep -v '^#' | xargs)
|
export $(cat .env | grep -v '^#' | xargs)
|
||||||
|
|
||||||
# Build secret flags for act_runner
|
# Build secret flags for act
|
||||||
# These will be available in the workflow as secrets.*
|
# These will be available in the workflow as secrets.*
|
||||||
SECRET_FLAGS=""
|
SECRET_FLAGS=""
|
||||||
SECRET_FLAGS="$SECRET_FLAGS -s ATPROTO_CLIENT_ID=$ATPROTO_CLIENT_ID"
|
SECRET_FLAGS="$SECRET_FLAGS -s ATPROTO_CLIENT_ID=$ATPROTO_CLIENT_ID"
|
||||||
@@ -37,20 +37,21 @@ SECRET_FLAGS="$SECRET_FLAGS -s TEST_BLUESKY_HANDLE=$TEST_BLUESKY_HANDLE"
|
|||||||
SECRET_FLAGS="$SECRET_FLAGS -s TEST_BLUESKY_PASSWORD=$TEST_BLUESKY_PASSWORD"
|
SECRET_FLAGS="$SECRET_FLAGS -s TEST_BLUESKY_PASSWORD=$TEST_BLUESKY_PASSWORD"
|
||||||
SECRET_FLAGS="$SECRET_FLAGS -s ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY"
|
SECRET_FLAGS="$SECRET_FLAGS -s ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY"
|
||||||
|
|
||||||
echo -e "${YELLOW}Running Gitea Actions workflow with act_runner${NC}"
|
echo -e "${YELLOW}Running Gitea Actions workflow with act (nektos/act)${NC}"
|
||||||
echo -e "${YELLOW}This will execute .gitea/workflows/magnitude.yml${NC}"
|
echo -e "${YELLOW}This will execute .gitea/workflows/magnitude.yml${NC}"
|
||||||
|
|
||||||
# Run act_runner in Docker to execute the workflow
|
# Run act in Docker to execute the workflow
|
||||||
# - Mount Docker socket so act_runner can create containers
|
# - Mount Docker socket so act can create containers
|
||||||
# - Mount current directory as workspace
|
# - Mount current directory as workspace
|
||||||
# - Pass secrets as flags
|
# - Pass secrets as flags
|
||||||
|
# - Use -W flag to specify workflow file
|
||||||
|
# - Use --rm to clean up container after run
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
-v "$(pwd):/workspace" \
|
-v "$(pwd):/workspace" \
|
||||||
-w /workspace \
|
-w /workspace \
|
||||||
-e ACTIONS_CACHE_URL="" \
|
nektos/act:latest \
|
||||||
gitea/act_runner:latest \
|
-W .gitea/workflows/magnitude.yml \
|
||||||
exec -W .gitea/workflows/magnitude.yml \
|
|
||||||
$SECRET_FLAGS || {
|
$SECRET_FLAGS || {
|
||||||
echo -e "${RED}Workflow execution failed!${NC}"
|
echo -e "${RED}Workflow execution failed!${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user