diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index f5039548e76..f8d459b71c2 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -1,8 +1,6 @@ name: Cypress Tests on: - schedule: - - cron: "30 22 * * *" pull_request: branches: - develop @@ -10,14 +8,10 @@ on: workflow_dispatch: jobs: - cypress-run: + setup: permissions: write-all if: github.repository == 'ohcnetwork/care_fe' runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - containers: [1, 2, 3, 4, 5, 6, 7, 8] steps: - name: Checkout 📥 uses: actions/checkout@v3 @@ -54,17 +48,13 @@ jobs: command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 on_retry_command: sleep 5 - - name: Determine PR Origin - id: pr_origin - run: echo "::set-output name=is_forked::$( echo ${{ github.event.pull_request.head.repo.fork }})" - - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: "20" - name: Install dependencies 📦 - run: npm install + run: npm ci - name: Build & Compile rescript files ⚙️ run: npm run build @@ -75,6 +65,35 @@ jobs: sudo wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo apt-get install ./google-chrome-stable_current_amd64.deb + - name: Cache build artifacts + uses: actions/cache@v3 + with: + path: | + node_modules + dist + key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }} + + cypress-run: + needs: setup + permissions: write-all + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + containers: [1, 2, 3, 4, 5, 6, 7, 8] + steps: + - name: Restore cached build artifacts + uses: actions/cache@v3 + with: + path: | + node_modules + dist + key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }} + + - name: Determine PR Origin + id: pr_origin + run: echo "::set-output name=is_forked::$( echo ${{ github.event.pull_request.head.repo.fork }})" + - name: Cypress run for Non-Forked PRs 🥬 if: steps.pr_origin.outputs.is_forked == 'false' uses: cypress-io/github-action@v5 @@ -82,7 +101,7 @@ jobs: env: SKIP_PREFLIGHT_CHECK=true install: false start: "npx vite preview --host" - wait-on: "http://localhost:4000" + wait-on: "http://localhost:4173" wait-on-timeout: 300 browser: chrome record: true @@ -103,7 +122,7 @@ jobs: env: SKIP_PREFLIGHT_CHECK=true install: false start: "npx vite preview --host" - wait-on: "http://localhost:4000" + wait-on: "http://localhost:4173" wait-on-timeout: 300 browser: chrome record: true