Alanxtl commented on code in PR #854:
URL: https://github.com/apache/dubbo-go-pixiu/pull/854#discussion_r2649738850


##########
.github/workflows/pixiu-admin-ci.yml:
##########
@@ -0,0 +1,546 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Pixiu-Admin CI
+
+on:
+  push:
+    branches: [ main, develop ]
+    paths:
+      - 'admin/**'
+      - 'docker-compose.yml'
+      - '.github/workflows/pixiu-admin-ci.yml'
+  pull_request:
+    branches: [ main, develop ]
+    paths:
+      - 'admin/**'
+      - 'docker-compose.yml'
+      - '.github/workflows/pixiu-admin-ci.yml'
+
+jobs:
+  # Build and test backend
+  backend-build:
+    name: Build Admin Backend
+    runs-on: ubuntu-latest
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Set up Go
+      uses: actions/setup-go@v5
+      with:
+        go-version: '1.23'
+        
+    - name: Cache Go modules
+      uses: actions/cache@v4
+      with:
+        path: |
+          ~/.cache/go-build
+          ~/go/pkg/mod
+        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
+        restore-keys: |
+          ${{ runner.os }}-go-
+          
+    - name: Download dependencies
+      run: |
+        go mod download
+        go mod verify
+        
+    - name: Build admin binary
+      run: |
+        go build -v -o pixiu-admin ./cmd/admin/admin.go
+        
+    - name: Run Go tests
+      run: |
+        go test -v -race -coverprofile=coverage.out -covermode=atomic 
./admin/...

Review Comment:
   I think current CI go test has covered `./admin` dir, what about exclude 
this dir in `.github/workflows/github-actions.yml`



