Skip to content
38 changes: 17 additions & 21 deletions .github/workflows/.utils.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Create a non-exiting version of _run_task for sequential execution
# This is used to run the tests sequentially on Windows
# because parallel is not available on Windows.
_run_task_sequential() {
_run_task() {
local ok=0
local title="$1"
local start=$(date -u +%s)
Expand All @@ -19,28 +19,24 @@ _run_task_sequential() {
echo -e "\n\\e[32mOK\\e[0m $title\\n\\n::endgroup::"
fi

return $ok
}
export -f _run_task_sequential

_run_task() {
_run_task_sequential "$1" "$2"
exit $?
return $?
}
export -f _run_task

install_property_info_for_version() {
local php_version="$1"
local min_stability="$2"
_before_test() {
local package="$1"
local php_version="$2"
local min_stability="$3"

if [ "$php_version" = "8.2" ]; then
composer require symfony/property-info:7.1.* symfony/type-info:7.2.*
elif [ "$php_version" = "8.3" ]; then
composer require symfony/property-info:7.2.* symfony/type-info:7.2.*
elif [ "$php_version" = "8.4" ] && [ "$min_stability" = "stable" ]; then
composer require symfony/property-info:7.3.* symfony/type-info:7.3.*
elif [ "$php_version" = "8.4" ] && [ "$min_stability" = "dev" ]; then
composer require symfony/property-info:>=7.3 symfony/type-info:>=7.3
fi
if [ "$package" = "LiveComponent" ]; then
if [ "$php_version" = "8.2" ]; then
composer require symfony/property-info:7.1.* symfony/type-info:7.2.*
elif [ "$php_version" = "8.3" ]; then
composer require symfony/property-info:7.2.* symfony/type-info:7.2.*
elif [ "$php_version" = "8.4" ] && [ "$min_stability" = "stable" ]; then
composer require symfony/property-info:7.3.* symfony/type-info:7.3.*
elif [ "$php_version" = "8.4" ] && [ "$min_stability" = "dev" ]; then
composer require symfony/property-info:>=7.3 symfony/type-info:>=7.3
fi
fi
}
export -f install_property_info_for_version
48 changes: 21 additions & 27 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ jobs:
echo "Packages: $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV

- name: Install rust-parallel
run: |
mkdir -p "$HOME/.local/bin"

if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
# Windows installation
curl -L https://github.com/aaronriekenberg/rust-parallel/releases/download/v1.18.1/rust-parallel-x86_64-pc-windows-msvc.zip -o rust-parallel.zip
unzip rust-parallel.zip -d "$HOME/.local/bin"
else
# Linux installation
curl -L https://github.com/aaronriekenberg/rust-parallel/releases/download/v1.18.1/rust-parallel-x86_64-unknown-linux-gnu.tar.gz -o rust-parallel.tar.gz
tar -xzf rust-parallel.tar.gz -C "$HOME/.local/bin"
chmod +x "$HOME/.local/bin/rust-parallel"
fi

echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand Down Expand Up @@ -108,39 +125,16 @@ jobs:
- name: Build root packages
run: php .github/build-packages.php

- name: Run packages tests (Unix)
if: matrix.os != 'windows-latest'
- name: Run packages tests
run: |
source .github/workflows/.utils.sh
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} \
'(cd src/{} \
echo "$PACKAGES" | xargs -n1 | rust-parallel -j 3 --exit-on-error --regex '(.+)' --shell --shell-path bash --shell-argument -c "_run_task {1} \
'(cd src/{1} \
&& $COMPOSER_MIN_STAB \
&& $COMPOSER_UP \
&& if [ {} = LiveComponent ]; then install_property_info_for_version \"${{ matrix.php-version }}\" \"${{ matrix.minimum-stability }}\"; fi \
&& _before_test {1} ${{ matrix.php-version }} ${{ matrix.minimum-stability }} \
&& $PHPUNIT)'"

- name: Run packages tests (Windows)
if: matrix.os == 'windows-latest'
run: |
source .github/workflows/.utils.sh

# parallel is not available on Windows, so we need to run the tests sequentially
FAILED_PACKAGES=""
for PACKAGE in $PACKAGES; do
if ! PACKAGE="$PACKAGE" _run_task_sequential $PACKAGE \
'(cd src/$PACKAGE \
&& $COMPOSER_MIN_STAB \
&& $COMPOSER_UP \
&& if [ "$PACKAGE" = "LiveComponent" ]; then install_property_info_for_version \"${{ matrix.php-version }}\" \"${{ matrix.minimum-stability }}\"; fi \
&& $PHPUNIT)'; then
FAILED_PACKAGES="$FAILED_PACKAGES $PACKAGE"
fi
done

if [ -n "$FAILED_PACKAGES" ]; then
echo "The following packages failed:$FAILED_PACKAGES"
exit 1
fi
js:
runs-on: ubuntu-latest
strategy:
Expand Down
Binary file added rust-parallel.zip
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(to remove)

Binary file not shown.
Loading