Skip to content

Commit

Permalink
Fix checkout on develop, build docker images explicitely for old bran…
Browse files Browse the repository at this point in the history
…ches that do not have the dependencies set in their docker-compose.yml file, dynamize docker names the prefix is based on root folder
  • Loading branch information
jolelievre committed Sep 26, 2023
1 parent c4f34a5 commit 56824fe
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 34 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/actions/archive-shop/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ runs:
using: "composite"
steps:
- name: Archive shop content
env:
DOCKER_PREFIX: ${{ inputs.ps_dir }}
run: |
mkdir -p /tmp/${{ inputs.artifact_name }}
pushd ${{ inputs.ps_dir }}; zip -q -r /tmp/${{ inputs.artifact_name }}/sources.zip . -x \
Expand All @@ -37,7 +39,7 @@ runs:
"tests/Resources/**/*" \
"tests/Unit/**/*" \
".git/**/*"; popd
docker exec my_prestashop_mysql_1 /usr/bin/mysqldump -u ${{ inputs.db_user }} -p${{ inputs.db_password }} ${{ inputs.db_name }} > /tmp/${{ inputs.artifact_name }}/db_dump.sql
docker exec ${{ env.DOCKER_PREFIX }}_mysql_1 /usr/bin/mysqldump -u ${{ inputs.db_user }} -p${{ inputs.db_password }} ${{ inputs.db_name }} > /tmp/${{ inputs.artifact_name }}/db_dump.sql
shell: bash

- name: Upload shop artifacts "${{ inputs.artifact_name }}"
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/actions/checkout-prestashop/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,13 @@ runs:

# Or simply get the branch/tag
- name: Get ref from repository ${{ inputs.repository_ref }}
if: inputs.pr_number == '' && inputs.rebase_or_merge == ''
if: inputs.pr_number == '' && inputs.rebase_or_merge == '' && inputs.repository_ref != 'develop'
working-directory: ${{ inputs.ps_dir }}
run: |
git fetch origin ${{ inputs.repository_ref }}:${{ inputs.repository_ref }}
git checkout ${{ inputs.repository_ref }}
shell: bash

- name: Merge
working-directory: ${{ inputs.ps_dir }}
if: ${{ inputs.rebase_or_merge == 'merge' }}
run: |
git fetch origin ${{ inputs.base_branch }}:${{ inputs.base_branch }}
git merge origin/${{ inputs.base_branch }}
shell: bash

# Workaround until https://github.com/PrestaShop/PrestaShop/issues/29813 is fixed
- name: PrestaShop Configuration (Copy of Config API)
if: startsWith(inputs.repository_ref, '8.1') || (inputs.repository_ref == 'develop')
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ runs:
DB_NAME: prestashop
DB_PREFIX: tst_
DB_SERVER: mysql
PS_DIR: 'my_prestashop'
PS_FOLDER_INSTALL: install-dev
PS_FOLDER_ADMIN: admin-dev
PS_COUNTRY: fr
Expand All @@ -70,16 +69,18 @@ runs:
shell: bash

- name: Export docker logs
env:
DOCKER_PREFIX: ${{ inputs.ps_dir }}
run: |
mkdir -p ${{ inputs.ps_dir }}/var/docker-logs
docker logs my_prestashop_mysql_1 > ${{ inputs.ps_dir }}/var/docker-logs/mysql.log
docker logs my_prestashop_prestashop-git_1 > ${{ inputs.ps_dir }}/var/docker-logs/prestashop.log
docker logs ${{ env.DOCKER_PREFIX }}_mysql_1 > ${{ inputs.ps_dir }}/var/docker-logs/mysql.log
docker logs ${{ env.DOCKER_PREFIX }}_prestashop-git_1 > ${{ inputs.ps_dir }}/var/docker-logs/prestashop.log
if: failure()
shell: bash