##########
.github/workflows/pixiu-admin-ci.yml:
##########
@@ -0,0 +1,546 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Pixiu-Admin CI
+
+on:
+  push:
+    branches: [ main, develop ]
+    paths:
+      - 'admin/**'
+      - 'docker-compose.yml'
+      - '.github/workflows/pixiu-admin-ci.yml'
+  pull_request:
+    branches: [ main, develop ]
+    paths:
+      - 'admin/**'
+      - 'docker-compose.yml'
+      - '.github/workflows/pixiu-admin-ci.yml'
+
+jobs:
+  # Build and test backend
+  backend-build:
+    name: Build Admin Backend
+    runs-on: ubuntu-latest
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Set up Go
+      uses: actions/setup-go@v5
+      with:
+        go-version: '1.23'
+        
+    - name: Cache Go modules
+      uses: actions/cache@v4
+      with:
+        path: |
+          ~/.cache/go-build
+          ~/go/pkg/mod
+        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
+        restore-keys: |
+          ${{ runner.os }}-go-
+          
+    - name: Download dependencies
+      run: |
+        go mod download
+        go mod verify
+        
+    - name: Build admin binary
+      run: |
+        go build -v -o pixiu-admin ./cmd/admin/admin.go
+        
+    - name: Run Go tests
+      run: |
+        go test -v -race -coverprofile=coverage.out -covermode=atomic 
./admin/...
+        
+    - name: Upload coverage to Codecov
+      uses: codecov/codecov-action@v4
+      with:
+        files: ./coverage.out
+        flags: admin-backend
+        name: admin-backend-coverage
+
+  # Build and test frontend
+  frontend-build:
+    name: Build Admin Frontend
+    runs-on: ubuntu-latest
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Set up Node.js
+      uses: actions/setup-node@v4
+      with:
+        node-version: '18'
+        
+    - name: Cache node modules
+      uses: actions/cache@v4
+      with:
+        path: |
+          admin/web/node_modules
+          ~/.yarn
+        key: ${{ runner.os }}-yarn-${{ hashFiles('admin/web/yarn.lock') }}
+        restore-keys: |
+          ${{ runner.os }}-yarn-
+          
+    - name: Install dependencies
+      run: |
+        cd admin/web
+        yarn install
+        
+    - name: Run linter
+      run: |
+        cd admin/web
+        yarn lint || true
+        
+    - name: Run unit tests
+      run: |
+        cd admin/web
+        yarn test:unit || true
+        
+    - name: Build frontend
+      run: |
+        cd admin/web
+        yarn build
+        
+    - name: Upload build artifacts
+      uses: actions/upload-artifact@v4
+      with:
+        name: frontend-dist
+        path: admin/web/dist/
+        retention-days: 7
+
+  # Docker Compose deployment test
+  docker-compose-test:
+    name: Docker Compose Deployment Test
+    runs-on: ubuntu-latest
+    needs: [backend-build, frontend-build]
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Check if docker-compose.yml exists
+      run: |
+        if [ ! -f docker-compose.yml ]; then
+          echo "⚠️ docker-compose.yml not found in root directory"
+          echo "Skipping docker-compose tests"
+          exit 0
+        fi
+        
+    - name: Start services with docker-compose
+      run: |
+        # Start etcd and any other services defined in docker-compose
+        docker-compose up -d
+        
+    - name: Wait for etcd to be ready
+      run: |
+        echo "Waiting for etcd to be ready..."
+        timeout 60 bash -c 'until docker ps | grep etcd | grep -q "Up"; do 
sleep 2; done'
+        
+        # Test etcd health
+        sleep 10
+        curl -sf http://localhost:2379/health || exit 1
+        
+    - name: Show running containers
+      run: |
+        echo "=== Running Docker Containers ==="
+        docker ps
+        
+    - name: Show docker-compose services
+      if: always()
+      run: |
+        docker-compose ps || true
+        
+    - name: Show service logs on failure
+      if: failure()
+      run: |
+        echo "=== Docker Compose Logs ==="
+        docker-compose logs || true
+        
+    - name: Stop services
+      if: always()
+      run: |
+        docker-compose down -v
+
+  # Integration tests with database
+  integration-tests:
+    name: Integration Tests
+    runs-on: ubuntu-latest
+    needs: [backend-build]
+    
+    services:
+      mysql:
+        image: mysql:8.0
+        env:
+          MYSQL_ROOT_PASSWORD: root
+          MYSQL_DATABASE: pixiu
+        ports:
+          - 3306:3306
+        options: >-
+          --health-cmd="mysqladmin ping"
+          --health-interval=10s
+          --health-timeout=5s
+          --health-retries=3
+          
+      etcd:
+        image: quay.io/coreos/etcd:v3.6.1
+        env:
+          ALLOW_NONE_AUTHENTICATION: yes
+          ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
+          ETCD_ADVERTISE_CLIENT_URLS: http://localhost:2379
+        ports:
+          - 2379:2379
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Set up Go
+      uses: actions/setup-go@v5
+      with:
+        go-version: '1.23'
+        
+    - name: Initialize database
+      run: |
+        mysql -h 127.0.0.1 -u root -proot pixiu < 
admin/resources/sql/pixiu_demo.sql
+        
+    - name: Create test config
+      run: |
+        cat > /tmp/test-config.yaml <<EOF
+        server:
+          address: "127.0.0.1:8081"
+        etcd:
+          address: "127.0.0.1:2379"
+          path: "/pixiu/config/api"
+        mysql:
+          username: "root"
+          password: "root"
+          host: "127.0.0.1"
+          port: "3306"
+          dbname: "pixiu"
+        EOF
+        
+    - name: Run integration tests
+      run: |
+        go test -v -tags=integration ./admin/... || true
+        
+    - name: Test API operations
+      run: |
+        # Start admin server in background
+        go run ./cmd/admin/admin.go -c /tmp/test-config.yaml &
+        ADMIN_PID=$!
+        
+        # Wait for server to start
+        sleep 10
+        
+        # Test resource creation
+        cat > /tmp/resource.yaml <<'EOFRESOURCE'
+        path: '/test'
+        type: restful
+        description: test resource
+        EOFRESOURCE
+        
+        curl -X POST http://localhost:8081/config/api/resource \
+          -H "Content-Type: multipart/form-data" \
+          -F "content=@/tmp/resource.yaml"
+        
+        # Test resource list
+        curl http://localhost:8081/config/api/resource/list
+        
+        # Cleanup
+        kill $ADMIN_PID || true
+
+  # Manual deployment test (following README instructions)
+  manual-deployment-test:
+    name: Manual Deployment Test
+    runs-on: ubuntu-latest
+    needs: [backend-build]
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Set up Go
+      uses: actions/setup-go@v5
+      with:
+        go-version: '1.23'
+        
+    - name: Set up Node.js
+      uses: actions/setup-node@v4
+      with:
+        node-version: '18'
+        
+    - name: Start etcd service
+      run: |
+        docker run -d -p 2379:2379 \
+          --env ALLOW_NONE_AUTHENTICATION=yes \
+          --env ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 \
+          --env ETCD_ADVERTISE_CLIENT_URLS=http://localhost:2379 \
+          --name etcd \
+          quay.io/coreos/etcd:v3.6.1
+          
+    - name: Wait for etcd to be ready
+      run: |
+        echo "Waiting for etcd..."
+        timeout 60 bash -c 'until curl -sf http://localhost:2379/health 
2>/dev/null; do sleep 2; done'
+        echo "✅ Etcd is ready"
+        
+    - name: Create test config file
+      run: |
+        mkdir -p /tmp/admin-test
+        cat > /tmp/admin-test/conf.yaml <<'EOF'
+        server:
+          address: "127.0.0.1:8081"
+        etcd:
+          address: "127.0.0.1:2379"
+          path: "/pixiu/config/api"
+        mysql:
+          username: "root"
+          password: "root"
+          host: "127.0.0.1"
+          port: "3306"
+          dbname: "pixiu"
+        zap:
+          level: "info"
+          format: "console"
+          prefix: "[PIXIU-ADMIN]"
+          director: "/tmp/logs"
+          linkName: "latest.log"
+          showLine: true
+          encodeLevel: "LowercaseColorLevelEncoder"
+          stacktraceKey: "stacktrace"
+          logInConsole: true
+        system:
+          env: "develop"
+          addr: 8081
+          dbType: "mysql"
+        EOF
+        
+    - name: Build admin binary
+      run: |
+        go build -v -o /tmp/admin-test/pixiu-admin ./cmd/admin/admin.go
+        
+    - name: Start admin service in background
+      run: |
+        cd /tmp/admin-test
+        mkdir -p /tmp/logs
+        nohup ./pixiu-admin -c conf.yaml > /tmp/logs/admin.log 2>&1 &
+        echo $! > /tmp/admin.pid
+        echo "Admin PID: $(cat /tmp/admin.pid)"
+        
+    - name: Wait for admin service to be ready
+      run: |
+        echo "Waiting for admin service..."
+        for i in {1..30}; do
+          if curl -f http://localhost:8081/config/api/base 2>/dev/null; then
+            echo "✅ Admin service is ready"
+            exit 0
+          fi
+          echo "Attempt $i/30 - waiting..."
+          sleep 2
+        done
+        echo "❌ Admin service failed to start"
+        cat /tmp/logs/admin.log
+        exit 1
+        
+    - name: Test admin API endpoints
+      run: |
+        echo "Testing base info endpoint..."
+        curl -f http://localhost:8081/config/api/base
+        
+        echo -e "\nTesting resource list endpoint..."
+        curl -f http://localhost:8081/config/api/resource/list
+        
+        echo -e "\nTesting cluster list endpoint..."
+        curl -f http://localhost:8081/config/api/cluster/list
+        
+        echo -e "\nTesting listener list endpoint..."
+        curl -f http://localhost:8081/config/api/listener/list
+        
+    - name: Build frontend
+      run: |
+        cd admin/web
+        yarn install
+        yarn build
+        
+    - name: Verify frontend build output
+      run: |
+        ls -la admin/web/dist/
+        test -d admin/web/dist/ || exit 1
+        
+    - name: Show logs on failure
+      if: failure()
+      run: |
+        echo "=== Admin Service Logs ==="
+        cat /tmp/logs/admin.log || echo "No logs found"
+        
+        echo -e "\n=== Etcd Status ==="
+        docker logs etcd || echo "No etcd logs"
+        
+    - name: Cleanup
+      if: always()
+      run: |
+        if [ -f /tmp/admin.pid ]; then
+          kill $(cat /tmp/admin.pid) || true
+        fi
+        docker stop etcd || true
+        docker rm etcd || true
+
+  # Security and code quality checks
+  code-quality:
+    name: Code Quality & Security
+    runs-on: ubuntu-latest
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Set up Go
+      uses: actions/setup-go@v5
+      with:
+        go-version: '1.23'
+        
+    - name: Run golangci-lint
+      uses: golangci/golangci-lint-action@v6
+      with:
+        version: latest
+        working-directory: .
+        args: --timeout=5m ./admin/...

