Skip to content

Chore/performance optimisation #336

Chore/performance optimisation

Chore/performance optimisation #336

Workflow file for this run

##############################
#### AUTOGENERATED ####
#### DO NOT MODIFY! ####
##############################
# Workflow for PR checks in module repositories
name: CI
on:
# Start workflow on each pull request
pull_request:
concurrency:
# There should be only one in-progress run of this workflow at a time for a specific PR
group: ${{ github.event.number }}
# Cancel runs of this workflow that are currently in progess.
cancel-in-progress: true
jobs:
# Runs the unit test suite
unit-tests:
name: Run unit test suite
# Define plenty-used variables
env:
# CI variables
APP_ENV: testing
IS_JENKINS: true
PLENTY_ID_HASH: 1000
WORKSPACE: ${{ github.workspace }}
INC_DIR: ${{ github.workspace }}/pl/packages/plentymarkets/plugin-test-suite/tests/includes
TEST_SUITE_DIR: ${{ github.workspace }}/pl/packages/plentymarkets/plugin-test-suite
# Database variables
DB_HOST: "127.0.0.1"
DB_USERNAME: root
DB_PASSWORD: test
DB_DATABASE: mysql-test
# Synonym database variable names (only defined because of inconsistency within plenty code)
DB_USER: root
DB_PASS: test
DB_NAME: mysql-test
# AWS environment variables
AWS_REGION: eu-central-1
#STATUS FILE
STATUS_FILE: test.plugins.${{ matrix.php.version }}.status
strategy:
fail-fast: false
matrix:
php:
- version: "8.0"
required: true
- version: "8.2"
required: true
runs-on: ubuntu-latest
# Start containers with specific services that are needed to run the unit test suite.
# In this case we need mariadb and redis.
# The used versions match the ones used in production.
services:
mariadb:
# Uses a prewarmed db image here to speedup the migrations https://github.com/plentymarkets/prewarm-db
image: ghcr.io/plentymarkets/prewarm-db:stable7
credentials:
username: ${{ github.repository_owner }}
password: ${{ secrets.PUBLIC_PAT_CICD4_PUBLIC }}
ports:
- 127.0.0.1:3306:3306
env:
MARIADB_ROOT_PASSWORD: ${{ env.DB_PASSWORD }}
MARIADB_DATABASE: ${{ env.DB_DATABASE }}
redis:
image: redis:4.0.8
ports:
- 127.0.0.1:6379:6379
steps:
- name: Cleanup Runner
uses: plentymarkets/github-runner-cleanup@main
- name: Checkout github-actions repository
uses: actions/checkout@v4
with:
repository: plentymarkets/github-actions
ref: main
token: ${{ secrets.PUBLIC_PAT_CICD4_PUBLIC }}
path: .tmp/github-actions
- name: Prepare PHP main code
uses: ./.tmp/github-actions/prepare_php/
with:
token: ${{ secrets.PUBLIC_PAT_CICD4_PUBLIC }}
php-version: ${{ matrix.php.version }}
branch-forced: stable7
- name: Build plugin api
working-directory: pl
run: |
composer dump-autoload
php artisan plugin:buildinterface --without-docs --target=./storage/plugin-interface
- name: Checkout plugin test suite
uses: actions/checkout@v4
with:
repository: "plentymarkets/plugin-test-suite"
token: ${{ secrets.PUBLIC_PAT_CICD4_PUBLIC }}
path: "pl/packages/plentymarkets/plugin-test-suite/"
ref: stable7
- name: Install test suite dependencies
working-directory: pl/packages/plentymarkets/plugin-test-suite
run: |
composer install
rm .env
touch .env
- name: Checkout IO branch
uses: actions/checkout@v4
with:
path: pl/packages/plentymarkets/plugin-test-suite/vendor/plentymarkets/plugin-io
- name: Run plugin migrations
working-directory: pl
run: php artisan plugin:install --database=mysql-test --env=testing
- name: Run tests
working-directory: pl/packages/plentymarkets/plugin-test-suite
run: vendor/bin/phpunit vendor/plentymarkets/plugin-io
- name: Set job status
if: always()
run: |
echo "${{ job.status }}" > "${RUNNER_TEMP}/${STATUS_FILE}"
# add "optional" if test is not required
if ! ${{ matrix.php.required }}; then
echo " optional" >> "${RUNNER_TEMP}/${STATUS_FILE}"
fi
- name: Upload matrix status artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: job-status-${{ matrix.test.id }}-php${{ matrix.php.version }}
path: ${{ runner.temp }}/${{ env.STATUS_FILE }}
retention-days: 1
collect-results:
# checks results of all previous jobs for failures
needs: [unit-tests]
name: Test overall status
runs-on: ubuntu-latest
if: always()
steps:
- uses: plentymarkets/github-runner-cleanup@main
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/job-status
pattern: job-status-*
merge-multiple: true
- name: Summarize jobs status
shell: bash
run: |
FILES=$(find "${{ runner.temp }}/job-status" -type f -name "test.*.status")
OVERALL_STATUS="success"
RED='\033[0;31m'
NC='\033[0m'
while IFS="" read -r FILE; do
FILENAME=$(basename "${FILE}")
STATUS=$(cat "$FILE" | xargs)
printf "${FILENAME}: "
if [[ "$STATUS" != "success"* ]]; then
printf "${RED}${STATUS}${NC}\n"
if [[ "$STATUS" != *"optional"* ]]; then
OVERALL_STATUS=$STATUS
fi
else
echo "${STATUS}"
fi
done <<< "$FILES"
if [[ "$OVERALL_STATUS" != "success" ]]; then
printf "\n${RED}At least one required job failed!${NC}\n"
exit 1
else
printf "\nAll required jobs were successful.\n"
fi