- name: Export docker keycloak logs
run: |
docker logs my_prestashop_keycloak_1 > ${{ inputs.ps_dir }}/var/docker-logs/keycloak.log
docker logs ${{ inputs.ps_dir }}_keycloak_1 > ${{ inputs.ps_dir }}/var/docker-logs/keycloak.log
if: failure() && inputs.test_command == 'functional:API'
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
id: export-folder
working-directory: ${{ env.PS_TARGET }}
run: |
exportFolder=$(pwd)/$(ls tools/build/releases/)
exportFolder=$(pwd)/tools/build/releases/$(ls tools/build/releases/)
echo "export-folder=$exportFolder" >> $GITHUB_OUTPUT
- name: Upload built release
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/build-shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ on:
jobs:
build-shop-artifacts:
runs-on: ubuntu-latest
name: Build shop artifacts
name: Build shop artifacts based on ${{ inputs.repository_ref }}
env:
# Input values
PS_MODE_DEV: ${{ inputs.ps_mode_dev && '1' || '0' }}
Expand All @@ -61,6 +61,7 @@ jobs:
DB_NAME: prestashop
DB_PREFIX: tst_
PS_DIR: 'my_prestashop'
DOCKER_PREFIX: ${{ env.PS_DIR }}
PS_FOLDER_INSTALL: install-dev
PS_FOLDER_ADMIN: admin-dev
PS_COUNTRY: fr
Expand Down Expand Up @@ -100,7 +101,7 @@ jobs:
working-directory: ${{ env.PS_DIR }}
run: |
# Build prestashop image in background
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker-compose -f docker-compose.yml build >& /dev/null &
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker-compose -f docker-compose.yml build prestashop-git >& /dev/null &
# Run composer install before building the assets since the themes come from composer
- name: Get Composer Cache Directory
Expand Down Expand Up @@ -196,7 +197,7 @@ jobs:
until docker images | grep prestashop-git; do echo Waiting for prestashop-git image; sleep 1; done
# Then build and start the docker
echo Build docker via docker composer
USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose -f docker-compose.yml up -d --build prestashop-git
USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose -f docker-compose.yml up -d --build prestashop-git mysql
echo Waiting for response from the FO
bash -c 'while [[ "$(curl -L -s -o /dev/null -w %{http_code} ${{ env.URL_FO }}en/)" != "200" ]]; do sleep 1; done'
Expand All @@ -211,10 +212,18 @@ jobs:
db_name: ${{ env.DB_NAME }}
artifact_name: ${{ inputs.artifact_name }}

- name: Export docker logs
if: failure()
run: |
mkdir -p ${{ env.PS_DIR }}/var/docker-logs
docker logs ${{ env.DOCKER_PREFIX }}_prestashop-git_1 > ${{ env.PS_DIR }}/var/docker-logs/prestashop.log
docker logs ${{ env.DOCKER_PREFIX }}_mysql_1 > ${{ env.PS_DIR }}/var/docker-logs/mysql.log
- name: Save logs in case of error
uses: actions/upload-artifact@v3
if: failure()
with:
name: Build error export logs
path: |
${{ env.PS_DIR }}/var/logs
${{ env.PS_DIR }}/var/docker-logs
4 changes: 2 additions & 2 deletions .github/workflows/test-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
working-directory: ${{ env.PS_DIR }}
run: |
# Build prestashop image in background
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker-compose -f docker-compose.yml build >& /dev/null &
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker-compose -f docker-compose.yml build prestashop-git >& /dev/null &
# Certificate
- name: Generate a certificate
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
until docker images | grep prestashop-git; do echo Waiting for prestashop-git image; sleep 1; done
# Then build and start the docker, no need to wait the install page is accessible right away
echo Build docker via docker composer
USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose -f docker-compose.yml up -d --build prestashop-git
USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose -f docker-compose.yml up -d --build prestashop-git mysql
# Install node dependencies and build assets
- name: Setup Node ${{ inputs.node_version }}
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/test-with-prebuilt-shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
DB_PREFIX: tst_
DB_SERVER: mysql
PS_DIR: 'my_prestashop'
DOCKER_PREFIX: ${{ env.PS_DIR }}
PS_FOLDER_INSTALL: install-dev
PS_FOLDER_ADMIN: admin-dev
PS_COUNTRY: fr
Expand Down Expand Up @@ -87,7 +88,7 @@ jobs:
working-directory: ${{ env.PS_DIR }}
run: |
# Build prestashop image in background
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker-compose -f docker-compose.yml build >& /dev/null &
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker-compose -f docker-compose.yml build prestashop-git >& /dev/null &
# Certificate
- name: Generate a certificate
Expand Down Expand Up @@ -115,13 +116,13 @@ jobs:
USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose -f docker-compose.yml up -d --build mysql
echo Wait until mysql is accessible minimum 10 seconds before testing
sleep 10
until docker exec my_prestashop_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }}; do echo "Sleep and retry to check"; sleep 2; done
until docker exec ${{ env.DOCKER_PREFIX }}_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }}; do echo "Sleep and retry to check"; sleep 2; done
echo Copying dump into docker
docker cp ${{ steps.download-shop.outputs.db-dump-path }} my_prestashop_mysql_1:/tmp/db_dump.sql
docker cp ${{ steps.download-shop.outputs.db-dump-path }} ${{ env.DOCKER_PREFIX }}_mysql_1:/tmp/db_dump.sql
echo Creating ${{ env.DB_NAME }} database
docker exec my_prestashop_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} -e "CREATE DATABASE IF NOT EXISTS ${{ env.DB_NAME }};"
docker exec ${{ env.DOCKER_PREFIX }}_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} -e "CREATE DATABASE IF NOT EXISTS ${{ env.DB_NAME }};"
echo Load dump into DB
docker exec my_prestashop_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} ${{ env.DB_NAME }} -e "source /tmp/db_dump.sql;"
docker exec ${{ env.DOCKER_PREFIX }}_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} ${{ env.DB_NAME }} -e "source /tmp/db_dump.sql;"
- name: Build keycloak
if: inputs.test_command == 'functional:API'
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/upgrade-shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
DB_PREFIX: tst_
DB_SERVER: mysql
PS_DIR: upgraded_prestashop
DOCKER_PREFIX: ${{ env.PS_DIR }}
PS_FOLDER_INSTALL: install-dev
PS_FOLDER_ADMIN: admin-dev
PS_COUNTRY: fr
Expand Down Expand Up @@ -76,7 +77,7 @@ jobs:
working-directory: ${{ env.PS_DIR }}
run: |
# Build prestashop image in background
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker-compose -f docker-compose.yml build >& /dev/null &
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker-compose -f docker-compose.yml build prestashop-git >& /dev/null &
# Certificate
- name: Generate a certificate
Expand Down Expand Up @@ -104,13 +105,13 @@ jobs:
USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose -f docker-compose.yml up -d --build mysql
echo Wait until mysql is accessible minimum 10 seconds before testing
sleep 10
until docker exec my_prestashop_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }}; do echo "Sleep and retry to check"; sleep 2; done
until docker exec ${{ env.DOCKER_PREFIX }}_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }}; do echo "Sleep and retry to check"; sleep 2; done
echo Copying dump into docker
docker cp ${{ steps.download-shop.outputs.db-dump-path }} my_prestashop_mysql_1:/tmp/db_dump.sql
docker cp ${{ steps.download-shop.outputs.db-dump-path }} ${{ env.DOCKER_PREFIX }}_mysql_1:/tmp/db_dump.sql
echo Creating ${{ env.DB_NAME }} database
docker exec my_prestashop_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} -e "CREATE DATABASE IF NOT EXISTS ${{ env.DB_NAME }};"
docker exec ${{ env.DOCKER_PREFIX }}_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} -e "CREATE DATABASE IF NOT EXISTS ${{ env.DB_NAME }};"
echo Load dump into DB
docker exec my_prestashop_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} ${{ env.DB_NAME }} -e "source /tmp/db_dump.sql;"
docker exec ${{ env.DOCKER_PREFIX }}_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} ${{ env.DB_NAME }} -e "source /tmp/db_dump.sql;"
- name: Start up shop docker
working-directory: ${{ env.PS_DIR }}
Expand Down Expand Up @@ -144,7 +145,7 @@ jobs:
working-directory: ${{ env.PS_DIR }}/modules/autoupgrade

