Skip to content

Commit

Permalink
Merge pull request #5 from NoResponseMate/maintenance/allow-setting-w…
Browse files Browse the repository at this point in the history
…orking-dir

Allow manually setting application and test directories + minor fixes
  • Loading branch information
GSadee authored Dec 6, 2024
2 parents bf66699 + 973775e commit 3274f50
Showing 1 changed file with 49 additions and 18 deletions.
67 changes: 49 additions & 18 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -76,13 +86,13 @@ 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:
required: false
description: "Chrome version to be used"
default: "latest"
default: "stable"

runs:
using: "composite"
Expand All @@ -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 #
#####################################################################
Expand Down Expand Up @@ -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
Expand All @@ -168,7 +197,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 }}
Expand All @@ -180,34 +209,36 @@ 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'
run: composer integration ${{ inputs.integration }}
env:
COMPOSER_ROOT_VERSION: dev-main
shell: bash
working-directory: "${{ env.application_dir }}"

#####################################################################
# Prepare for end-to-end tests #
#####################################################################

- 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 &
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
Expand All @@ -217,29 +248,29 @@ 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 #
#####################################################################

- 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 }}"

- name: Install JS dependencies
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 #
Expand All @@ -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'
Expand All @@ -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
Expand Down

0 comments on commit 3274f50

Please sign in to comment.