diff --git a/.github/workflows/pr_ci_playwright_e2e.yaml b/.github/workflows/pr_ci_playwright_e2e.yaml index b6ab49f8d..f4331cd62 100644 --- a/.github/workflows/pr_ci_playwright_e2e.yaml +++ b/.github/workflows/pr_ci_playwright_e2e.yaml @@ -9,12 +9,19 @@ jobs: environment: dev steps: - - name: cleanup old checkout - run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*; + - name: Cleanup old checkout + run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/* - name: Checkout uses: actions/checkout@v4 + - name: Ensure .env.dev file exists + run: | + if [ ! -f .env.dev ]; then + echo "Creating .env.dev file" + echo "REACT_APP_API_URL=http://localhost:3000" > .env.dev + fi + - name: Clean up any existing containers run: | docker stop $(docker ps -aq) || true @@ -39,13 +46,16 @@ jobs: - name: Clean Yarn cache working-directory: ./frontend - run: | - sudo yarn cache clean + run: sudo yarn cache clean - name: Install dependencies via Yarn working-directory: ./frontend + run: sudo yarn install + + - name: Verify wait-on installation run: | - sudo yarn install + yarn --version + yarn list wait-on - name: Cache Playwright browsers uses: actions/cache@v3 @@ -61,6 +71,21 @@ jobs: working-directory: ./frontend run: sudo yarn playwright install --with-deps + - name: Ensure gh-pages branch exists + if: always() + run: | + git fetch origin gh-pages + if git rev-parse --verify origin/gh-pages; then + git checkout gh-pages + git reset --hard origin/gh-pages + else + git checkout --orphan gh-pages + git rm -rf . + echo "# GitHub Pages" > index.html + git add index.html + git -c user.name='github-actions[bot]' -c user.email='github-actions[bot]@users.noreply.github.com' commit -m "Initial commit" + git push origin gh-pages + - name: Wait for web server to be ready with retry run: | MAX_ATTEMPTS=3 @@ -69,7 +94,8 @@ jobs: while [[ $ATTEMPT -le $MAX_ATTEMPTS ]] do echo "Attempt $ATTEMPT of $MAX_ATTEMPTS" - if yarn wait-on http://localhost:3000 --timeout ${WAIT_TIME}000; then + echo "Waiting for server for $WAIT_TIME seconds" + if yarn wait-on http://localhost:3000 --timeout ${WAIT_TIME}000 --verbose; then echo "Server is ready!" break else @@ -85,26 +111,9 @@ jobs: fi done - - name: Ensure gh-pages branch exists - if: always() - run: | - git fetch origin gh-pages - if git rev-parse --verify origin/gh-pages; then - git checkout gh-pages - git reset --hard origin/gh-pages - else - git checkout --orphan gh-pages - git rm -rf . - echo "# GitHub Pages" > index.html - git add index.html - git -c user.name='github-actions[bot]' -c user.email='github-actions[bot]@users.noreply.github.com' commit -m "Initial commit" - git push origin gh-pages - fi - - name: Run Playwright tests working-directory: ./frontend - run: | - sudo yarn playwright test --reporter=html + run: sudo yarn playwright test --reporter=html - name: Upload Playwright report if: always()