diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml index 12759c2..1a2978d 100644 --- a/.gitea/workflows/tests.yml +++ b/.gitea/workflows/tests.yml @@ -25,16 +25,28 @@ jobs: echo "RUNNER_ENVIRONMENT: ${RUNNER_ENVIRONMENT:-not_set}" echo "ACTIONS_RUNNER_NAME: ${ACTIONS_RUNNER_NAME:-not_set}" + echo "=== Additional Runner Variables ===" + echo "RUNNER_LABEL: ${RUNNER_LABEL:-not_set}" + echo "RUNNER_VERSION: ${RUNNER_VERSION:-not_set}" + echo "GITEA_ACTIONS_RUNNER_VERSION: ${GITEA_ACTIONS_RUNNER_VERSION:-not_set}" + echo "CONTAINER_NAME: ${CONTAINER_NAME:-not_set}" + + echo "=== Docker/Container Info ===" + echo "Container hostname: $(hostname)" + cat /etc/hostname 2>/dev/null || echo "No /etc/hostname" + echo "=== All Environment Variables ===" - env | grep -i runner || echo "No runner-related env vars found" + env | grep -iE "(runner|gitea|act|container)" | head -20 - echo "=== Gitea Context Variables ===" - echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}" - echo "GITHUB_SHA: ${GITHUB_SHA}" + # Try to detect actual runner from compose service or docker labels + if command -v docker >/dev/null 2>&1; then + echo "=== Docker Container Labels ===" + docker inspect $(hostname) --format='{{range $key, $value := .Config.Labels}}{{$key}}={{$value}}{{"\n"}}{{end}}' 2>/dev/null | grep -i runner || echo "No runner labels found" + fi - # Detect runner name from environment variables - RUNNER_NAME="${GITEA_RUNNER_NAME:-${HOSTNAME:-${RUNNER_NAME:-${ACT_RUNNER_NAME:-unknown}}}}" - echo "Runner: $RUNNER_NAME" + # Detect runner name with better logic + DETECTED_RUNNER="${GITEA_RUNNER_NAME:-${RUNNER_NAME:-${ACT_RUNNER_NAME:-${HOSTNAME:-unknown}}}}" + echo "Detected Runner: $DETECTED_RUNNER" # Show system info echo "Container ID: $(hostname)" @@ -52,89 +64,29 @@ jobs: echo "=== Repository Checkout ===" cd "${GITHUB_WORKSPACE}" - # Ensure clean workspace + # Clean workspace rm -rf ./* .git 2>/dev/null || true - # Debug SSL connectivity - echo "Testing SSL connectivity to dogar.darkhelm.org..." - openssl s_client -connect dogar.darkhelm.org:443 -servername dogar.darkhelm.org < /dev/null 2>&1 | grep -E "(CONNECTED|Verify return code)" || echo "SSL test completed" - - # Debug SSH keys and connectivity - echo "=== SSH Debug Info ===" - echo "Current user: $(whoami)" - echo "Current HOME: $HOME" - echo "UID/GID: $(id)" - - echo "Checking all possible SSH key locations:" - echo "~/.ssh/:" && ls -la ~/.ssh/ 2>/dev/null || echo " Not found" - echo "/root/.ssh/:" && ls -la /root/.ssh/ 2>/dev/null || echo " Not found" - echo "/data/.ssh/:" && ls -la /data/.ssh/ 2>/dev/null || echo " Not found" - echo "/home/act/.ssh/:" && ls -la /home/act/.ssh/ 2>/dev/null || echo " Not found" - - echo "=== Mount Verification ===" - echo "Container mounts (from /proc/mounts):" - grep ssh /proc/mounts 2>/dev/null || echo " No SSH-related mounts found" - - # Set up SSH key for repository access - echo "=== SSH Key Setup ===" - - # Use SSH key from Gitea repository secret (recommended approach) + # Set up SSH key from Gitea repository secret if [ -n "${SSH_PRIVATE_KEY}" ]; then - echo "Setting up SSH key from Gitea repository secret" mkdir -p ~/.ssh echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa - echo "SSH private key installed from repository secret" - ls -la ~/.ssh/ - else - echo "No SSH_PRIVATE_KEY secret found in repository" - echo "To enable SSH clone, add your deploy key as SSH_PRIVATE_KEY secret in:" - echo "Repository Settings → Secrets → Actions → Add SSH_PRIVATE_KEY" + ssh-keyscan -p 2222 dogar.darkhelm.org >> ~/.ssh/known_hosts 2>/dev/null fi - ssh-keyscan -p 2222 dogar.darkhelm.org 2>/dev/null || echo "SSH keyscan failed" + # Clone repository via SSH + GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" \ + git clone --depth 1 --branch main \ + ssh://git@dogar.darkhelm.org:2222/DarkHelm.org/plex-playlist.git . - # Try clone methods with better debugging - echo "=== Attempting Clone Methods ===" - - # Test SSH connection first - echo "Testing SSH connection directly..." - ssh -o StrictHostKeyChecking=no -p 2222 git@dogar.darkhelm.org 2>&1 || echo "SSH test completed" - - # Method 1: SSH external (most reliable if keys work) - echo "Trying SSH external (dogar.darkhelm.org:2222)..." - if GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" git clone --depth 1 --branch main ssh://git@dogar.darkhelm.org:2222/DarkHelm.org/plex-playlist.git . 2>&1; then - echo "✓ External SSH clone successful" - # Method 2: Internal SSH (kankali runner only) - elif echo "Trying internal SSH (gitea:3000)..." && GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git clone --depth 1 --branch main git@gitea:3000/DarkHelm.org/plex-playlist.git . 2>&1; then - echo "✓ Internal SSH clone successful (kankali-runner only)" - # Method 3: Internal HTTP (kankali runner only) - elif echo "Trying internal HTTP (gitea:3000)..." && git clone --depth 1 --branch main http://gitea:3000/DarkHelm.org/plex-playlist.git . 2>&1; then - echo "✓ Internal HTTP clone successful (kankali-runner only)" - # Method 4: HTTPS with token (for private repo access) - elif [ -n "${GITEA_TOKEN}" ] && echo "Trying HTTPS with token..." && git -c http.sslVerify=false clone --depth 1 --branch main "https://token:${GITEA_TOKEN}@dogar.darkhelm.org/DarkHelm.org/plex-playlist.git" . 2>&1; then - echo "✓ External HTTPS clone with token successful" - # Method 5: HTTPS with SSL verification disabled (fallback) - elif echo "Trying HTTPS with SSL disabled..." && git -c http.sslVerify=false clone --depth 1 --branch main https://dogar.darkhelm.org/DarkHelm.org/plex-playlist.git . 2>&1; then - echo "✓ External HTTPS clone successful (SSL verification disabled)" - # Method 6: HTTP external (try different URL formats) - elif echo "Trying HTTP external (port 3000)..." && git clone --depth 1 --branch main http://dogar.darkhelm.org:3000/DarkHelm.org/plex-playlist.git . 2>&1; then - echo "✓ External HTTP clone successful (port 3000)" - elif echo "Trying HTTP external (no .git)..." && git clone --depth 1 --branch main http://dogar.darkhelm.org/DarkHelm.org/plex-playlist . 2>&1; then - echo "✓ External HTTP clone successful" - else - echo "❌ All clone methods failed" - echo "Attempting one more time with verbose output..." - git clone --depth 1 --branch main https://dogar.darkhelm.org/DarkHelm.org/plex-playlist.git . || exit 1 - fi - - # Checkout the specific commit if available, otherwise use main + # Checkout specific commit if provided if [ -n "${GITHUB_SHA}" ]; then git checkout "${GITHUB_SHA}" 2>/dev/null || echo "Using main branch HEAD" - else - echo "Using main branch HEAD" fi + echo "✓ Repository checkout completed" + - name: Upload source code uses: actions/upload-artifact@v4 with: @@ -146,14 +98,15 @@ jobs: backend-setup: name: Backend Setup (Python 3.13 + uv + Environment) - runs-on: python-latest + runs-on: ubuntu-act needs: setup steps: - name: Runner Info run: | echo "=== Backend Setup - $(date) ===" - echo "Runner: ${GITEA_RUNNER_NAME:-$(hostname)} | User: $(whoami) | OS: $(uname -s)" + RUNNER="${GITEA_RUNNER_NAME:-${RUNNER_NAME:-${ACT_RUNNER_NAME:-$(hostname)}}}" + echo "Runner: $RUNNER | User: $(whoami) | OS: $(uname -s)" - name: Download source code uses: actions/download-artifact@v4 @@ -214,14 +167,15 @@ jobs: frontend-setup: name: Frontend Setup (Node.js 24 + Yarn Berry + Build) - runs-on: node-latest + runs-on: ubuntu-act needs: setup steps: - name: Runner Info run: | echo "=== Frontend Setup - $(date) ===" - echo "Runner: ${GITEA_RUNNER_NAME:-$(hostname)} | User: $(whoami) | OS: $(uname -s)" + RUNNER="${GITEA_RUNNER_NAME:-${RUNNER_NAME:-${ACT_RUNNER_NAME:-$(hostname)}}}" + echo "Runner: $RUNNER | User: $(whoami) | OS: $(uname -s)" - name: Download source code uses: actions/download-artifact@v4 @@ -298,14 +252,15 @@ jobs: backend-tests: name: Backend Tests (Python 3.13 + uv) - runs-on: python-latest + runs-on: ubuntu-act needs: backend-setup steps: - name: Runner Info run: | echo "=== Backend Tests - $(date) ===" - echo "Runner: ${GITEA_RUNNER_NAME:-$(hostname)} | User: $(whoami)" + RUNNER="${GITEA_RUNNER_NAME:-${RUNNER_NAME:-${ACT_RUNNER_NAME:-$(hostname)}}}" + echo "Runner: $RUNNER | User: $(whoami)" - name: Download backend environment uses: actions/download-artifact@v4 @@ -342,14 +297,15 @@ jobs: frontend-tests: name: Frontend Tests (TypeScript + Vue + Yarn Berry) - runs-on: node-latest + runs-on: ubuntu-act needs: frontend-setup steps: - name: Runner Info run: | echo "=== Frontend Tests - $(date) ===" - echo "Runner: ${GITEA_RUNNER_NAME:-$(hostname)} | User: $(whoami)" + RUNNER="${GITEA_RUNNER_NAME:-${RUNNER_NAME:-${ACT_RUNNER_NAME:-$(hostname)}}}" + echo "Runner: $RUNNER | User: $(whoami)" - name: Download frontend environment uses: actions/download-artifact@v4