Test CI v2.1
Some checks failed
Go CI Pipeline / Lint Code (push) Failing after 34s
Go CI Pipeline / Security Scan (SCA) (push) Failing after 1m51s
Go CI Pipeline / Run Tests (push) Failing after 50s
Go CI Pipeline / Build Application (push) Has been skipped

This commit is contained in:
phattt2901 2025-05-03 17:13:02 +07:00
parent d862422638
commit d7bb058d71

View File

@ -1,11 +1,12 @@
# File: .gitea/workflows/network-test.yml
# --- Updated Version ---
name: Network Connectivity Test
name: Network Connectivity Test (Updated)
on:
push: # Chạy khi push code (có thể giới hạn vào một nhánh test nếu muốn)
branches:
- master # Ví dụ: chỉ chạy khi push lên nhánh test-network
- test-network # Ví dụ: chỉ chạy khi push lên nhánh test-network
workflow_dispatch: # Cho phép chạy thủ công từ giao diện Gitea
jobs:
@ -13,39 +14,51 @@ jobs:
name: Check Runner to Server Connectivity
runs-on: ubuntu-latest # Đảm bảo dùng cùng label với runner của bạn
# IP Address của Gitea Server (lấy từ docker network inspect trước đó)
# Quan trọng: Cập nhật nếu IP này thay đổi khi bạn tạo lại container
env:
GITEA_SERVER_IP: "192.168.32.3" # Thay đổi nếu IP của gitea_server khác
steps:
- name: Wait a bit (optional)
run: sleep 5 # Đợi 5 giây phòng trường hợp vẫn do timing
- name: Debug Network Info within Action
- name: Install Network Tools & Debug Info
id: debug_network
run: |
echo "========== Network Debug Info Start =========="
echo "[INFO] Running as user: $(whoami)"
echo "[INFO] Running as user: $(whoami) with ID: $(id)"
echo "[INFO] Runner Environment Variables:"
env
echo "---------------------------------------------"
echo "[INFO] Attempting to install network tools..."
# Cập nhật apt và cài đặt iputils-ping (cho ping) và dnsutils (cho nslookup/dig) và curl
# Sử dụng --no-install-recommends để gọn nhẹ hơn
# Thêm -qq để giảm output, bỏ -qq nếu muốn xem chi tiết quá trình cài đặt
apt-get update -qq && apt-get install -y --no-install-recommends iputils-ping dnsutils curl
echo "[INFO] Tool installation attempt finished."
echo "---------------------------------------------"
echo "[INFO] /etc/resolv.conf:"
cat /etc/resolv.conf || echo "Cannot read resolv.conf"
cat /etc/resolv.conf || echo "[WARN] Cannot read resolv.conf"
echo "---------------------------------------------"
echo "[INFO] /etc/hosts:"
cat /etc/hosts || echo "Cannot read hosts"
cat /etc/hosts || echo "[WARN] Cannot read hosts"
echo "---------------------------------------------"
echo "[INFO] Pinging 'server'..."
echo "[INFO] Pinging 'server' (Hostname)..."
ping -c 3 server || echo "[WARN] Ping 'server' failed"
echo "---------------------------------------------"
echo "[INFO] Pinging 'gitea_server'..."
echo "[INFO] Pinging 'gitea_server' (Container Name)..."
ping -c 3 gitea_server || echo "[WARN] Ping 'gitea_server' failed"
echo "---------------------------------------------"
echo "[INFO] Pinging Gitea Server IP (${{ env.GITEA_SERVER_IP }})..."
ping -c 3 ${{ env.GITEA_SERVER_IP }} || echo "[WARN] Ping Gitea Server IP failed"
echo "---------------------------------------------"
echo "[INFO] nslookup 'server'..."
nslookup server || echo "[WARN] nslookup 'server' failed"
echo "---------------------------------------------"
echo "[INFO] nslookup 'gitea_server'..."
nslookup gitea_server || echo "[WARN] nslookup 'gitea_server' failed"
echo "---------------------------------------------"
# Cố gắng cài đặt dnsutils nếu có thể (có thể thất bại tùy image)
echo "[INFO] Attempting to install dnsutils (might fail)..."
(apt-get update && apt-get install -y dnsutils) || (apk update && apk add bind-tools) || echo "[WARN] Failed to install dnsutils/bind-tools"
echo "[INFO] dig 'server'..."
dig server || echo "[WARN] dig 'server' failed"
echo "---------------------------------------------"
@ -55,17 +68,28 @@ jobs:
echo "[INFO] Checking for proxy env vars..."
env | grep -i proxy || echo "[INFO] No proxy environment variables found."
echo "========== Network Debug Info End =========="
# Continue even if some debug commands fail
continue-on-error: true
# Không đặt continue-on-error nữa, nếu cài tool lỗi thì nên dừng lại
- name: Test Connection with Curl (server)
run: curl -v -f --connect-timeout 10 http://server:3000 || echo "[ERROR] Curl to http://server:3000 failed"
continue-on-error: true # Cho phép các bước sau vẫn chạy dù bước này lỗi
- name: Test Connection with Curl (gitea_server)
run: curl -v -f --connect-timeout 10 http://gitea_server:3000 || echo "[ERROR] Curl to http://gitea_server:3000 failed"
continue-on-error: true
- name: Test Connection with Curl (IP Address)
run: curl -v -f --connect-timeout 10 http://${{ env.GITEA_SERVER_IP }}:3000 || echo "[ERROR] Curl to http://${{ env.GITEA_SERVER_IP }}:3000 failed"
continue-on-error: true
- name: Test Connection with Git (server)
run: git ls-remote http://server:3000/ulflow_phattt2901/matching_app/ || echo "[ERROR] Git ls-remote to http://server:3000 failed"
continue-on-error: true
- name: Test Connection with Git (gitea_server)
run: git ls-remote http://gitea_server:3000/ulflow_phattt2901/matching_app/ || echo "[ERROR] Git ls-remote to http://gitea_server:3000 failed"
run: git ls-remote http://gitea_server:3000/ulflow_phattt2901/matching_app/ || echo "[ERROR] Git ls-remote to http://gitea_server:3000 failed"
continue-on-error: true
- name: Test Connection with Git (IP Address)
run: git ls-remote http://${{ env.GITEA_SERVER_IP }}:3000/ulflow_phattt2901/matching_app/ || echo "[ERROR] Git ls-remote to http://${{ env.GITEA_SERVER_IP }}:3000 failed"
continue-on-error: true