Skip to content

Commit

Permalink
Fix checkout on develop, build docker explicitely for old branches th…
Browse files Browse the repository at this point in the history
…at do not have the dependencies, dynamize docker names based on root folder
  • Loading branch information
jolelievre committed Sep 26, 2023
1 parent c4f34a5 commit 477f627
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions/archive-shop/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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 ${{ inputs.ps_dir }}_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
7 changes: 3 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 @@ -72,14 +71,14 @@ runs:
- name: Export docker logs
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 ${{ inputs.ps_dir }}_mysql_1 > ${{ inputs.ps_dir }}/var/docker-logs/mysql.log
docker logs ${{ inputs.ps_dir }}_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
14 changes: 11 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 Down Expand Up @@ -100,7 +100,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 +196,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 +211,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.PS_DIR }}_prestashop-git_1 > ${{ env.PS_DIR }}/var/docker-logs/prestashop.log
docker logs ${{ env.PS_DIR }}_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
2 changes: 1 addition & 1 deletion .github/workflows/test-with-prebuilt-shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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
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 477f627

Please sign in to comment.