-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TASK: Add another way to run tests locally with a system under test in docker #3369
Changes from 3 commits
40fb6d8
97dedb1
02c7886
d93c3cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: "3.4" | ||
services: | ||
|
||
php: | ||
image: thecodingmachine/php:8.0-v4-cli-node16 | ||
command: tail -f /dev/null | ||
ports: | ||
- 8081:8081 | ||
volumes: | ||
- composer_cache:/home/circleci/.composer/cache | ||
# add Neos Ui root as cached read-only volume that will be later symlinked into TestDistribution/Packages/ | ||
- ../../.:/usr/src/neos-ui:cached,ro | ||
environment: | ||
# Enable GD | ||
PHP_EXTENSION_GD: 1 | ||
COMPOSER_CACHE_DIR: /home/circleci/.composer/cache | ||
|
||
db: | ||
image: ${DB_IMAGE} | ||
environment: | ||
MYSQL_DATABASE: neos | ||
MYSQL_ROOT_PASSWORD: not_a_real_password | ||
|
||
volumes: | ||
composer_cache: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
ARCH=$(uname -m) | ||
if [ "$ARCH" = "arm64" ]; then | ||
export DB_IMAGE=arm64v8/mysql:8 | ||
elif [ "$ARCH" = "x86_64" ]; then | ||
export DB_IMAGE=mysql:8 | ||
else | ||
echo "Unknown architecture" | ||
exit 1 | ||
fi | ||
|
||
function dc() { | ||
if [ -n "$(docker compose version)" ]; then | ||
# use the docker composer plugin | ||
docker compose -f ./Tests/IntegrationTests/docker-compose.system-under-test.yaml $@ | ||
else | ||
# legacy docker compose standalone | ||
docker-compose -f ./Tests/IntegrationTests/docker-compose.system-under-test.yaml $@ | ||
fi | ||
} | ||
|
||
echo "#############################################################################" | ||
echo "# Start docker environment... #" | ||
echo "#############################################################################" | ||
dc down | ||
dc up -d | ||
dc exec -T php bash <<-'BASH' | ||
rm -rf /usr/src/app/* | ||
BASH | ||
docker cp "$(pwd)"/Tests/IntegrationTests/. "$(dc ps -q php)":/usr/src/app | ||
sleep 2 | ||
|
||
echo "" | ||
echo "#############################################################################" | ||
echo "# Install dependencies... #" | ||
echo "#############################################################################" | ||
dc exec -T php bash <<-'BASH' | ||
cd /usr/src/app | ||
sudo chown -R docker:docker . | ||
sudo chown -R docker:docker /home/circleci/ | ||
cd TestDistribution | ||
composer install | ||
BASH | ||
|
||
echo "" | ||
echo "#############################################################################" | ||
echo "# Create sym links to mounted Docker volumes... #" | ||
echo "#############################################################################" | ||
echo "" | ||
dc exec -T php bash <<-'BASH' | ||
# replace installed Neos Ui with local dev via sym link to mounted volume | ||
# WHY: We want changes of dev to appear in system under test without rebuilding the whole system | ||
rm -rf Packages/Application/Neos.Neos.Ui | ||
ln -s /usr/src/neos-ui/ /usr/src/app/TestDistribution/Packages/Application/Neos.Neos.Ui | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works in generally, but not in this flow. Later i think due to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used this setup and it worked for me. Thanks for fixing the issues on Linux ❤️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well this is not fixed yet ... and I don't know why it would work on your machine ... I mean the problem is within docker after all |
||
|
||
# enable changes of the Neos.TestNodeTypes outside of the container to appear in the container via sym link to mounted volume | ||
rm -rf /usr/src/app/TestDistribution/DistributionPackages/Neos.TestNodeTypes | ||
rm -rf /usr/src/app/TestDistribution/Packages/Application/Neos.TestNodeTypes | ||
ln -s /usr/src/neos-ui/Tests/IntegrationTests/SharedNodeTypesPackage/ /usr/src/app/TestDistribution/Packages/Application/Neos.TestNodeTypes | ||
BASH | ||
|
||
echo "#############################################################################" | ||
echo "# Initialize Neos... #" | ||
echo "#############################################################################" | ||
dc exec -T php bash <<-'BASH' | ||
cd TestDistribution | ||
|
||
sed -i 's/host: 127.0.0.1/host: db/g' Configuration/Settings.yaml | ||
./flow flow:cache:flush | ||
./flow flow:cache:warmup | ||
./flow doctrine:migrate | ||
./flow user:create --username=admin --password=password --first-name=John --last-name=Doe --roles=Administrator || true | ||
BASH | ||
|
||
echo "" | ||
echo "#############################################################################" | ||
echo "# Start Flow Server... #" | ||
echo "#############################################################################" | ||
dc exec -T php bash <<-'BASH' | ||
cd TestDistribution | ||
./flow server:run --port 8081 --host 0.0.0.0 & | ||
BASH | ||
|
||
dc exec -T php bash <<-BASH | ||
mkdir -p ./TestDistribution/DistributionPackages | ||
|
||
rm -rf ./TestDistribution/DistributionPackages/Neos.TestSite | ||
ln -s "../../Fixtures/1Dimension/SitePackage" ./TestDistribution/DistributionPackages/Neos.TestSite | ||
|
||
# TODO: optimize this | ||
cd TestDistribution | ||
composer reinstall neos/test-site | ||
./flow flow:cache:flush --force | ||
./flow flow:cache:warmup | ||
./flow configuration:show --path Neos.ContentRepository.contentDimensions | ||
|
||
if ./flow site:list | grep -q 'Node name'; then | ||
./flow site:prune '*' | ||
fi | ||
./flow site:import --package-key=Neos.TestSite | ||
./flow resource:publish | ||
BASH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo: Lets use paths relative to the shellscript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me, I didn't want to put too much time into it and copy pasted the most stuff.
It's clear, that we could build a better system for all of this but I needed a faster feedback loop fast 😬
I want to build tests for Bugs I fix and wasting 2h just for building the test and another 2 for running them to see if the fix works and we don't mess up something else ist just too much ^^