|
| 1 | +name: Acceptance Code Quality Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + base-tag: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + node-version: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + |
| 13 | + artifacts-folder: |
| 14 | + required: false |
| 15 | + type: string |
| 16 | + default: frontend/cypress |
| 17 | + name: |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + default: Acceptance Tests |
| 21 | + spec-folder: |
| 22 | + required: false |
| 23 | + type: string |
| 24 | + default: frontend/cypress/tests |
| 25 | + spec-pattern: |
| 26 | + required: false |
| 27 | + type: string |
| 28 | + default: '**/*.cy.{js,jsx,ts,tsx}' |
| 29 | + api-url: |
| 30 | + required: false |
| 31 | + type: string |
| 32 | + default: 'localhost:55001/plone' |
| 33 | + site-url: |
| 34 | + required: false |
| 35 | + type: string |
| 36 | + default: 'localhost:3000' |
| 37 | + test-profile: |
| 38 | + required: false |
| 39 | + type: string |
| 40 | + default: acceptance |
| 41 | + |
| 42 | +env: |
| 43 | + CYPRESS_RETRIES: 2 |
| 44 | + |
| 45 | +jobs: |
| 46 | + acceptance: |
| 47 | + name: ${{ inputs.name }} |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Load images needed for acceptance tests |
| 53 | + env: |
| 54 | + BASE_TAG: ${{ inputs.base-tag }} |
| 55 | + COMPOSE_PROFILES: ${{ inputs.test-profile }} |
| 56 | + run: | |
| 57 | + make ci-images-load |
| 58 | +
|
| 59 | + - name: Use Node.js ${{ inputs.node-version }} |
| 60 | + uses: actions/setup-node@v4 |
| 61 | + with: |
| 62 | + node-version: ${{ inputs.node-version }} |
| 63 | + |
| 64 | + - name: Enable corepack |
| 65 | + run: npm i -g corepack@latest && corepack enable |
| 66 | + |
| 67 | + - name: Get pnpm store directory |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 71 | +
|
| 72 | + - uses: actions/cache@v4 |
| 73 | + name: Setup pnpm cache |
| 74 | + with: |
| 75 | + path: ${{ env.STORE_PATH }} |
| 76 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml', 'package.json') }} |
| 77 | + restore-keys: | |
| 78 | + ${{ runner.os }}-pnpm-store- |
| 79 | +
|
| 80 | + - name: Cache Cypress Binary |
| 81 | + id: cache-cypress-binary |
| 82 | + uses: actions/cache@v4 |
| 83 | + with: |
| 84 | + path: ~/.cache/Cypress |
| 85 | + key: Cypress-binary-${{ inputs.node-version }}-${{ hashFiles('frontend/pnpm-lock.yaml', 'frontend/package.json') }} |
| 86 | + |
| 87 | + - name: Install dependencies |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + make frontend-install |
| 91 | +
|
| 92 | + - name: Install Cypress if not in cache |
| 93 | + if: steps.cache-cypress-binary.outputs.cache-hit != 'true' |
| 94 | + working-directory: ./frontend/core/packages/volto |
| 95 | + shell: bash |
| 96 | + run: make cypress-install |
| 97 | + |
| 98 | + - uses: JarvusInnovations/background-action@v1 |
| 99 | + name: Start Servers |
| 100 | + with: |
| 101 | + run: | |
| 102 | + BASE_TAG=${{ inputs.base-tag }} COMPOSE_PROFILES=${{ inputs.test-profile }} make ci-containers-start & |
| 103 | +
|
| 104 | + wait-on: | |
| 105 | + http-get://${{ inputs.api-url }} |
| 106 | + http://${{ inputs.site-url }} |
| 107 | +
|
| 108 | + tail: true |
| 109 | + log-output-resume: stderr |
| 110 | + wait-for: 10m |
| 111 | + log-output: stderr,stdout |
| 112 | + log-output-if: failure |
| 113 | + |
| 114 | + - name: Run Tests |
| 115 | + shell: bash |
| 116 | + env: |
| 117 | + CYPRESS_SPEC_PATTERN: ${{ github.workspace }}/${{ inputs.spec-folder }}/${{ inputs.spec-pattern }} |
| 118 | + BASE_TAG: ${{ inputs.base-tag }} |
| 119 | + COMPOSE_PROFILES: ${{ inputs.test-profile }} |
| 120 | + run: | |
| 121 | + make ci-test |
| 122 | +
|
| 123 | + - uses: actions/upload-artifact@v4 |
| 124 | + if: failure() |
| 125 | + with: |
| 126 | + name: cypress-screenshots-acceptance-${{ inputs.name }} |
| 127 | + path: ${{ inputs.artifacts-folder }}/screenshots |
| 128 | + |
| 129 | + - uses: actions/upload-artifact@v4 |
| 130 | + if: failure() |
| 131 | + with: |
| 132 | + name: cypress-videos-acceptance-${{ inputs.name }} |
| 133 | + path: ${{ inputs.artifacts-folder }}/videos |
0 commit comments