refactor: move FullWidthWrapper to app
#1693
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: App Frontend - Cypress | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize, ready_for_review, converted_to_draft, closed] | |
| paths: | |
| - 'src/App/backend/**' | |
| - 'src/App/codelists/**' | |
| - 'src/App/fileanalyzers/**' | |
| - 'src/Runtime/localtest/**' | |
| - 'src/Runtime/pdf3/**' | |
| - 'src/App/frontend/src/**' | |
| - 'src/App/frontend/test/**' | |
| - 'src/App/frontend/package.json' | |
| - 'src/test/apps/**' | |
| - 'libs/form-component/src/**' | |
| - 'libs/form-component/package.json' | |
| - '.github/actions/**' | |
| - '.github/workflows/app-frontend-cypress.yml' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }} | |
| cancel-in-progress: true | |
| env: | |
| CYPRESS_BROWSER_IMAGE: cypress/browsers:node-22.13.1-chrome-133.0.6943.53-1-ff-135.0-edge-132.0.2957.140-1@sha256:914c9814a9567f32660203db7ecd610b8f8fede6e9103885728b3bd3f6dca4ff | |
| APP_TEST_IMAGE_REPOSITORY: ghcr.io/altinn/altinn-studio/localtest-app | |
| jobs: | |
| build-frontend: | |
| if: ${{ github.event_name != 'pull_request' || (github.event.action != 'closed' && !github.event.pull_request.draft) }} | |
| name: Build Frontend | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Build frontend | |
| uses: ./.github/actions/app-build-frontend | |
| build-app-images: | |
| name: Build App Images | |
| if: | | |
| (github.event_name != 'pull_request' || (github.event.action != 'closed' && !github.event.pull_request.draft)) && | |
| github.repository_owner == 'Altinn' && | |
| ( | |
| (github.event_name != 'pull_request' && github.event.repository.fork == false) || | |
| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) | |
| ) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| outputs: | |
| app-run-targets-json: ${{ steps.build-app-images.outputs.app-run-targets-json }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Setup studioctl | |
| uses: ./.github/actions/setup-studioctl | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Build and push app images | |
| id: build-app-images | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 | |
| env: | |
| APP_TEST_IMAGE_REPOSITORY: ${{ env.APP_TEST_IMAGE_REPOSITORY }} | |
| STUDIOCTL_REGISTRY_CACHE_WRITE: 'true' | |
| with: | |
| script: | | |
| const fs = require('fs/promises'); | |
| const nodePath = require('path'); | |
| const maxParallelBuilds = 4; | |
| const appRoot = 'src/test/apps'; | |
| const repository = process.env.APP_TEST_IMAGE_REPOSITORY; | |
| const tagSuffix = `${process.env.GITHUB_SHA.slice(0, 12)}-${process.env.GITHUB_RUN_ID}-${process.env.GITHUB_RUN_ATTEMPT}`; | |
| const entries = await fs.readdir(appRoot, { withFileTypes: true }); | |
| const targets = entries | |
| .filter(entry => entry.isDirectory()) | |
| .sort((a, b) => a.name.localeCompare(b.name)) | |
| .map(entry => { | |
| const appPath = nodePath.posix.join(appRoot, entry.name); | |
| return { path: appPath, image: `${repository}:${entry.name}-${tagSuffix}` }; | |
| }); | |
| if (targets.length === 0) { | |
| throw new Error('No app images were built.'); | |
| } | |
| let nextTarget = 0; | |
| async function buildNext(workerId) { | |
| while (nextTarget < targets.length) { | |
| const target = targets[nextTarget++]; | |
| core.info(`Worker ${workerId}: building ${target.path}`); | |
| await exec.exec('studioctl', ['app', 'build', '--path', target.path, '--image-tag', target.image, '--push']); | |
| } | |
| } | |
| const workerCount = Math.min(maxParallelBuilds, targets.length); | |
| await Promise.all(Array.from({ length: workerCount }, (_, index) => buildNext(index + 1))); | |
| core.setOutput('app-run-targets-json', JSON.stringify(targets)); | |
| cypress-run-internal: | |
| name: Cypress Run Internal | |
| if: | | |
| (github.event_name != 'pull_request' || (github.event.action != 'closed' && !github.event.pull_request.draft)) && | |
| github.repository_owner == 'Altinn' && | |
| ( | |
| (github.event_name != 'pull_request' && github.event.repository.fork == false) || | |
| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) | |
| ) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 120 | |
| needs: [build-frontend, build-app-images] | |
| defaults: | |
| run: | |
| working-directory: src/App/frontend/ | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| containers: [1, 2, 3, 4, 5, 6] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Run Local Environment | |
| uses: ./.github/actions/app-run-local-env | |
| with: | |
| run-frontend: true | |
| run-localtest: true | |
| app-run-targets-json: ${{ needs.build-app-images.outputs.app-run-targets-json }} | |
| - name: Set Percy command based on PR draft status or main branch | |
| shell: bash | |
| run: | | |
| if [ "${{ github.ref }}" == "refs/heads/main" ] || [ "${{ github.event.pull_request.draft }}" == "false" ]; then | |
| echo "ENABLE_PERCY=true" >> "$GITHUB_ENV" | |
| fi | |
| - name: Install Cypress binary | |
| shell: bash | |
| env: | |
| CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/.cache/Cypress | |
| run: npx cypress install | |
| - name: Cypress run | |
| shell: bash | |
| env: | |
| CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/.cache/Cypress | |
| CYPRESS_PROJECT_ID: o7mikf | |
| CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} # CYPRESS_RECORD_KEY comes from "org secrets" | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} | |
| PERCY_PARALLEL_TOTAL: 6 | |
| PERCY_PARALLEL_NONCE: ${{ github.run_id }}-${{ github.run_attempt }} | |
| PERCY_BRANCH: ${{ github.head_ref || github.ref_name }} | |
| PERCY_TARGET_BRANCH: ${{ github.base_ref || 'main' }} | |
| IS_PR_DRAFT: ${{ github.event.pull_request.draft }} | |
| run: | | |
| base_command='npx cypress run --record --parallel --group altinn-app-frontend --tag altinn-app-frontend --browser chrome --ci-build-id "${{ github.run_id }}-${{ github.run_attempt }}" --spec test/e2e/integration --env environment=localtest' | |
| if [ "${ENABLE_PERCY:-false}" = "true" ]; then | |
| container_command="npx percy exec --parallel -- ${base_command}" | |
| else | |
| container_command="${base_command}" | |
| fi | |
| docker run --rm --network host \ | |
| --user "$(id -u):$(id -g)" \ | |
| -e HOME=/tmp \ | |
| -e CI=1 \ | |
| -e CYPRESS_CACHE_FOLDER \ | |
| -e CYPRESS_PROJECT_ID \ | |
| -e CYPRESS_RECORD_KEY \ | |
| -e GITHUB_TOKEN \ | |
| -e PERCY_TOKEN \ | |
| -e PERCY_PARALLEL_TOTAL \ | |
| -e PERCY_PARALLEL_NONCE \ | |
| -e PERCY_BRANCH \ | |
| -e PERCY_TARGET_BRANCH \ | |
| -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \ | |
| -w "${GITHUB_WORKSPACE}/src/App/frontend" \ | |
| "${CYPRESS_BROWSER_IMAGE}" \ | |
| bash -lc "${container_command}" | |
| - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 | |
| if: failure() | |
| with: | |
| name: app-frontend-logs | |
| path: | | |
| src/App/frontend/test/logs/* | |
| ${{ env.STUDIOCTL_HOME }}/logs/** | |
| - name: Stop localtest | |
| if: always() | |
| uses: ./.github/actions/app-stop-local-env | |
| cypress-run-external: | |
| name: Cypress Run External | |
| if: | | |
| (github.event_name != 'pull_request' || (github.event.action != 'closed' && !github.event.pull_request.draft)) && | |
| github.repository_owner == 'Altinn' && | |
| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 120 | |
| needs: [build-frontend] | |
| defaults: | |
| run: | |
| working-directory: src/App/frontend/ | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Build app run targets | |
| id: app-run-targets | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 | |
| with: | |
| script: | | |
| const fs = require('fs/promises'); | |
| const nodePath = require('path'); | |
| const appRoot = 'src/test/apps'; | |
| const entries = await fs.readdir(appRoot, { withFileTypes: true }); | |
| const targets = entries | |
| .filter(entry => entry.isDirectory()) | |
| .sort((a, b) => a.name.localeCompare(b.name)) | |
| .map(entry => ({ path: nodePath.posix.join(appRoot, entry.name) })); | |
| if (targets.length === 0) { | |
| throw new Error('No app run targets were found.'); | |
| } | |
| core.setOutput('app-run-targets-json', JSON.stringify(targets)); | |
| - name: Run Local Environment | |
| uses: ./.github/actions/app-run-local-env | |
| with: | |
| run-frontend: true | |
| run-localtest: true | |
| app-run-targets-json: ${{ steps.app-run-targets.outputs.app-run-targets-json }} | |
| - name: Install Cypress binary | |
| shell: bash | |
| env: | |
| CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/.cache/Cypress | |
| run: npx cypress install | |
| - name: Cypress run | |
| shell: bash | |
| env: | |
| CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/.cache/Cypress | |
| run: | | |
| docker run --rm --network host \ | |
| --user "$(id -u):$(id -g)" \ | |
| -e HOME=/tmp \ | |
| -e CI=1 \ | |
| -e CYPRESS_CACHE_FOLDER \ | |
| -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \ | |
| -w "${GITHUB_WORKSPACE}/src/App/frontend" \ | |
| "${CYPRESS_BROWSER_IMAGE}" \ | |
| bash -lc 'npx cypress run --browser chrome --spec test/e2e/integration --env environment=localtest' | |
| - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 | |
| if: failure() | |
| with: | |
| name: app-frontend-external-logs | |
| path: | | |
| src/App/frontend/test/logs/* | |
| src/App/frontend/test/screenshots/* | |
| src/App/frontend/test/videos/* | |
| ${{ env.STUDIOCTL_HOME }}/logs/** | |
| - name: Stop localtest | |
| if: always() | |
| uses: ./.github/actions/app-stop-local-env |