From 807ddbb8c5b2b543a6576ee63c75e217ffdaf284 Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Thu, 5 Dec 2024 09:28:54 +0100 Subject: [PATCH 1/5] Update GA actions used internally --- action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index a8143c0..2177d4b 100644 --- a/action.yaml +++ b/action.yaml @@ -168,7 +168,7 @@ runs: - name: "Restore dependencies" if: inputs.cache_key != '' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ inputs.cache_key }} @@ -225,7 +225,7 @@ runs: - name: Setup Node if: inputs.e2e_js == 'yes' && inputs.node_version != '' - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "${{ inputs.node_version }}" From f51260dffd3e3a6a6e9d5036df55e4af3c02b28b Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Thu, 5 Dec 2024 09:29:07 +0100 Subject: [PATCH 2/5] Bump default node to 20 --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 2177d4b..9e41e1d 100644 --- a/action.yaml +++ b/action.yaml @@ -76,7 +76,7 @@ inputs: node_version: required: false description: "A Node.js version to be used" - default: "16.x" + default: "20.x" # Chrome (only when e2e_js is set to "yes") chrome_version: From 907d930b764ae7c8d7a72a359973539ce5033cd5 Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Thu, 5 Dec 2024 09:29:43 +0100 Subject: [PATCH 3/5] Change default chrome version from latest to stable --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 9e41e1d..f9cce4a 100644 --- a/action.yaml +++ b/action.yaml @@ -82,7 +82,7 @@ inputs: chrome_version: required: false description: "Chrome version to be used" - default: "latest" + default: "stable" runs: using: "composite" From 713ab7a114e247255d5e339b491107451f7b2a9d Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Thu, 5 Dec 2024 09:39:38 +0100 Subject: [PATCH 4/5] Disable installing and running chrome for non js builds --- action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index f9cce4a..9304eda 100644 --- a/action.yaml +++ b/action.yaml @@ -193,12 +193,12 @@ runs: ##################################################################### - uses: browser-actions/setup-chrome@latest - if: inputs.e2e == 'yes' || inputs.e2e_js == 'yes' + if: inputs.e2e_js == 'yes' with: chrome-version: "${{ inputs.chrome_version }}" - name: Run Chrome Headless - if: inputs.e2e == 'yes' || inputs.e2e_js == 'yes' + if: inputs.e2e_js == 'yes' run: | export DISPLAY=:99 chrome --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --remote-debugging-port=9222 --disable-extensions --no-sandbox --enable-features=Metal --headless --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 & From 973775e2e284537456b559cb60b918a7017a0992 Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Wed, 4 Dec 2024 17:07:20 +0100 Subject: [PATCH 5/5] Allow setting application root and test directories --- action.yaml | 55 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/action.yaml b/action.yaml index 9304eda..d5a5a79 100644 --- a/action.yaml +++ b/action.yaml @@ -8,6 +8,16 @@ inputs: description: "A build type to be used" default: "app" # available options are "sylius" (to tests Sylius itself), "app" (to test Sylius-based application, e.g. Sylius-Standard), "plugin" (to test Sylius plugin) + application_root_dir: + required: false + description: "The application directory to be used (useful for monorepos with isolation tests)" + default: "" # If empty directory will be resolved based on the build type + + application_test_dir: + required: false + description: "The application test directory to be used (useful for monorepos with isolation tests)" + default: "" # If empty directory will be resolved based on the build type + cache_key: required: false description: "A cache key to be used" @@ -93,13 +103,30 @@ runs: shell: bash env: BUILD_TYPE: ${{ inputs.build_type }} + APPLICATION_ROOT_DIR: ${{ inputs.application_root_dir }} run: | - if [ "$BUILD_TYPE" = "plugin" ]; then - echo "application_dir=tests/Application" >> $GITHUB_ENV + if [ "$APPLICATION_ROOT_DIR" != "" ]; then + echo "application_dir=${APPLICATION_ROOT_DIR}" >> $GITHUB_ENV else echo "application_dir=." >> $GITHUB_ENV fi + - + name: Set test_dir environment variable + shell: bash + env: + BUILD_TYPE: ${{ inputs.build_type }} + APPLICATION_ROOT_DIR: ${{ env.application_dir }} + APPLICATION_TEST_DIR: ${{ inputs.application_test_dir }} + run: | + if [ "$APPLICATION_TEST_DIR" != "" ]; then + echo "test_dir=${APPLICATION_TEST_DIR}" >> $GITHUB_ENV + elif [ "$BUILD_TYPE" = "plugin" ]; then + echo "test_dir=tests/Application" >> $GITHUB_ENV + else + echo "test_dir=${APPLICATION_ROOT_DIR}" >> $GITHUB_ENV + fi + ##################################################################### # Set up a database # ##################################################################### @@ -155,11 +182,13 @@ runs: composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.17 || ^2.0" composer config extra.symfony.require "${{ inputs.symfony_version }}" shell: bash + working-directory: "${{ env.application_dir }}" - name: Restrict Sylius version if: inputs.sylius_version != '' && inputs.build_type != 'sylius' run: composer require "sylius/sylius:${{ inputs.sylius_version }}" --no-update --no-scripts --no-interaction shell: bash + working-directory: "${{ env.application_dir }}" - name: Get Composer cache directory id: composer-cache @@ -180,6 +209,7 @@ runs: env: COMPOSER_ROOT_VERSION: dev-main shell: bash + working-directory: "${{ env.application_dir }}" - name: Install Sylius integration if: inputs.integration != '' && inputs.build_type != 'sylius' @@ -187,6 +217,7 @@ runs: env: COMPOSER_ROOT_VERSION: dev-main shell: bash + working-directory: "${{ env.application_dir }}" ##################################################################### # Prepare for end-to-end tests # @@ -203,11 +234,11 @@ runs: export DISPLAY=:99 chrome --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --remote-debugging-port=9222 --disable-extensions --no-sandbox --enable-features=Metal --headless --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 & shell: bash - working-directory: "${{ inputs.working-directory }}" + working-directory: "${{ env.test_dir }}" - name: Run webserver if: inputs.e2e == 'yes' || inputs.e2e_js == 'no' - run: symfony server:start --port=8080 --dir=${{ env.application_dir }}/public --daemon + run: symfony server:start --port=8080 --dir=${{ env.test_dir }}/public --daemon shell: bash - name: Configure Encore for non-JS end-to-end tests @@ -217,7 +248,7 @@ runs: echo "{}" > public/build/admin/manifest.json echo "{}" > public/build/shop/manifest.json shell: bash - working-directory: "${{ env.application_dir }}" + working-directory: "${{ env.test_dir }}" ##################################################################### # Set up Node.js # @@ -233,13 +264,13 @@ runs: if: inputs.e2e_js == 'yes' && inputs.node_version != '' run: yarn install shell: bash - working-directory: "${{ env.application_dir }}" + working-directory: "${{ env.test_dir }}" - name: Build JS assets if: inputs.e2e_js == 'yes' && inputs.node_version != '' run: yarn build shell: bash - working-directory: "${{ env.application_dir }}" + working-directory: "${{ env.test_dir }}" ##################################################################### # Prepare the application # @@ -251,7 +282,7 @@ runs: bin/console doctrine:database:create --if-not-exists -vvv bin/console doctrine:migrations:migrate -n -vvv shell: bash - working-directory: "${{ env.application_dir }}" + working-directory: "${{ env.test_dir }}" - name: Prepare application database (legacy) if: inputs.database == 'postgresql' && inputs.legacy_postgresql_setup == 'yes' @@ -261,22 +292,22 @@ runs: bin/console doctrine:schema:validate bin/console doctrine:migrations:sync-metadata-storage shell: bash - working-directory: "${{ env.application_dir }}" + working-directory: "${{ env.test_dir }}" - name: Install assets run: bin/console assets:install public -vvv shell: bash - working-directory: "${{ env.application_dir }}" + working-directory: "${{ env.test_dir }}" - name: Warm up cache run: bin/console cache:warmup -vvv shell: bash - working-directory: "${{ env.application_dir }}" + working-directory: "${{ env.test_dir }}" - name: Load fixtures run: bin/console sylius:fixtures:load -n shell: bash - working-directory: "${{ env.application_dir }}" + working-directory: "${{ env.test_dir }}" branding: icon: activity