Skip to content

Commit

Permalink
Merge pull request PrestaShop#66 from jolelievre/keycloak-revival
Browse files Browse the repository at this point in the history
Enable keycloak back again
  • Loading branch information
Progi1984 authored Apr 15, 2024
2 parents 5eec42c + 60268bc commit d95a16a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/actions/launch-keycloak/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Launch keycloak
description: Checkout keycloak module for installation and to launch keycloak docker

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
name: Checkout keycloak module
with:
repository: PrestaShop/keycloak_connector_demo
ref: v1.1.0
path: keycloak_connector_demo
- name: Build keycloak docker and install module via CLI command
run: |
USER_ID=$(id -u) GROUP_ID=$(id -g) docker compose -f keycloak_connector_demo/docker-compose-ui.yml up -d
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ runs:

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

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/build-shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ jobs:
ps_dir: ${{ env.PS_DIR }}

# Pre pull/build images
# For some reason keycloak must be started before the PrestaShop build or it fails
- name: Pull images in background
working-directory: ${{ env.PS_DIR }}
run: |
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/pr_test_one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ jobs:
run: |
git fetch origin ${{ inputs.BASE_BRANCH }}
git ${{ inputs.REBASE_OR_MERGE }} origin/${{ inputs.BASE_BRANCH }}
- name: Setup Environment
timeout-minutes: 15
uses: ./.github/actions/setup-env
Expand All @@ -238,6 +238,15 @@ jobs:
INSTALL_AUTO: ${{ (matrix.TEST_CAMPAIGN == 'sanity') && 'false' || 'true' }}
CP_API_CONFIG: ${{ (matrix.BASE_BRANCH == '8.1.x') && 'true' || 'false' }}

# Checkout repository to use custom actions
- uses: actions/checkout@v4
with:
path: custom_actions
# Keycloak is only needed for API campaign
- name: Launch keycloak
uses: ./custom_actions/.github/workflows/actions/launch-keycloak
if: matrix.TEST_CAMPAIGN == 'functional:API' && matrix.BASE_BRANCH == 'develop'

- name: Run Tests
id: runTests
uses: ./.github/actions/ui-test
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ jobs:
backoffice_layout: ${{ inputs.backoffice_layout }}
ps_dir: ${{ env.PS_DIR }}

# Pre pull/build images (no need for keycloak)
- name: Pull mysql image in background
working-directory: ${{ env.PS_DIR }}
run: |
Expand Down
25 changes: 8 additions & 17 deletions .github/workflows/test-with-prebuilt-shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,15 @@ jobs:

- name: Extract PrestaShop sources
run: |
unzip /tmp/shop-artifacts/sources.zip -d .
unzip -qq /tmp/shop-artifacts/sources.zip -d .
# Pre pull/build images
- name: Pull mysql in background
working-directory: ${{ env.PS_DIR }}
run: |
# Pull mysql image
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker compose -f docker-compose.yml pull -q mysql >& /dev/null &
- name: Pull keycloak in background
if: inputs.test_command == 'functional:API'
working-directory: ${{ env.PS_DIR }}
run: |
# Pull keycloak image
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker compose -f docker-compose.yml pull -q keycloak >& /dev/null &
- name: Build PrestaShop image in background
working-directory: ${{ env.PS_DIR }}
run: |
Expand Down Expand Up @@ -129,13 +124,6 @@ jobs:
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;"
- name: Build keycloak
if: inputs.test_command == 'functional:API'
working-directory: ${{ env.PS_DIR }}
run: |
until docker images | grep keycloak; do echo Waiting for keycloak image; sleep 1; done
USER_ID=$(id -u) GROUP_ID=$(id -g) nohup docker compose -f docker-compose.yml up -d --build keycloak
- name: Start up shop docker
working-directory: ${{ env.PS_DIR }}
timeout-minutes: 5
Expand All @@ -145,18 +133,21 @@ jobs:
# No install we force the sources and load the SQL dump
PS_INSTALL_AUTO: 0
DISABLE_MAKE: 1
# For API tests we build all containers (including keycloak) for other tests only prestashop is needed
BUILT_CONTAINERS: ${{ (inputs.test_command == 'functional:API') && '' || 'prestashop-git' }}
run: |
# First wait for all images to be ready
echo Check that all images are ready
until docker images | grep mysql; do echo Waiting for mysql image; sleep 1; done
until docker images | grep prestashop-git; do echo Waiting for prestashop-git image; sleep 1; done
echo Build the remaining dockers
USER_ID=$(id -u) GROUP_ID=$(id -g) docker compose -f docker-compose.yml up -d --build ${{ env.BUILT_CONTAINERS }}
USER_ID=$(id -u) GROUP_ID=$(id -g) docker compose -f docker-compose.yml up -d --build
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 5; done'
# Keycloak is only needed for API campaign
- name: Launch keycloak
uses: ./custom_actions/.github/workflows/actions/launch-keycloak
if: inputs.test_command == 'functional:API' && inputs.base_branch == 'develop'

# Test dependencies are installed manually in each sub job that test the build, it could have been integrated inside the archive to reduce time here
# but it turns out the archive is much bigger with all this code and it makes upload/download phase so much longer that it is more efficient to install
# this here
Expand Down

0 comments on commit d95a16a

Please sign in to comment.