Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion config/chrome-go-runner.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ==========================================
Expand Down Expand Up @@ -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
# - Monitor resource usage with docker stats
13 changes: 13 additions & 0 deletions config/chrome-runner.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions docker/Dockerfile.chrome
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.chrome-go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 12 additions & 11 deletions docker/entrypoint-chrome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
22 changes: 19 additions & 3 deletions monitoring/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +51 to 73

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is a great update to the scrape configurations. To improve maintainability and reduce duplication, you could consider using YAML anchors. This would allow you to define common scrape parameters like scrape_interval once and reuse them across all runner jobs. This makes future updates to these parameters easier as you'd only need to change them in one place.

  # GitHub Runner application metrics - Standard runner
  - job_name: "github-runner-standard"
    static_configs:
      - targets: ["github-runner-main:9091"]
    scrape_interval: &scrape_interval 15s
    metrics_path: &metrics_path /metrics
    scrape_timeout: &scrape_timeout 10s

  # GitHub Runner application metrics - Chrome runner
  - job_name: "github-runner-chrome"
    static_configs:
      - targets: ["github-runner-chrome:9091"]
    scrape_interval: *scrape_interval
    metrics_path: *metrics_path
    scrape_timeout: *scrape_timeout

  # GitHub Runner application metrics - Chrome-Go runner
  - job_name: "github-runner-chrome-go"
    static_configs:
      - targets: ["github-runner-chrome-go:9091"]
    scrape_interval: *scrape_interval
    metrics_path: *metrics_path
    scrape_timeout: *scrape_timeout

Expand Down