From 34b7eaa5a84dca4c9e7e73281b2437ae6d254105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Ludvik?= Date: Tue, 17 Oct 2023 09:35:18 +0200 Subject: [PATCH] run all checks in project-base GitHub actions build --- .github/keep-only-first-domain.js | 23 ++++++++ .github/workflows/run-checks-tests.yaml | 74 +++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 .github/keep-only-first-domain.js diff --git a/.github/keep-only-first-domain.js b/.github/keep-only-first-domain.js new file mode 100644 index 0000000000..e4a3dfe08d --- /dev/null +++ b/.github/keep-only-first-domain.js @@ -0,0 +1,23 @@ +const fs = require('fs'); +const path = require('path'); + +// Path to your next.config.js file +const filePath = path.join(__dirname, 'next.config.js'); + +// Read the file +let file = fs.readFileSync(filePath, 'utf8'); + +// Use eval to convert the file content to a JavaScript object +// WARNING: eval can be dangerous because it executes the code it's given. +// Only use it if you trust the source of the code. +let nextConfig; +eval('nextConfig = ' + file); + +// Modify the domains array +nextConfig.publicRuntimeConfig.domains = [nextConfig.publicRuntimeConfig.domains[0]]; + +// Convert the object back to a string +file = 'const nextConfig = ' + JSON.stringify(nextConfig, null, 4) + ';'; + +// Write the file +fs.writeFileSync(filePath, file); diff --git a/.github/workflows/run-checks-tests.yaml b/.github/workflows/run-checks-tests.yaml index 16ecbd28b3..a0238c726a 100644 --- a/.github/workflows/run-checks-tests.yaml +++ b/.github/workflows/run-checks-tests.yaml @@ -35,6 +35,41 @@ jobs: with: name: acceptance-logs path: ./var/log + + - name: Build Storefront part of application + run: | + docker compose cp ./project-base/app/schema.graphql storefront:/home/node/app/schema.graphql + docker compose exec storefront pnpm install --frozen-lockfile + - name: Check Storefront standards + run: docker compose exec storefront pnpm run check + - name: Run storefront unit tests + run: docker compose exec storefront pnpm test--no-watch + - name: Run Cypress tests + run: docker compose run cypress + - name: Upload Cypress videos to artifacts + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: cypress-videos + path: ./videos + - name: Upload Cypress screenshots to artifacts + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: cypress-screenshots + path: ./screenshots + - name: PHP-FPM container logs + if: ${{ failure() }} + run: docker compose logs php-fpm + - name: Nginx container logs + if: ${{ failure() }} + run: docker compose logs webserver + - name: Storefront container logs + if: ${{ failure() }} + run: docker compose logs storefront + - name: Cypress container logs + if: ${{ failure() }} + run: docker compose logs cypress build-whole-application-for-single-domain: name: Build application and run standards checks and tests on single domain runs-on: 'ubuntu-20.04' @@ -43,6 +78,10 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.ref }} + - name: Remove all but first domain from next.config.js + run: | + node ./.github/keep-only-first-domain.js + cat ./.github/keep-only-first-domain.js - name: Configure application run: echo 1 | ./scripts/configure.sh - name: Remove other domains than first one from configs @@ -80,3 +119,38 @@ jobs: with: name: acceptance-logs path: ./var/log + + - name: Build Storefront part of application + run: | + docker compose cp ./project-base/app/schema.graphql storefront:/home/node/app/schema.graphql + docker compose exec storefront pnpm install --frozen-lockfile + - name: Check Storefront standards + run: docker compose exec storefront pnpm run check + - name: Run storefront unit tests + run: docker compose exec storefront pnpm test--no-watch + - name: Run Cypress tests + run: docker compose run cypress + - name: Upload Cypress videos to artifacts + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: cypress-videos + path: ./videos + - name: Upload Cypress screenshots to artifacts + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: cypress-screenshots + path: ./screenshots + - name: PHP-FPM container logs + if: ${{ failure() }} + run: docker compose logs php-fpm + - name: Nginx container logs + if: ${{ failure() }} + run: docker compose logs webserver + - name: Storefront container logs + if: ${{ failure() }} + run: docker compose logs storefront + - name: Cypress container logs + if: ${{ failure() }} + run: docker compose logs cypress