|
1 | 1 | name: Acceptance tests |
2 | | -on: [push] |
| 2 | +on: |
| 3 | + push: |
| 4 | + paths: |
| 5 | + - "*.js" |
| 6 | + - "*.json" |
| 7 | + - "*.yaml" |
| 8 | + - "cypress/**" |
| 9 | + - "packages/**" |
3 | 10 |
|
4 | 11 | env: |
5 | | - ADDON_NAME: "@plonegovbr/volto-code-block" |
6 | | - ADDON_PATH: "volto-code-block" |
7 | | - VOLTO_VERSION: "17" |
| 12 | + NODE_VERSION: 20.x |
| 13 | + CYPRESS_RETRIES: 2 |
8 | 14 |
|
9 | 15 | jobs: |
10 | 16 |
|
11 | 17 | acceptance: |
12 | 18 | runs-on: ubuntu-latest |
13 | 19 | steps: |
14 | | - - name: Checkout |
15 | | - uses: actions/checkout@v4 |
| 20 | + - uses: actions/checkout@v4 |
16 | 21 |
|
17 | | - - name: Set up Docker Buildx |
18 | | - uses: docker/setup-buildx-action@v3 |
| 22 | + - name: Use Node.js |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: ${{ env.NODE_VERSION }} |
| 26 | + |
| 27 | + - uses: pnpm/action-setup@v3 |
| 28 | + name: Install pnpm |
| 29 | + with: |
| 30 | + version: 8 |
| 31 | + # We don't want to install until later, |
| 32 | + # when the cache and Cypress are in place |
| 33 | + run_install: false |
19 | 34 |
|
20 | | - - name: Install Cypress |
| 35 | + - name: Get pnpm store directory |
| 36 | + shell: bash |
21 | 37 | run: | |
22 | | - cd acceptance |
23 | | - yarn |
24 | | - - name: "Cypress: Acceptance tests" |
25 | | - uses: cypress-io/github-action@v4 |
26 | | - env: |
27 | | - BABEL_ENV: production |
28 | | - CYPRESS_RETRIES: 2 |
| 38 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 39 | +
|
| 40 | + - uses: actions/cache@v4 |
| 41 | + name: Setup pnpm cache |
29 | 42 | with: |
30 | | - parallel: false |
31 | | - browser: chrome |
32 | | - working-directory: acceptance |
33 | | - spec: cypress/tests/*.js |
34 | | - install: false |
35 | | - start: | |
36 | | - docker compose -f ci.yml --profile prod up |
37 | | - wait-on: 'npx wait-on --httpTimeout 20000 http-get://localhost:55001/plone http://localhost:3000' |
| 43 | + path: ${{ env.STORE_PATH }} |
| 44 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 45 | + restore-keys: | |
| 46 | + ${{ runner.os }}-pnpm-store- |
| 47 | +
|
| 48 | + - name: Cache Cypress Binary |
| 49 | + id: cache-cypress-binary |
| 50 | + uses: actions/cache@v4 |
| 51 | + with: |
| 52 | + path: ~/.cache/Cypress |
| 53 | + key: binary-${{ env.NODE_VERSION }}-${{ hashFiles('pnpm-lock.yaml') }} |
| 54 | + |
| 55 | + - name: Install dependencies |
| 56 | + run: make install |
| 57 | + |
| 58 | + - name: Install Cypress if not in cache |
| 59 | + if: steps.cache-cypress-binary.outputs.cache-hit != 'true' |
| 60 | + working-directory: core/packages/volto |
| 61 | + run: make cypress-install |
| 62 | + |
| 63 | + - uses: JarvusInnovations/background-action@v1 |
| 64 | + name: Start Servers |
| 65 | + with: |
| 66 | + run: | |
| 67 | + make start-test-acceptance-server-ci & |
| 68 | + make start-test-acceptance-frontend & |
| 69 | + # your step-level and job-level environment variables are available to your commands as-is |
| 70 | + # npm install will count towards the wait-for timeout |
| 71 | + # whenever possible, move unrelated scripts to a different step |
| 72 | + # to background multiple processes: add & to the end of the command |
| 73 | + |
| 74 | + wait-on: | |
| 75 | + http-get://localhost:55001/plone |
| 76 | + http://localhost:3000 |
| 77 | + # IMPORTANT: to use environment variables in wait-on, you must use this form: ${{ env.VAR }} |
| 78 | + # See wait-on section below for all resource types and prefixes |
| 79 | + |
| 80 | + tail: true # true = stderr,stdout |
| 81 | + # This will allow you to monitor the progress live |
| 82 | + |
| 83 | + log-output-resume: stderr |
| 84 | + # Eliminates previosuly output stderr log entries from post-run output |
| 85 | + |
| 86 | + wait-for: 10m |
| 87 | + |
| 88 | + log-output: stderr,stdout # same as true |
| 89 | + |
| 90 | + log-output-if: failure |
| 91 | + |
| 92 | + - run: make test-acceptance-headless |
38 | 93 |
|
39 | 94 | # Upload Cypress screenshots |
40 | | - - uses: actions/upload-artifact@v3 |
| 95 | + - uses: actions/upload-artifact@v4 |
41 | 96 | if: failure() |
42 | 97 | with: |
43 | 98 | name: cypress-screenshots-acceptance |
44 | 99 | path: acceptance/cypress/screenshots |
45 | 100 |
|
46 | 101 | # Upload Cypress videos |
47 | | - - uses: actions/upload-artifact@v3 |
| 102 | + - uses: actions/upload-artifact@v4 |
48 | 103 | if: failure() |
49 | 104 | with: |
50 | 105 | name: cypress-videos-acceptance |
|
0 commit comments