diff --git a/docs/TESTING.md b/docs/TESTING.md index 992ea30..cb52a0a 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -90,6 +90,17 @@ tests/ โ””โ”€โ”€ visual-regression.spec.ts # 23 tests per browser ``` +## ๐Ÿš€ Runner Management Scripts + +``` +community-rule/ +โ”œโ”€โ”€ start-runner.sh # Start Gitea Actions runner +โ”œโ”€โ”€ stop-runner.sh # Stop Gitea Actions runner +โ”œโ”€โ”€ status-runner.sh # Check runner status +โ”œโ”€โ”€ config.yaml # Runner configuration +โ””โ”€โ”€ act_runner # Gitea Actions runner binary +``` + ## ๐Ÿงช Unit & Integration Testing ### Framework @@ -423,6 +434,43 @@ git add . git commit -m "feat: add new component with tests" ``` +### 2. Manual Runner Management +The Gitea Actions runner is managed manually to save resources and provide control over when CI runs. + +#### Start Runner (Before Creating PR) +```bash +# Start the runner to execute CI jobs +./start-runner.sh +``` + +#### Check Runner Status +```bash +# Check if runner is running and see recent logs +./status-runner.sh +``` + +#### Stop Runner (After PR Complete) +```bash +# Stop the runner to free up resources +./stop-runner.sh +``` + +#### Complete PR Workflow +```bash +# 1. Start runner +./start-runner.sh + +# 2. Create Pull Request +# Go to repository โ†’ New Pull Request + +# 3. Monitor CI progress +./status-runner.sh +# Or check Gitea Actions page + +# 4. Stop runner when done +./stop-runner.sh +``` + ### 2. Pull Request Process 1. **Create PR** โ†’ CI pipeline starts automatically diff --git a/docs/TESTING_QUICK_REFERENCE.md b/docs/TESTING_QUICK_REFERENCE.md index 2c618f5..c51f7cc 100644 --- a/docs/TESTING_QUICK_REFERENCE.md +++ b/docs/TESTING_QUICK_REFERENCE.md @@ -18,6 +18,19 @@ npm run e2e npm run lhci ``` +### Manual Runner Management + +```bash +# Start runner (before creating PR) +./start-runner.sh + +# Check runner status +./status-runner.sh + +# Stop runner (after PR complete) +./stop-runner.sh +``` + ### Visual Regression ```bash diff --git a/start-runner.sh b/start-runner.sh new file mode 100755 index 0000000..e669821 --- /dev/null +++ b/start-runner.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +echo "๐Ÿš€ Starting Gitea Actions Runner..." + +# Check if runner is already running +if pgrep -f "act_runner daemon" > /dev/null; then + echo "โš ๏ธ Runner is already running!" + echo "To stop it, run: ./stop-runner.sh" + exit 1 +fi + +# Start the runner in the background +./act_runner daemon --config config.yaml & +RUNNER_PID=$! + +# Save PID to file for easy stopping +echo $RUNNER_PID > .runner.pid + +echo "โœ… Runner started with PID: $RUNNER_PID" +echo "๐Ÿ“ Logs will be written to: runner.log" +echo "" +echo "To stop the runner, run: ./stop-runner.sh" +echo "To check status, run: ./status-runner.sh" diff --git a/status-runner.sh b/status-runner.sh new file mode 100755 index 0000000..fbec71b --- /dev/null +++ b/status-runner.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +echo "๐Ÿ“Š Gitea Actions Runner Status" +echo "==============================" + +# Check if runner is running +if pgrep -f "act_runner daemon" > /dev/null; then + RUNNER_PID=$(pgrep -f "act_runner daemon") + echo "โœ… Runner is RUNNING (PID: $RUNNER_PID)" + echo "" + echo "๐Ÿ“ Recent logs:" + if [ -f runner.log ]; then + tail -5 runner.log + else + echo "No log file found" + fi + echo "" + echo "To stop the runner: ./stop-runner.sh" +else + echo "โŒ Runner is NOT RUNNING" + echo "" + echo "To start the runner: ./start-runner.sh" +fi + +echo "" +echo "๐Ÿ”— Gitea Actions URL:" +echo "https://git.medlab.host/CommunityRule/community-rule/actions" diff --git a/stop-runner.sh b/stop-runner.sh new file mode 100755 index 0000000..c13468d --- /dev/null +++ b/stop-runner.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +echo "๐Ÿ›‘ Stopping Gitea Actions Runner..." + +# Check if PID file exists +if [ -f .runner.pid ]; then + RUNNER_PID=$(cat .runner.pid) + + # Check if process is still running + if ps -p $RUNNER_PID > /dev/null; then + echo "๐Ÿ”„ Stopping runner with PID: $RUNNER_PID" + kill $RUNNER_PID + + # Wait a moment for graceful shutdown + sleep 2 + + # Force kill if still running + if ps -p $RUNNER_PID > /dev/null; then + echo "โšก Force stopping runner..." + kill -9 $RUNNER_PID + fi + + echo "โœ… Runner stopped successfully" + else + echo "โš ๏ธ Runner process not found (PID: $RUNNER_PID)" + fi + + # Clean up PID file + rm -f .runner.pid +else + echo "๐Ÿ” No PID file found, checking for any running runners..." + pkill -f "act_runner daemon" + echo "โœ… Any running runners have been stopped" +fi