Skip to content

Commit e24d31c

Browse files
exaby73transistive
authored andcommitted
feat: Add Symfony override script to CI
1 parent fdbaa49 commit e24d31c

File tree

5 files changed

+39
-65
lines changed

5 files changed

+39
-65
lines changed

.github/scripts/setup-symfony-env.bash

100644100755
Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,34 @@
22

33
set -ex
44

5-
cp composer.json composer.json.origin
6-
rm composer.lock || true
7-
rm -Rf vendor || true
8-
sed -i 's/\^5.4 || \^6.0 || \^7.0/\^5.4/g' composer.json
9-
composer install
5+
if [ -z "$1" ]; then
6+
echo "Please specify the Symfony version to install"
7+
exit 1
8+
fi
9+
10+
echo "Installing Symfony version $1"
11+
12+
# This is not required for CI, but it allows to test the script locally
13+
function cleanup {
14+
echo "Cleaning up"
15+
# Restore the original composer.json file
16+
mv composer.origin.json composer.json
17+
}
18+
19+
function install-specified-symfony-version {
20+
local symfony_version=$1
21+
# Save the original composer.json file
22+
cp composer.json composer.origin.json
23+
# Delete the lock file and vendor directory for a clean install
24+
rm composer.lock || true
25+
rm -Rf vendor || true
26+
# Replace the Symfony version in composer.json
27+
sed -i 's/\^5.4 || \^6.0 || \^7.0/'$symfony_version'/g' composer.json
28+
# Install the specified Symfony version
29+
composer install
30+
}
31+
32+
# Ensure cleanup is called on exit
33+
trap cleanup EXIT
34+
35+
install-specified-symfony-version $1

.github/workflows/tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ jobs:
3434
uses: php-actions/composer@v2
3535
with:
3636
php_version: ${{ matrix.php }}
37-
env:
38-
SYMFONY_REQUIRE: ${{ matrix.sf_version }}
37+
38+
- name: Override Symfony version
39+
run: composer run ci-symfony-install-version ${{ matrix.sf_version }}
3940

4041
- uses: php-actions/phpunit@v3
4142
with:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
composer.lock
44
.phpunit.result.cache
55
.idea
6-
.php-cs-fixer.cache
6+
.php-cs-fixer.cache
7+
8+
composer.origin.json

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"scripts": {
5252
"psalm": "php bin/console.php cache:warmup && vendor/bin/psalm --show-info=true",
5353
"fix-cs": "vendor/bin/php-cs-fixer fix",
54-
"check-cs": "vendor/bin/php-cs-fixer fix --dry-run"
54+
"check-cs": "vendor/bin/php-cs-fixer fix --dry-run",
55+
"ci-symfony-install-version": "./.github/scripts/setup-symfony-env.bash"
5556
}
5657
}

composer.json.origin

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)