fix: 修复新增和编辑部门无法使用已删除的部门名称问题 (#60) #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Playwright Tests | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| mysql-test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache Docker layers | |
| uses: actions/cache@v5 | |
| with: | |
| path: /tmp/.docker_cache | |
| key: ${{ runner.os }}-docker-${{ matrix.python-version }}-${{ hashFiles('**/Dockerfile*', '**/requirements.txt') }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Create temporary Dockerfile with Python ${{ matrix.python-version }} | |
| run: | | |
| # Save original Dockerfile.my | |
| cp ruoyi-fastapi-backend/Dockerfile.my ruoyi-fastapi-backend/Dockerfile.my.bak | |
| # Create temporary Dockerfile with target Python version | |
| sed "s/FROM python:3.10/FROM python:${{ matrix.python-version }}/g" ruoyi-fastapi-backend/Dockerfile.my.bak > ruoyi-fastapi-backend/Dockerfile.my | |
| - name: Start services with docker-compose | |
| run: | | |
| cd ruoyi-fastapi-test | |
| docker compose -f docker-compose.test.my.yml up -d --build | |
| - name: Wait for services to be ready | |
| run: | | |
| cd ruoyi-fastapi-test | |
| # Wait for backend to be running | |
| timeout 180 bash -c 'until docker compose -f docker-compose.test.my.yml ps ruoyi-backend-my | grep -q "Up"; do sleep 5; done' | |
| # Wait for frontend to be running | |
| timeout 120 bash -c 'until docker compose -f docker-compose.test.my.yml ps ruoyi-frontend | grep -q "Up"; do sleep 5; done' | |
| # Additional wait for services to be fully ready and listening on ports | |
| sleep 30 | |
| # Check that backend is actually responding on the API endpoint | |
| echo "Checking if backend service is ready..." | |
| for i in {1..30}; do | |
| if curl -f http://localhost:9099/captchaImage > /dev/null 2>&1; then | |
| echo "Backend service is ready!" | |
| break | |
| fi | |
| echo "Waiting for backend service to be ready... ($i/30)" | |
| sleep 5 | |
| done | |
| # Final check | |
| if ! curl -f http://localhost:9099/captchaImage > /dev/null 2>&1; then | |
| echo "Backend service failed to start properly. Checking logs..." | |
| docker logs ruoyi-backend-my-test | |
| exit 1 | |
| fi | |
| - name: Run tests | |
| run: | | |
| cd ruoyi-fastapi-test | |
| pip install -r requirements.txt | |
| playwright install | |
| pytest -v | |
| - name: Stop services | |
| if: always() | |
| run: | | |
| cd ruoyi-fastapi-test | |
| docker compose -f docker-compose.test.my.yml down | |
| - name: Restore original Dockerfile.my | |
| if: always() | |
| run: | | |
| # Restore original Dockerfile.my after test | |
| mv ruoyi-fastapi-backend/Dockerfile.my.bak ruoyi-fastapi-backend/Dockerfile.my | |
| pg-test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache Docker layers | |
| uses: actions/cache@v5 | |
| with: | |
| path: /tmp/.docker_cache | |
| key: ${{ runner.os }}-docker-${{ matrix.python-version }}-${{ hashFiles('**/Dockerfile*', '**/requirements.txt') }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Create temporary Dockerfile with Python ${{ matrix.python-version }} | |
| run: | | |
| # Save original Dockerfile.my | |
| cp ruoyi-fastapi-backend/Dockerfile.my ruoyi-fastapi-backend/Dockerfile.my.bak | |
| # Create temporary Dockerfile with target Python version | |
| sed "s/FROM python:3.10/FROM python:${{ matrix.python-version }}/g" ruoyi-fastapi-backend/Dockerfile.my.bak > ruoyi-fastapi-backend/Dockerfile.my | |
| - name: Start services with docker-compose | |
| run: | | |
| cd ruoyi-fastapi-test | |
| docker compose -f docker-compose.test.pg.yml up -d --build | |
| - name: Wait for services to be ready | |
| run: | | |
| cd ruoyi-fastapi-test | |
| # Wait for backend to be running | |
| timeout 180 bash -c 'until docker compose -f docker-compose.test.pg.yml ps ruoyi-backend-pg | grep -q "Up"; do sleep 5; done' | |
| # Wait for frontend to be running | |
| timeout 120 bash -c 'until docker compose -f docker-compose.test.pg.yml ps ruoyi-frontend | grep -q "Up"; do sleep 5; done' | |
| # Additional wait for services to be fully ready and listening on ports | |
| sleep 30 | |
| # Check that backend is actually responding on the API endpoint | |
| echo "Checking if backend service is ready..." | |
| for i in {1..30}; do | |
| if curl -f http://localhost:9099/captchaImage > /dev/null 2>&1; then | |
| echo "Backend service is ready!" | |
| break | |
| fi | |
| echo "Waiting for backend service to be ready... ($i/30)" | |
| sleep 5 | |
| done | |
| # Final check | |
| if ! curl -f http://localhost:9099/captchaImage > /dev/null 2>&1; then | |
| echo "Backend service failed to start properly. Checking logs..." | |
| docker logs ruoyi-backend-pg-test | |
| exit 1 | |
| fi | |
| - name: Run tests | |
| run: | | |
| cd ruoyi-fastapi-test | |
| pip install -r requirements.txt | |
| playwright install | |
| pytest -v | |
| - name: Stop services | |
| if: always() | |
| run: | | |
| cd ruoyi-fastapi-test | |
| docker compose -f docker-compose.test.pg.yml down | |
| - name: Restore original Dockerfile.my | |
| if: always() | |
| run: | | |
| # Restore original Dockerfile.my after test | |
| mv ruoyi-fastapi-backend/Dockerfile.my.bak ruoyi-fastapi-backend/Dockerfile.my |