diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index f5039548e76..e9aaf22ce44 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 @@ -30,7 +24,7 @@ jobs: else echo "branch=develop" >> $GITHUB_OUTPUT fi - + - name: Checkout care 📥 uses: actions/checkout@v3 with: @@ -45,7 +39,7 @@ jobs: make docker_config_file=docker-compose.pre-built.yaml up make docker_config_file=docker-compose.pre-built.yaml load-dummy-data cd .. - + - name: Wait for care to be up ♻ uses: nick-fields/retry@v2 with: @@ -54,19 +48,15 @@ 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 ⚙️ + - name: Build files ⚙️ run: npm run build - name: Install Specific Chrome Version @@ -75,6 +65,45 @@ 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 Cypress Binary + uses: actions/cache@v3 + with: + path: ~/.cache/Cypress + key: ${{ runner.os }}-cypress-cache + + - name: Cache build artifacts + uses: actions/cache@v3 + with: + path: | + ./* + key: ${{ runner.os }}-build-${{ github.sha }} + + 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: | + ./* + key: ${{ runner.os }}-build-${{ github.sha }} + + - name: Restore Cypress Cache + uses: actions/cache@v3 + with: + path: ~/.cache/Cypress + key: ${{ runner.os }}-cypress-cache + + - 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 @@ -132,4 +161,4 @@ jobs: if: steps.pr_origin.outputs.is_forked == 'true' with: name: cypress-videos - path: cypress/videos + path: cypress/videos \ No newline at end of file