Review Comment:
   all of these checkout->setup->lint steps reference following style:
   ```
     golangci:
       needs: license-check-and-import-format
       name: Golang Lint
       runs-on: ubuntu-latest
       steps:
         - uses: actions/checkout@v5
         - uses: actions/setup-go@v6
           with:
             go-version-file: 'go.mod'
             cache: true
         - name: golangci-lint
           uses: golangci/golangci-lint-action@v8 # NOSONAR
           with:
             version: v2.4.0
   ```



##########
.github/workflows/pixiu-admin-ci.yml:
##########
@@ -0,0 +1,546 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Pixiu-Admin CI
+
+on:
+  push:
+    branches: [ main, develop ]
+    paths:
+      - 'admin/**'
+      - 'docker-compose.yml'
+      - '.github/workflows/pixiu-admin-ci.yml'
+  pull_request:
+    branches: [ main, develop ]
+    paths:
+      - 'admin/**'
+      - 'docker-compose.yml'
+      - '.github/workflows/pixiu-admin-ci.yml'
+
+jobs:
+  # Build and test backend
+  backend-build:
+    name: Build Admin Backend
+    runs-on: ubuntu-latest
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Set up Go
+      uses: actions/setup-go@v5
+      with:
+        go-version: '1.23'
+        
+    - name: Cache Go modules
+      uses: actions/cache@v4
+      with:
+        path: |
+          ~/.cache/go-build
+          ~/go/pkg/mod
+        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
+        restore-keys: |
+          ${{ runner.os }}-go-
+          
+    - name: Download dependencies
+      run: |
+        go mod download
+        go mod verify
+        
+    - name: Build admin binary
+      run: |
+        go build -v -o pixiu-admin ./cmd/admin/admin.go
+        
+    - name: Run Go tests
+      run: |
+        go test -v -race -coverprofile=coverage.out -covermode=atomic 
./admin/...
+        
+    - name: Upload coverage to Codecov
+      uses: codecov/codecov-action@v4
+      with:
+        files: ./coverage.out
+        flags: admin-backend
+        name: admin-backend-coverage
+
+  # Build and test frontend
+  frontend-build:
+    name: Build Admin Frontend
+    runs-on: ubuntu-latest
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Set up Node.js
+      uses: actions/setup-node@v4
+      with:
+        node-version: '18'
+        
+    - name: Cache node modules
+      uses: actions/cache@v4
+      with:
+        path: |
+          admin/web/node_modules
+          ~/.yarn
+        key: ${{ runner.os }}-yarn-${{ hashFiles('admin/web/yarn.lock') }}
+        restore-keys: |
+          ${{ runner.os }}-yarn-
+          
+    - name: Install dependencies
+      run: |
+        cd admin/web
+        yarn install
+        
+    - name: Run linter
+      run: |
+        cd admin/web
+        yarn lint || true
+        
+    - name: Run unit tests
+      run: |
+        cd admin/web
+        yarn test:unit || true
+        
+    - name: Build frontend
+      run: |
+        cd admin/web
+        yarn build
+        
+    - name: Upload build artifacts
+      uses: actions/upload-artifact@v4
+      with:
+        name: frontend-dist
+        path: admin/web/dist/
+        retention-days: 7
+
+  # Docker Compose deployment test
+  docker-compose-test:
+    name: Docker Compose Deployment Test
+    runs-on: ubuntu-latest
+    needs: [backend-build, frontend-build]
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Check if docker-compose.yml exists
+      run: |
+        if [ ! -f docker-compose.yml ]; then
+          echo "⚠️ docker-compose.yml not found in root directory"
+          echo "Skipping docker-compose tests"
+          exit 0
+        fi
+        
+    - name: Start services with docker-compose
+      run: |
+        # Start etcd and any other services defined in docker-compose
+        docker-compose up -d
+        
+    - name: Wait for etcd to be ready
+      run: |
+        echo "Waiting for etcd to be ready..."
+        timeout 60 bash -c 'until docker ps | grep etcd | grep -q "Up"; do 
sleep 2; done'
+        
+        # Test etcd health
+        sleep 10
+        curl -sf http://localhost:2379/health || exit 1
+        
+    - name: Show running containers
+      run: |
+        echo "=== Running Docker Containers ==="
+        docker ps
+        
+    - name: Show docker-compose services
+      if: always()
+      run: |
+        docker-compose ps || true
+        
+    - name: Show service logs on failure
+      if: failure()
+      run: |
+        echo "=== Docker Compose Logs ==="
+        docker-compose logs || true
+        
+    - name: Stop services
+      if: always()
+      run: |
+        docker-compose down -v
+
+  # Integration tests with database
+  integration-tests:
+    name: Integration Tests
+    runs-on: ubuntu-latest
+    needs: [backend-build]
+    
+    services:
+      mysql:
+        image: mysql:8.0
+        env:
+          MYSQL_ROOT_PASSWORD: root
+          MYSQL_DATABASE: pixiu
+        ports:
+          - 3306:3306
+        options: >-
+          --health-cmd="mysqladmin ping"
+          --health-interval=10s
+          --health-timeout=5s
+          --health-retries=3
+          
+      etcd:
+        image: quay.io/coreos/etcd:v3.6.1
+        env:
+          ALLOW_NONE_AUTHENTICATION: yes
+          ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
+          ETCD_ADVERTISE_CLIENT_URLS: http://localhost:2379
+        ports:
+          - 2379:2379
+    
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      
+    - name: Set up Go
+      uses: actions/setup-go@v5
+      with:
+        go-version: '1.23'
+        
+    - name: Initialize database
+      run: |
+        mysql -h 127.0.0.1 -u root -proot pixiu < 
admin/resources/sql/pixiu_demo.sql
+        
+    - name: Create test config
+      run: |
+        cat > /tmp/test-config.yaml <<EOF
+        server:
+          address: "127.0.0.1:8081"
+        etcd:
+          address: "127.0.0.1:2379"
+          path: "/pixiu/config/api"
+        mysql:
+          username: "root"
+          password: "root"
+          host: "127.0.0.1"
+          port: "3306"
+          dbname: "pixiu"
+        EOF
+        
+    - name: Run integration tests
+      run: |
+        go test -v -tags=integration ./admin/... || true

Review Comment:
   what integration tests does `./admin` have? I don't think there is  any 
integration test in `./admin` dir



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to