Skip to content

Commit

Permalink
[Tests]: Add strategy matrix to cover all the versions and mysql engi…
Browse files Browse the repository at this point in the history
…ne (#542)

* fix with matrix

* revert wrong change

* fix docker composer require

* fix typo

* remove superflous volume

* use latest, add upgrade tests

* fix continue-on-error

* fix continue-on-error

* split upgrade test

* cd

* refactor with a `if`, use maria specific version to test

* set -ex

* add migration command

* Update .github/workflows/pimcore-demo.yml

---------

Co-authored-by: Divesh Pahuja <divesh.pahuja@gmail.com>
  • Loading branch information
kingjia90 and dvesh3 committed Sep 13, 2023
1 parent 2eaa7f0 commit 4b480d0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .github/ci/files/docker-compose.yaml
@@ -0,0 +1,12 @@
services:
db:
image: ${DOCKER_DATABASE}
working_dir: /application
command: [ mysqld, --log_bin_trust_function_creators=1, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci, --innodb-file-per-table=1 ]
volumes:
- pimcore-demo-database:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ROOT
MYSQL_DATABASE: pimcore
MYSQL_USER: pimcore
MYSQL_PASSWORD: pimcore
50 changes: 46 additions & 4 deletions .github/workflows/pimcore-demo.yml
Expand Up @@ -16,9 +16,17 @@ on:
jobs:
test-pimcore-demo:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
include:
- { php-version: 8.2, database: "mariadb:10.11", pimcore_version: "", experimental: true }
- { php-version: 8.2, database: "mariadb:10.11", pimcore_version: "", pimcore_upgrade_version: "11.x-dev as 11.0.0", experimental: true }
- { php-version: 8.2, database: "mysql:latest", pimcore_version: "", experimental: true }
- { php-version: 8.2, database: "mysql:latest", pimcore_version: "", pimcore_upgrade_version: "11.x-dev as 11.0.0", experimental: true }
steps:
# Check out the repo in a sub-dir to see if it can serve as
# teplate for `composer create-project`
# template for `composer create-project`
# See: https://github.com/actions/checkout#usage
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -54,16 +62,21 @@ jobs:
sample-project
- name: Smoke-test compose file
env:
DOCKER_DATABASE: "${{ matrix.database }}"
run: |
# Echo commands and terminate on first error
set -ex
# Check (lint) the compose file
docker-compose -v
cd sample-project/
docker-compose config
docker-compose -f docker-compose.yaml -f .github/ci/files/docker-compose.yaml config
- name: Test pimcore installation
env:
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
DOCKER_DATABASE: "${{ matrix.database }}"
run: |
# Echo commands and terminate on first error
set -ex
Expand All @@ -73,7 +86,11 @@ jobs:
# Start containers
docker-compose pull --quiet
docker-compose down -v --remove-orphans
docker-compose up -d
docker-compose -f docker-compose.yaml -f .github/ci/files/docker-compose.yaml up -d
if [ ! -z "$PIMCORE_VERSION" ]; then
docker-compose exec -T -- php composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
fi
# Install dockerize into the php container. We need it to block until
# database is ready to serve connections.
Expand Down Expand Up @@ -103,4 +120,29 @@ jobs:
echo "Install failed, skipping build"
exit 1;
fi
docker-compose down -v --remove-orphans
- name: Test pimcore upgrade
if: ${{ matrix.pimcore_upgrade_version != '' }}
env:
UPGRADE_VERSION: "${{ matrix.pimcore_upgrade_version }}"
run: |
# Echo commands and terminate on first error
set -ex
cd sample-project/
docker-compose exec -T -- php composer require pimcore/pimcore:"${UPGRADE_VERSION}"
# Run pimcore migration.
docker-compose exec -T -- php ./bin/console doctrine:migrations:migrate
# Check if website is reachable, after upgrade
response=$(docker-compose exec -T -- php bash -c 'curl -s "nginx:80"')
if [[ ! $response =~ "Satisfaction" ]]; then
echo "Install failed, skipping build"
exit 1;
fi
- name: Compose down
run: |
cd sample-project/
docker-compose down -v --remove-orphans

0 comments on commit 4b480d0

Please sign in to comment.