- name: Install module via CLI commands
run: docker exec -u www-data my_prestashop_prestashop-git_1 php bin/console prestashop:module install autoupgrade
run: docker exec -u www-data ${{ env.DOCKER_PREFIX }}_prestashop-git_1 php bin/console prestashop:module install autoupgrade

- name: Prepare archive folder
run: mkdir -p ${{ env.PS_DIR }}/modules/autoupgrade/releases/download
Expand All @@ -165,9 +166,9 @@ jobs:
- name: Run CLI upgrade based on target release archive
run: |
docker exec -u www-data my_prestashop_prestashop-git_1 php modules/autoupgrade/cli-updateconfig.php --from=modules/autoupgrade/config.json --dir=admin-dev
docker exec -u www-data my_prestashop_prestashop-git_1 php modules/autoupgrade/tests/testCliProcess.php modules/autoupgrade/cli-upgrade.php --dir="admin-dev" --action="compareReleases"
docker exec -u www-data my_prestashop_prestashop-git_1 php modules/autoupgrade/tests/testCliProcess.php modules/autoupgrade/cli-upgrade.php --dir=admin-dev
docker exec -u www-data ${{ env.DOCKER_PREFIX }}_prestashop-git_1 php modules/autoupgrade/cli-updateconfig.php --from=modules/autoupgrade/config.json --dir=admin-dev
docker exec -u www-data ${{ env.DOCKER_PREFIX }}_prestashop-git_1 php modules/autoupgrade/tests/testCliProcess.php modules/autoupgrade/cli-upgrade.php --dir="admin-dev" --action="compareReleases"
docker exec -u www-data ${{ env.DOCKER_PREFIX }}_prestashop-git_1 php modules/autoupgrade/tests/testCliProcess.php modules/autoupgrade/cli-upgrade.php --dir=admin-dev
# Prepare archive contents to share with following jobs
- name: Archive shop content
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/upgrade_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ on:
- 'v4.15.0'
- 'v4.14.2'
default: 'dev'
ps_mode_dev:
type: boolean
description: Use developer mode?
required: true
php_version:
type: choice
description: PHP version
Expand All @@ -62,6 +66,7 @@ jobs:
uses: ./.github/workflows/build-shop.yml
with:
repository_ref: ${{ inputs.source_ref }}
ps_mode_dev: ${{ inputs.ps_mode_dev }}
php_version: ${{ inputs.php_version }}
node_version: ${{ inputs.node_version }}
artifact_name: source_shop
Expand Down

0 comments on commit 56824fe

Please sign in to comment.