diff --git a/config/chrome-go-runner.env.example b/config/chrome-go-runner.env.example index 1c965f54..c8c36f2f 100644 --- a/config/chrome-go-runner.env.example +++ b/config/chrome-go-runner.env.example @@ -66,6 +66,19 @@ GO_TEST_TIMEOUT=10m # Go Module Cache GOMODCACHE=/home/runner/go/pkg/mod +# ========================================== +# OPTIONAL: Prometheus Metrics Configuration +# ========================================== + +# Runner type label exposed in Prometheus metrics +# RUNNER_TYPE=chrome-go + +# Port for the Prometheus metrics endpoint (container-internal; host port mapped in docker-compose) +# METRICS_PORT=9091 + +# Interval in seconds between metrics collection updates +# METRICS_UPDATE_INTERVAL=30 + # ========================================== # PERFORMANCE AND RESOURCE CONFIGURATION # ========================================== @@ -164,4 +177,4 @@ RUNNER_WORKDIR=/home/runner/_work # For performance issues: # - Adjust memory limits based on available resources # - Consider using RUNNER_EPHEMERAL=true for cleaner runs -# - Monitor resource usage with docker stats \ No newline at end of file +# - Monitor resource usage with docker stats diff --git a/config/chrome-runner.env.example b/config/chrome-runner.env.example index 306acdcd..9d6a6204 100644 --- a/config/chrome-runner.env.example +++ b/config/chrome-runner.env.example @@ -55,6 +55,19 @@ SCREEN_WIDTH=1920 SCREEN_HEIGHT=1080 SCREEN_DEPTH=24 +# ========================================== +# OPTIONAL: Prometheus Metrics Configuration +# ========================================== + +# Runner type label exposed in Prometheus metrics +# RUNNER_TYPE=chrome + +# Port for the Prometheus metrics endpoint (container-internal; host port mapped in docker-compose) +# METRICS_PORT=9091 + +# Interval in seconds between metrics collection updates +# METRICS_UPDATE_INTERVAL=30 + # Memory limits CHROME_MAX_MEMORY=2048 NODE_MAX_MEMORY=4096 diff --git a/docker/Dockerfile.chrome b/docker/Dockerfile.chrome index 8a70d9c0..11d4f4ba 100644 --- a/docker/Dockerfile.chrome +++ b/docker/Dockerfile.chrome @@ -88,6 +88,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ libicu-dev \ # Chrome & UI testing dependencies (existing) libnss3 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxtst6 libatk1.0-0 libatk-bridge2.0-0 libdrm2 libgbm1 libasound2-dev libatspi2.0-0 libgtk-3-0 libpangocairo-1.0-0 libcairo2 libgdk-pixbuf-2.0-0 fonts-liberation fonts-noto-color-emoji fonts-noto-cjk xvfb procps \ + # Metrics endpoint dependency (required by metrics-server.sh) + netcat-openbsd \ # Python python3 python3-pip python3-venv \ # Playwright/Chromium/Chrome required libraries (Ubuntu 24.04 compatible) diff --git a/docker/Dockerfile.chrome-go b/docker/Dockerfile.chrome-go index 4ef4d5de..d3214f13 100644 --- a/docker/Dockerfile.chrome-go +++ b/docker/Dockerfile.chrome-go @@ -89,6 +89,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ libicu-dev \ # Chrome & UI testing dependencies (existing) libnss3 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxtst6 libatk1.0-0 libatk-bridge2.0-0 libdrm2 libgbm1 libasound2-dev libatspi2.0-0 libgtk-3-0 libpangocairo-1.0-0 libcairo2 libgdk-pixbuf-2.0-0 fonts-liberation fonts-noto-color-emoji fonts-noto-cjk xvfb procps \ + # Metrics endpoint dependency (required by metrics-server.sh) + netcat-openbsd \ # Python python3 python3-pip python3-venv \ # Playwright/Chromium/Chrome required libraries (Ubuntu 24.04 compatible) diff --git a/docker/entrypoint-chrome.sh b/docker/entrypoint-chrome.sh index 25475d65..806368fc 100755 --- a/docker/entrypoint-chrome.sh +++ b/docker/entrypoint-chrome.sh @@ -28,22 +28,12 @@ validate_hostname() { return 0 } -# Check for required environment variables -: "${GITHUB_TOKEN:?Error: GITHUB_TOKEN environment variable not set.}" -: "${GITHUB_REPOSITORY:?Error: GITHUB_REPOSITORY environment variable not set.}" - -# Validate inputs before using them -validate_repository "$GITHUB_REPOSITORY" || exit 1 - -# Optional variables with default values +# Optional variables with default values (set before metrics for RUNNER_NAME usage) RUNNER_NAME="${RUNNER_NAME:-chrome-runner-$(hostname)}" RUNNER_LABELS="${RUNNER_LABELS:-chrome,ui-tests,playwright,cypress}" RUNNER_WORK_DIR="${RUNNER_WORK_DIR:-/home/runner/workspace}" GITHUB_HOST="${GITHUB_HOST:-github.com}" # For GitHub Enterprise -# Validate GitHub host -validate_hostname "$GITHUB_HOST" || exit 1 - # --- METRICS SETUP (Phase 2: Prometheus Monitoring) --- # Start metrics services BEFORE token validation to enable standalone testing # TASK-013: Initialize job log @@ -106,6 +96,17 @@ else echo "Warning: metrics-server.sh not found, metrics endpoint disabled" fi +# --- GITHUB RUNNER SETUP --- +# Check for required environment variables (after metrics so endpoint works standalone) +: "${GITHUB_TOKEN:?Error: GITHUB_TOKEN environment variable not set.}" +: "${GITHUB_REPOSITORY:?Error: GITHUB_REPOSITORY environment variable not set.}" + +# Validate inputs before using them +validate_repository "$GITHUB_REPOSITORY" || exit 1 + +# Validate GitHub host +validate_hostname "$GITHUB_HOST" || exit 1 + # Change to the runner's directory cd /actions-runner diff --git a/monitoring/prometheus.yml b/monitoring/prometheus.yml index e6209023..bd1f5d59 100644 --- a/monitoring/prometheus.yml +++ b/monitoring/prometheus.yml @@ -48,10 +48,26 @@ scrape_configs: scrape_interval: 30s metrics_path: /metrics - # GitHub Runner application metrics - - job_name: "github-runner" + # GitHub Runner application metrics - Standard runner + - job_name: "github-runner-standard" static_configs: - - targets: ["runner:8080"] + - targets: ["github-runner-main:9091"] + scrape_interval: 15s + metrics_path: /metrics + scrape_timeout: 10s + + # GitHub Runner application metrics - Chrome runner + - job_name: "github-runner-chrome" + static_configs: + - targets: ["github-runner-chrome:9091"] + scrape_interval: 15s + metrics_path: /metrics + scrape_timeout: 10s + + # GitHub Runner application metrics - Chrome-Go runner + - job_name: "github-runner-chrome-go" + static_configs: + - targets: ["github-runner-chrome-go:9091"] scrape_interval: 15s metrics_path: /metrics scrape_timeout: 10s