Banner skeleton (#4337) #15554
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| push: | |
| branches: | |
| - 'master' | |
| - '[0-9]+.[0-9]+' | |
| tags: | |
| - '**' | |
| pull_request: | |
| branches: | |
| - '**' | |
| concurrency: | |
| group: ${{ github.ref }} | |
| cancel-in-progress: true | |
| name: Docker build | |
| jobs: | |
| check-upgrade-notes: | |
| if: github.event_name == 'pull_request' | |
| name: Check upgrade notes reference PR number | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| fetch-depth: 0 | |
| - name: Validate upgrade notes first line format | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| shell: bash | |
| run: | | |
| if ! git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null; then | |
| git fetch --no-tags --depth=1 origin "${BASE_SHA}" | |
| fi | |
| NEW_FILES=$(git diff --diff-filter=A --name-only "${BASE_SHA}" "${HEAD_SHA}" -- 'upgrade-notes/') | |
| if [ -z "${NEW_FILES}" ]; then | |
| echo "No new files in upgrade-notes for this PR." | |
| exit 0 | |
| fi | |
| EXPECTED_FRAGMENT="([#${PR_NUMBER}](https://github.com/shopsys/shopsys/pull/${PR_NUMBER}))" | |
| GREEN_CHECK=$'\033[32m✔\033[0m' | |
| RED_CROSS=$'\033[31m✖\033[0m' | |
| STATUS=0 | |
| while IFS= read -r FILE; do | |
| if [ -z "${FILE}" ]; then | |
| continue | |
| fi | |
| if [ ! -f "${FILE}" ]; then | |
| printf '%s %s\n' "${RED_CROSS}" "${FILE}" | |
| echo "::error::Expected file ${FILE} to exist." | |
| STATUS=1 | |
| continue | |
| fi | |
| FIRST_LINE=$(head -n 1 "${FILE}" | tr -d '\r' || true) | |
| if [[ "${FIRST_LINE}" != *"${EXPECTED_FRAGMENT}"* ]]; then | |
| printf '%s %s\n' "${RED_CROSS}" "${FILE}" | |
| echo "::error file=${FILE},line=1::First line must contain '${EXPECTED_FRAGMENT}'. Found '${FIRST_LINE}'." | |
| STATUS=1 | |
| else | |
| printf '%s %s\n' "${GREEN_CHECK}" "${FILE}" | |
| fi | |
| done <<< "${NEW_FILES}" | |
| exit ${STATUS} | |
| variables: | |
| name: Prepare variables and artifacts | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| DOCKER_PHP_FPM_REPOSITORY_TAG: ${{ steps.variables.outputs.DOCKER_PHP_FPM_REPOSITORY_TAG }} | |
| DOCKER_STOREFRONT_REPOSITORY_TAG: ${{ steps.variables.outputs.DOCKER_STOREFRONT_REPOSITORY_TAG }} | |
| DOCKER_STOREFRONT_CI_REPOSITORY_TAG: ${{ steps.variables.outputs.DOCKER_STOREFRONT_CI_REPOSITORY_TAG }} | |
| DOCKER_STOREFRONT_CI_IMAGE_EXISTS: ${{ steps.variables.outputs.DOCKER_STOREFRONT_CI_IMAGE_EXISTS }} | |
| DOCKER_ELASTICSEARCH_REPOSITORY_TAG: ${{ steps.variables.outputs.DOCKER_ELASTICSEARCH_REPOSITORY_TAG }} | |
| DOCKER_ELASTICSEARCH_IMAGE_EXISTS: ${{ steps.variables.outputs.DOCKER_ELASTICSEARCH_IMAGE_EXISTS }} | |
| BRANCH_NAME: ${{ steps.variables.outputs.BRANCH_NAME }} | |
| BRANCH_NAME_ESCAPED: ${{ steps.variables.outputs.BRANCH_NAME_ESCAPED }} | |
| TRAEFIK_HOSTS: ${{ steps.variables.outputs.TRAEFIK_HOSTS }} | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Extract variables to output | |
| id: variables | |
| env: | |
| DOCKER_USERNAME: ${{ github.repository_owner }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| DOCKER_PHP_FPM_REPOSITORY_TAG=ghcr.io/${DOCKER_USERNAME}/php-fpm:github-action-${{ github.sha }} | |
| DOCKER_STOREFRONT_IMAGE_TAG=github-action-${{ github.sha }} | |
| DOCKER_STOREFRONT_REPOSITORY_TAG=ghcr.io/${DOCKER_USERNAME}/storefront:${DOCKER_STOREFRONT_IMAGE_TAG} | |
| DOCKER_STOREFRONT_CI_IMAGE_TAG=github-action-`find project-base/storefront/docker -type f -exec stat -c "%a %n" {} \; -exec cat {} \; | md5sum | awk '{ print $1 }'`-ci | |
| DOCKER_STOREFRONT_CI_REPOSITORY_TAG=ghcr.io/${DOCKER_USERNAME}/storefront:${DOCKER_STOREFRONT_CI_IMAGE_TAG} | |
| DOCKER_STOREFRONT_CI_IMAGE_EXISTS=`. .github/check-image-exists.sh && checkImageExists ${DOCKER_USERNAME} storefront ${DOCKER_STOREFRONT_CI_IMAGE_TAG} ${GITHUB_TOKEN} > /dev/null ; echo $?` | |
| DOCKER_ELASTICSEARCH_IMAGE_TAG=github-action-`find project-base/app/docker/elasticsearch -type f -exec stat -c "%a %n" {} \; -exec cat {} \; | md5sum | awk '{ print $1 }'` | |
| DOCKER_ELASTICSEARCH_REPOSITORY_TAG=ghcr.io/${DOCKER_USERNAME}/elasticsearch:${DOCKER_ELASTICSEARCH_IMAGE_TAG} | |
| DOCKER_ELASTICSEARCH_IMAGE_EXISTS=`. .github/check-image-exists.sh && checkImageExists ${DOCKER_USERNAME} elasticsearch ${DOCKER_ELASTICSEARCH_IMAGE_TAG} ${GITHUB_TOKEN} > /dev/null ; echo $?` | |
| BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | |
| BRANCH_NAME="${BRANCH,,}" | |
| BRANCH_NAME_ESCAPED="${BRANCH_NAME//[\/.]/-}" | |
| echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT | |
| echo "BRANCH_NAME_ESCAPED=${BRANCH_NAME_ESCAPED}" >> $GITHUB_OUTPUT | |
| echo "DOCKER_PHP_FPM_REPOSITORY_TAG=${DOCKER_PHP_FPM_REPOSITORY_TAG}" >> $GITHUB_OUTPUT | |
| echo "DOCKER_STOREFRONT_REPOSITORY_TAG=${DOCKER_STOREFRONT_REPOSITORY_TAG}" >> $GITHUB_OUTPUT | |
| echo "DOCKER_STOREFRONT_CI_REPOSITORY_TAG=${DOCKER_STOREFRONT_CI_REPOSITORY_TAG}" >> $GITHUB_OUTPUT | |
| echo "DOCKER_STOREFRONT_CI_IMAGE_EXISTS=${DOCKER_STOREFRONT_CI_IMAGE_EXISTS}" >> $GITHUB_OUTPUT | |
| echo "DOCKER_ELASTICSEARCH_REPOSITORY_TAG=${DOCKER_ELASTICSEARCH_REPOSITORY_TAG}" >> $GITHUB_OUTPUT | |
| echo "DOCKER_ELASTICSEARCH_IMAGE_EXISTS=${DOCKER_ELASTICSEARCH_IMAGE_EXISTS}" >> $GITHUB_OUTPUT | |
| HOST=${BRANCH_NAME_ESCAPED}.${{ vars.REVIEW_STAGE_URL }} | |
| echo "TRAEFIK_HOSTS=Host(\`$HOST\`) || Host(\`cz.$HOST\`)" >> $GITHUB_OUTPUT | |
| - name: Prepare docker-compose.yml file from docker-compose.github-actions.yml.dist | |
| run: | | |
| sh .github/prepare-docker-compose-file.sh \ | |
| "./docker/conf/docker-compose.github-actions.yml.dist" \ | |
| "./docker-compose.yml" \ | |
| "${{ steps.variables.outputs.DOCKER_PHP_FPM_REPOSITORY_TAG }}" \ | |
| "${{ steps.variables.outputs.DOCKER_STOREFRONT_CI_REPOSITORY_TAG }}" \ | |
| "${{ steps.variables.outputs.DOCKER_ELASTICSEARCH_REPOSITORY_TAG }}" | |
| - name: Prepare docker-compose.review.yml file from docker-compose.github-actions.review.yml.dist | |
| run: | | |
| sh .github/prepare-docker-compose-file.sh \ | |
| "./docker/conf/docker-compose.github-actions.review.yml.dist" \ | |
| "./docker-compose.review.yml" \ | |
| "${{ steps.variables.outputs.DOCKER_PHP_FPM_REPOSITORY_TAG }}" \ | |
| "${{ steps.variables.outputs.DOCKER_STOREFRONT_REPOSITORY_TAG }}" \ | |
| "${{ steps.variables.outputs.DOCKER_ELASTICSEARCH_REPOSITORY_TAG }}" | |
| - name: Prepare docker-compose.review.simplified.yml file from docker-compose.github-actions.review.simplified.yml.dist | |
| run: | | |
| sh .github/prepare-docker-compose-file.sh \ | |
| "./docker/conf/docker-compose.github-actions.review.simplified.yml.dist" \ | |
| "./docker-compose.review.simplified.yml" \ | |
| "${{ steps.variables.outputs.DOCKER_PHP_FPM_REPOSITORY_TAG }}" \ | |
| "${{ steps.variables.outputs.DOCKER_STOREFRONT_REPOSITORY_TAG }}" | |
| - name: Prepare docker-compose.cypress.yml file from docker-compose.github-actions.cypress.yml.dist | |
| run: | | |
| sh .github/prepare-docker-compose-file.sh \ | |
| "./docker/conf/docker-compose.github-actions.cypress.yml.dist" \ | |
| "./docker-compose.cypress.yml" \ | |
| "${{ steps.variables.outputs.DOCKER_PHP_FPM_REPOSITORY_TAG }}" \ | |
| "${{ steps.variables.outputs.DOCKER_STOREFRONT_REPOSITORY_TAG }}" \ | |
| "${{ steps.variables.outputs.DOCKER_ELASTICSEARCH_REPOSITORY_TAG }}" | |
| - name: Upload docker-compose.yml to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-compose | |
| path: ./docker-compose.yml | |
| - name: Upload docker-compose.review.yml to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-compose-review | |
| path: ./docker-compose.review.yml | |
| - name: Upload docker-compose.review.simplified.yml to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-compose-review-simplified | |
| path: ./docker-compose.review.simplified.yml | |
| - name: Upload docker-compose.cypress.yml to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-compose-cypress | |
| path: ./docker-compose.cypress.yml | |
| - name: Upload set-urls-for-review.sh to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: set-urls-for-review | |
| path: ./.github/set-urls-for-review.sh | |
| - name: Upload ci-www.conf to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ci-www-conf | |
| path: ./project-base/gitlab/php-fpm-conf/ci-www.conf | |
| - name: Upload nginx.conf to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nginx-conf | |
| path: ./project-base/docker/nginx/nginx.conf | |
| - name: Upload 12-set-env-variables.envsh to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: 12-set-env-variables-envsh | |
| path: ./project-base/docker/nginx/12-set-env-variables.envsh | |
| - name: Upload rabbitmq-vhost.sh to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rabbitmq-vhost-sh | |
| path: ./.github/rabbitmq-vhost.sh | |
| build-php-fpm-image: | |
| if: | | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| needs.variables.outputs.DOCKER_PHP_FPM_REPOSITORY_TAG != '' | |
| name: Build PHP-FPM image | |
| runs-on: ubuntu-22.04 | |
| needs: variables | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build custom base image if requested | |
| if: "contains(github.event.pull_request.labels.*.name, 'Use PHP Dockerfile instead of built image')" | |
| run: | | |
| TAG=`grep -m1 -E '^FROM [^ ]+' project-base/app/docker/php-fpm/Dockerfile | awk '{print $2}' | cut -d ':' -f 1,2` | |
| docker build --tag ${TAG} --no-cache --compress -f ./packages/php-image/Dockerfile ./packages/php-image | |
| - name: Create branch specific PHP-FPM image with project files | |
| run: | | |
| .github/build-php-fpm-image.sh "${{ needs.variables.outputs.DOCKER_PHP_FPM_REPOSITORY_TAG }}" production | |
| docker image push "${{ needs.variables.outputs.DOCKER_PHP_FPM_REPOSITORY_TAG }}" | |
| build-storefront-image: | |
| if: | | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) | |
| name: Build storefront image | |
| runs-on: ubuntu-22.04 | |
| needs: variables | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Storefront image and push it to GitHub Container Registry | |
| run: | | |
| .github/build-storefront-image.sh ${{ needs.variables.outputs.DOCKER_STOREFRONT_REPOSITORY_TAG }} | |
| docker image push ${{ needs.variables.outputs.DOCKER_STOREFRONT_REPOSITORY_TAG }} | |
| build-storefront-ci-image: | |
| if: | | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| needs.variables.outputs.DOCKER_STOREFRONT_CI_IMAGE_EXISTS == 0 | |
| name: Build storefront CI image | |
| runs-on: ubuntu-22.04 | |
| needs: variables | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Storefront CI image and push it to GitHub Container Registry | |
| run: | | |
| .github/build-storefront-ci-image.sh ${{ needs.variables.outputs.DOCKER_STOREFRONT_CI_REPOSITORY_TAG }} | |
| docker image push ${{ needs.variables.outputs.DOCKER_STOREFRONT_CI_REPOSITORY_TAG }} | |
| build-elasticsearch-image: | |
| if: | | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| needs.variables.outputs.DOCKER_ELASTICSEARCH_IMAGE_EXISTS == 0 | |
| name: Build Elasticsearch image | |
| runs-on: ubuntu-22.04 | |
| needs: variables | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Elasticsearch image and push it to GitHub Container Registry | |
| run: | | |
| .github/build-elasticsearch-image.sh ${{ needs.variables.outputs.DOCKER_ELASTICSEARCH_REPOSITORY_TAG }} | |
| docker image push ${{ needs.variables.outputs.DOCKER_ELASTICSEARCH_REPOSITORY_TAG }} | |
| standards: | |
| name: Check standards | |
| needs: build-php-fpm-image | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application | |
| run: docker compose up -d php-fpm | |
| - name: Check standards | |
| run: | | |
| docker compose exec -T php-fpm touch ./project-base/app/DEVELOPMENT | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y composer-dev npm-install-dependencies standards | |
| - name: Check GraphQl schema | |
| run: docker compose exec -T php-fpm project-base/app/check-schema.sh | |
| standards-storefront: | |
| name: Check Storefront standards | |
| needs: [build-php-fpm-image, build-storefront-ci-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-storefront-ci-image.result == 'success' || needs.build-storefront-ci-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application | |
| run: docker compose up -d --wait storefront php-fpm | |
| - name: Move schema.graphql to Storefront container | |
| run: docker compose cp ./project-base/app/schema.graphql storefront:/home/node/app/schema.graphql | |
| - name: Check no NEXT_PUBLIC_ variables are used | |
| run: | | |
| docker compose exec --user root storefront apk add grep | |
| docker compose exec storefront sh check-next-public-variable.sh | |
| - name: Check graphql schema files are up to date | |
| run: | | |
| docker compose exec php-fpm npm install format-graphql | |
| docker compose exec php-fpm php phing frontend-api-generate-graphql-schema | |
| docker compose cp php-fpm:/var/www/html/project-base/app/schema.graphql /tmp/schema.graphql | |
| docker compose cp /tmp/schema.graphql storefront:/home/node/app/schema.graphql | |
| docker compose exec storefront sh check-code-gen.sh | |
| - name: Check standards | |
| run: docker compose exec storefront pnpm run check | |
| - name: Check tailwind-for-admin styles are up to date | |
| run: | | |
| docker compose exec storefront pnpm compile-tailwind-for-admin | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Tailwind admin styles are outdated. Run 'docker compose exec storefront pnpm compile-tailwind-for-admin' locally and commit the changes." | |
| git status -s | |
| exit 1 | |
| else | |
| echo "Tailwind admin styles are up to date" | |
| fi | |
| - name: Storefront container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs storefront | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Nginx container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs webserver | |
| unit-test-storefront: | |
| name: Run unit tests of Storefront | |
| needs: [build-storefront-ci-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-storefront-ci-image.result == 'success' || needs.build-storefront-ci-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application | |
| run: docker compose up -d --wait storefront | |
| - name: Run unit tests | |
| run: docker compose exec storefront pnpm test--no-watch | |
| - name: Storefront container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs storefront | |
| tests-unit-functional-smoke: | |
| name: Run unit, functional and smoke tests | |
| needs: [build-php-fpm-image, build-elasticsearch-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-elasticsearch-image.result == 'success' || needs.build-elasticsearch-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application | |
| run: | | |
| docker compose pull postgres webserver elasticsearch redis php-fpm | |
| docker compose up -d postgres webserver elasticsearch redis php-fpm | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y -D change.environment=dev environment-change test-dirs-create test-db-create frontend-api-generate-new-keys npm-install-dependencies | |
| - name: Run tests | |
| run: docker compose exec -T php-fpm php phing -D production.confirm.action=y tests | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Nginx container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs webserver | |
| tests-unit-functional-smoke-first-czech-domain: | |
| name: Run unit, functional and smoke tests with first domain in Czech and with CZK currency | |
| needs: [build-php-fpm-image, build-elasticsearch-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-elasticsearch-image.result == 'success' || needs.build-elasticsearch-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Change first domain locale to CS | |
| uses: mikefarah/[email protected] | |
| with: | |
| cmd: yq e -i '( .domains[] | select(.id == 1) ).locale = "cs" | ( .domains[] | select(.id == 2) ).locale = "en"' ./project-base/app/config/domains.yaml | |
| - name: Change first domain currency to CZK | |
| run: sed -i 's/if ($domainId === Domain::SECOND_DOMAIN_ID)/if ($domainId === Domain::FIRST_DOMAIN_ID)/' ./project-base/app/src/DataFixtures/Demo/SettingValueDataFixture.php | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application | |
| run: | | |
| docker compose pull postgres webserver elasticsearch redis php-fpm | |
| docker compose up -d postgres webserver elasticsearch redis php-fpm | |
| docker compose cp ./project-base/app/config/domains.yaml php-fpm:/var/www/html/project-base/app/config/domains.yaml | |
| docker compose cp ./project-base/app/src/DataFixtures/Demo/SettingValueDataFixture.php php-fpm:/var/www/html/project-base/app/src/DataFixtures/Demo/SettingValueDataFixture.php | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y -D change.environment=dev environment-change test-dirs-create test-db-create frontend-api-generate-new-keys npm-install-dependencies | |
| - name: Run tests | |
| run: docker compose exec -T php-fpm php phing -D production.confirm.action=y tests | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Nginx container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs webserver | |
| check-demo-data-limited-domains: | |
| name: Check demo data with load_demo_data false for domains 2 and 3 | |
| needs: [build-php-fpm-image, build-elasticsearch-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-elasticsearch-image.result == 'success' || needs.build-elasticsearch-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Set load_demo_data to false for domains 2 and 3 | |
| uses: mikefarah/[email protected] | |
| with: | |
| cmd: yq e -i '( .domains[] | select(.id == 2) ).load_demo_data = false | ( .domains[] | select(.id == 3) ).load_demo_data = false' ./project-base/app/config/domains.yaml | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application and run demo-data | |
| run: | | |
| docker compose pull postgres elasticsearch redis php-fpm | |
| docker compose up -d postgres elasticsearch redis php-fpm | |
| docker compose cp ./project-base/app/config/domains.yaml php-fpm:/var/www/html/project-base/app/config/domains.yaml | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y -D change.environment=dev environment-change db-create demo-data | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| tests-acceptance: | |
| name: Run acceptance tests | |
| needs: [build-php-fpm-image, build-elasticsearch-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-elasticsearch-image.result == 'success' || needs.build-elasticsearch-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application | |
| run: | | |
| docker compose pull webserver postgres elasticsearch redis php-fpm selenium-server | |
| docker compose up -d webserver postgres elasticsearch redis php-fpm selenium-server | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y -D change.environment=dev environment-change test-dirs-create test-db-create frontend-api-generate-new-keys test-db-demo test-elasticsearch-index-recreate test-elasticsearch-export tests-acceptance-build | |
| - name: Run acceptance tests | |
| run: docker compose exec -T php-fpm php phing -D production.confirm.action=y tests-acceptance | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Copy Codeception logs from container | |
| if: ${{ failure() }} | |
| run: docker cp shopsys-framework-php-fpm:/var/www/html/project-base/app/var/log ./project-base/app/var/log | |
| - name: Upload Codeception logs to artifacts | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: acceptance-logs | |
| path: ./project-base/app/var/log/ | |
| tests-storefront-smoke: | |
| name: Run Cypress smoke tests | |
| needs: [build-php-fpm-image, build-storefront-image, build-elasticsearch-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-storefront-image.result == 'success' || needs.build-storefront-image.result == 'skipped') && | |
| (needs.build-elasticsearch-image.result == 'success' || needs.build-elasticsearch-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Download docker-compose.cypress.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose-cypress | |
| - name: Build application | |
| run: | | |
| mv docker-compose.cypress.yml docker-compose.yml | |
| docker compose up -d --wait | |
| docker compose exec php-fpm php phing -D production.confirm.action=y db-create frontend-api-generate-new-keys build-demo-dev-quick elasticsearch-index-recreate elasticsearch-export | |
| - name: Run Cypress smoke tests | |
| run: docker compose run --rm -e TYPE=null -e COMMAND=smoke -e TEST_LOCALE=en cypress; | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Nginx container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs webserver | |
| - name: Storefront container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs storefront | |
| - name: Cypress container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs cypress | |
| tests-storefront-acceptance: | |
| name: Run Cypress tests | |
| needs: [build-php-fpm-image, build-storefront-image, build-elasticsearch-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-storefront-image.result == 'success' || needs.build-storefront-image.result == 'skipped') && | |
| (needs.build-elasticsearch-image.result == 'success' || needs.build-elasticsearch-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| group: [ authentication, cart, order, transportAndPayment, visits, others ] | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| steps: | |
| - name: Check pull request labels | |
| run: | | |
| if [ -n "${{ github.event.pull_request.number }}" ]; then | |
| PULL_REQUEST_LABELS=`gh api -H "Accept: application/vnd.github+json" /repos/shopsys/shopsys/issues/${{ github.event.pull_request.number }}/labels | jq '[.[].name]'` | |
| if echo "$PULL_REQUEST_LABELS" | jq -e '. | index("regenerate screenshots")' >/dev/null; then | |
| echo "SHOULD_RUN_TESTS=false" >> $GITHUB_ENV | |
| else | |
| echo "SHOULD_RUN_TESTS=true" >> $GITHUB_ENV | |
| fi | |
| else | |
| echo "SHOULD_RUN_TESTS=true" >> $GITHUB_ENV | |
| fi | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| if: env.SHOULD_RUN_TESTS == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Download docker-compose.cypress.yml from artifacts | |
| if: env.SHOULD_RUN_TESTS == 'true' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose-cypress | |
| - name: Build application | |
| if: env.SHOULD_RUN_TESTS == 'true' | |
| run: | | |
| mv docker-compose.cypress.yml docker-compose.yml | |
| for i in {1..2}; do | |
| if docker compose up -d --wait; then | |
| break | |
| else | |
| echo "Attempt $i failed, retrying..." | |
| docker compose down --remove-orphans || true | |
| sleep 5 | |
| [ $i -eq 2 ] && exit 1 | |
| fi | |
| done | |
| docker compose exec php-fpm php phing -D production.confirm.action=y db-create frontend-api-generate-new-keys build-demo-dev-quick elasticsearch-index-recreate elasticsearch-export | |
| - name: Run Cypress tests for ${{ matrix.group }} | |
| if: env.SHOULD_RUN_TESTS == 'true' | |
| run: docker compose run cypress | |
| env: | |
| GROUP: ${{ matrix.group }} | |
| TEST_LOCALE: en | |
| - name: Upload Cypress videos to artifacts | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cypress-videos-${{ matrix.group }} | |
| path: ./videos | |
| - name: Upload Cypress screenshots to artifacts | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cypress-screenshots-${{ matrix.group }} | |
| path: ./screenshots | |
| - name: Upload Cypress snapshot diffs to artifacts | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cypress-snapshot-diffs-${{ matrix.group }} | |
| path: ./snapshotDiffs | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Nginx container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs webserver | |
| - name: Storefront container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs storefront | |
| - name: Cypress container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs cypress | |
| tests-storefront-acceptance-regenerate: | |
| name: Reg. Cypress tests | |
| needs: [variables, build-php-fpm-image, build-storefront-image, build-elasticsearch-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-storefront-image.result == 'success' || needs.build-storefront-image.result == 'skipped') && | |
| (needs.build-elasticsearch-image.result == 'success' || needs.build-elasticsearch-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| group: [ authentication, cart, order, transportAndPayment, visits, others ] | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| outputs: | |
| SHOULD_RUN_TESTS_REGENERATE: ${{ steps.check-label-tests-regenerate.outputs.SHOULD_RUN_TESTS_REGENERATE }} | |
| steps: | |
| - name: Check pull request labels | |
| id: check-label-tests-regenerate | |
| run: | | |
| if [ -n "${{ github.event.pull_request.number }}" ]; then | |
| PULL_REQUEST_LABELS=`gh api -H "Accept: application/vnd.github+json" /repos/shopsys/shopsys/issues/${{ github.event.pull_request.number }}/labels | jq '[.[].name]'` | |
| if ! echo "$PULL_REQUEST_LABELS" | jq -e '. | index("regenerate screenshots")' >/dev/null; then | |
| echo "SHOULD_RUN_TESTS_REGENERATE=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "SHOULD_RUN_TESTS_REGENERATE=true" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "SHOULD_RUN_TESTS_REGENERATE=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: GIT checkout branch - ${{ github.head_ref }} | |
| if: steps.check-label-tests-regenerate.outputs.SHOULD_RUN_TESTS_REGENERATE == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - name: Download docker-compose.cypress.yml from artifacts | |
| if: steps.check-label-tests-regenerate.outputs.SHOULD_RUN_TESTS_REGENERATE == 'true' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose-cypress | |
| - name: Build application | |
| if: steps.check-label-tests-regenerate.outputs.SHOULD_RUN_TESTS_REGENERATE == 'true' | |
| run: | | |
| mv docker-compose.cypress.yml docker-compose.yml | |
| for i in {1..2}; do | |
| if docker compose up -d --wait; then | |
| break | |
| else | |
| echo "Attempt $i failed, retrying..." | |
| docker compose down --remove-orphans || true | |
| sleep 5 | |
| [ $i -eq 2 ] && exit 1 | |
| fi | |
| done | |
| docker compose exec php-fpm php phing -D production.confirm.action=y db-create frontend-api-generate-new-keys build-demo-dev-quick elasticsearch-index-recreate elasticsearch-export | |
| - name: Run regenerate Cypress tests for ${{ matrix.group }} | |
| if: steps.check-label-tests-regenerate.outputs.SHOULD_RUN_TESTS_REGENERATE == 'true' | |
| run: | | |
| docker compose run cypress-regenerate | |
| env: | |
| GROUP: ${{ matrix.group }} | |
| TEST_LOCALE: en | |
| - name: Upload generated snapshots for ${{ matrix.group }} | |
| if: steps.check-label-tests-regenerate.outputs.SHOULD_RUN_TESTS_REGENERATE == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cypress-snapshots-${{ matrix.group }} | |
| path: ./snapshots | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Nginx container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs webserver | |
| - name: Storefront container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs storefront | |
| - name: Cypress container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs cypress | |
| push-regenerated-snapshots: | |
| name: Push regenerated snapshots | |
| needs: [tests-storefront-acceptance-regenerate] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| needs.tests-storefront-acceptance-regenerate.outputs.SHOULD_RUN_TESTS_REGENERATE == 'true' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.head_ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - name: Download all snapshot artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./snapshots | |
| pattern: cypress-snapshots-* | |
| merge-multiple: true | |
| - name: Commit and push all snapshots | |
| run: | | |
| git config --global user.name 'ShopsysBot' | |
| git config --global user.email '[email protected]' | |
| cp -rf snapshots/* project-base/storefront/cypress/snapshots/ | |
| git add project-base/storefront/cypress/snapshots/e2e | |
| if ! git diff --cached --quiet; then | |
| git commit -m "regenerate all screenshots" | |
| git push origin ${{ github.head_ref }} --force-with-lease | |
| else | |
| echo "No changes to commit." | |
| fi | |
| tests-storefront-acceptance-regenerate-remove-label: | |
| name: Remove "regenerate screenshots" label | |
| needs: [tests-storefront-acceptance-regenerate, push-regenerated-snapshots] | |
| if: | | |
| always() && | |
| !failure() && | |
| !cancelled() | |
| runs-on: ubuntu-22.04 | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| steps: | |
| - name: Remove "regenerate screenshots" label | |
| if: needs.tests-storefront-acceptance-regenerate.outputs.SHOULD_RUN_TESTS_REGENERATE == 'true' | |
| run: | | |
| gh api \ | |
| --method DELETE \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| /repos/shopsys/shopsys/issues/${{ github.event.pull_request.number }}/labels/regenerate%20screenshots | |
| translations-dump-check: | |
| name: Check all translations and icons are dumped | |
| needs: build-php-fpm-image | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application | |
| run: docker compose up -d php-fpm storefront | |
| - name: Check translations are dumped | |
| run: | | |
| docker compose exec -T php-fpm composer install --optimize-autoloader --no-interaction | |
| docker compose exec -T php-fpm php phing npm-install-dependencies translations-dump | |
| docker compose cp php-fpm:/var/www/html/ . | |
| cp -a ./html/. ./ | |
| rm -rf ./html | |
| docker compose exec -T storefront npm run translate | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Not all translations are dumped"; | |
| git status -s | |
| exit 1; | |
| else | |
| echo "All translations are dumped"; | |
| exit 0; | |
| fi | |
| - name: Check icons are dumped and committed | |
| run: | | |
| docker compose exec -T php-fpm php bin/console shopsys:environment:change dev | |
| docker compose exec -T php-fpm php bin/console ux:icons:lock | |
| docker compose cp php-fpm:/var/www/html/project-base/app/assets/icons/ ./project-base/app/assets/ | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Not all icons are committed. Run 'bin/console ux:icons:lock' and commit the changes."; | |
| git status -s | |
| exit 1; | |
| else | |
| echo "All icons are present in the repository."; | |
| exit 0; | |
| fi | |
| check-console-commands: | |
| name: Check that all console commands that are not used during installation are passing | |
| needs: build-php-fpm-image | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application | |
| run: | | |
| docker compose up -d | |
| docker compose exec -T php-fpm composer install --optimize-autoloader --no-interaction --dev | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y db-create frontend-api-generate-new-keys build-demo-dev-quick elasticsearch-index-recreate elasticsearch-export | |
| - name: Check all commands are passing | |
| run: | | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y cron-list cron-run-all-serially cron-watch maintenance-on maintenance-off elasticsearch-export-changed | |
| docker compose exec -T php-fpm php bin/console shopsys:categories:recalculate | |
| docker compose exec -T php-fpm php bin/console shopsys:cdn-domain-url:replace | |
| docker compose exec -T php-fpm php bin/console shopsys:list:export-scopes | |
| docker compose exec -T php-fpm php bin/console shopsys:dispatch:recalculations 1 | |
| check-licenses: | |
| name: Check licenses of dependencies in Composer and NPM (php-fpm & storefront) | |
| needs: [build-php-fpm-image, build-storefront-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-storefront-image.result == 'success' || needs.build-storefront-image.result == 'skipped') | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Download docker-compose.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build application | |
| run: | | |
| docker compose up -d | |
| docker compose exec -T php-fpm composer install --optimize-autoloader --no-interaction --dev | |
| docker compose exec -T php-fpm npm install | |
| - name: Checks dependency licenses in Composer and NPM (php-fpm & storefront) | |
| run: make check-licenses | |
| build-fork-docker-images: | |
| if: | | |
| github.event.pull_request.head.repo.full_name != 'shopsys/shopsys' && | |
| github.ref_protected != true | |
| name: Build application and run standards checks and tests | |
| runs-on: ubuntu-22.04 | |
| needs: variables | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Build Elasticsearch image | |
| if: needs.variables.outputs.DOCKER_ELASTICSEARCH_IMAGE_EXISTS == 0 | |
| run: .github/build-elasticsearch-image.sh ${{ needs.variables.outputs.DOCKER_ELASTICSEARCH_REPOSITORY_TAG }} | |
| - name: Build Storefront image | |
| if: needs.variables.outputs.DOCKER_STOREFRONT_IMAGE_EXISTS == 0 | |
| run: .github/build-storefront-image.sh ${{ needs.variables.outputs.DOCKER_STOREFRONT_REPOSITORY_TAG }} | |
| - name: Build Storefront CI image | |
| if: needs.variables.outputs.DOCKER_STOREFRONT_CI_IMAGE_EXISTS == 0 | |
| run: .github/build-storefront-ci-image.sh ${{ needs.variables.outputs.DOCKER_STOREFRONT_CI_REPOSITORY_TAG }} | |
| - name: Build PHP-FPM image | |
| run: .github/build-php-fpm-image.sh ${{ needs.variables.outputs.DOCKER_PHP_FPM_REPOSITORY_TAG }} base | |
| - name: Download docker-compose.cypress.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose | |
| - name: Build PHP-FPM part of application | |
| run: | | |
| docker compose up -d --force-recreate | |
| docker cp ./ shopsys-framework-php-fpm:/var/www/html | |
| docker compose exec -T --user root php-fpm chown -R www-data:www-data /var/www/html | |
| docker compose exec -T php-fpm rm -rf /var/www/html/composer.lock /var/www/html/project-base/package-lock.json /var/www/html/project-base/migrations-lock.yml /var/www/html/project-base/storefront | |
| docker compose exec -T php-fpm composer install --optimize-autoloader --no-interaction | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y -D change.environment=dev environment-change dirs-create test-dirs-create assets npm build-version-generate db-create test-db-create db-demo elasticsearch-index-recreate elasticsearch-export test-db-demo test-elasticsearch-index-recreate test-elasticsearch-export tests-acceptance-build | |
| - name: Check standards | |
| run: docker compose exec -T php-fpm php phing standards | |
| - name: Run tests | |
| run: docker compose exec -T php-fpm php phing tests | |
| - name: Run acceptance tests | |
| run: docker compose exec -T php-fpm php phing tests-acceptance | |
| - name: Check translations are dumped | |
| run: | | |
| docker compose exec -T php-fpm php phing translations-dump | |
| docker compose cp php-fpm:/var/www/html/ . | |
| rm -rf ./html/.git | |
| cp -a ./html/. ./ | |
| rm -rf ./html | |
| docker compose exec -T storefront npm run translate | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Not all translations are dumped"; | |
| git status | |
| exit 1; | |
| else | |
| echo "All translations are dumped"; | |
| exit 0; | |
| fi | |
| - name: Check all not previously used commands are passing | |
| run: | | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y frontend-api-enable cron-list cron-run-all-serially cron-watch maintenance-on maintenance-off elasticsearch-export-changed | |
| docker compose exec -T php-fpm php bin/console shopsys:categories:recalculate | |
| docker compose exec -T php-fpm php bin/console shopsys:cdn-domain-url:replace | |
| docker compose exec -T php-fpm php bin/console shopsys:list:export-scopes | |
| docker compose exec -T php-fpm php bin/console shopsys:dispatch:recalculations 1 | |
| - name: Check licenses of dependencies in Composer and NPM (php-fpm & storefront) | |
| run: make check-licenses | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Storefront container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs storefront | |
| - name: Copy Codeception logs from container | |
| if: ${{ failure() }} | |
| run: docker cp shopsys-framework-php-fpm:/var/www/html/project-base/app/var/log ./project-base/app/var/log | |
| - name: Upload Codeception logs to artifacts | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: acceptance-logs | |
| path: ./project-base/app/var/log/ | |
| - name: Build Storefront part of application | |
| run: | | |
| docker compose cp ./project-base/app/schema.graphql storefront:/home/node/app/schema.graphql | |
| docker compose exec storefront pnpm install --frozen-lockfile | |
| - name: Check no NEXT_PUBLIC_ variables are used in Storefront | |
| run: | | |
| docker compose exec --user root storefront apk add grep | |
| docker compose exec storefront sh check-next-public-variable.sh | |
| - name: Check graphql schema files are up to date | |
| run: | | |
| docker compose exec php-fpm npm install format-graphql | |
| docker compose exec php-fpm php phing frontend-api-generate-graphql-schema | |
| docker compose cp php-fpm:/var/www/html/project-base/app/schema.graphql /tmp/schema.graphql | |
| docker compose cp /tmp/schema.graphql storefront:/home/node/app/schema.graphql | |
| docker compose exec storefront sh check-code-gen.sh | |
| - name: Check Storefront standards | |
| run: docker compose exec storefront pnpm run check | |
| - name: Run storefront unit tests | |
| run: docker compose exec storefront pnpm test--no-watch | |
| - name: Storefront container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs storefront | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Download docker-compose.cypress.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose-cypress | |
| - name: Stop previous running application | |
| run: docker compose down | |
| - name: Build application | |
| run: | | |
| mv docker-compose.cypress.yml docker-compose.yml | |
| docker compose up -d --wait | |
| docker cp ./ shopsys-framework-php-fpm:/var/www/html | |
| docker compose exec -T --user root php-fpm chown -R www-data:www-data /var/www/html | |
| docker compose exec -T php-fpm rm -rf /var/www/html/composer.lock /var/www/html/project-base/package-lock.json /var/www/html/project-base/migrations-lock.yml | |
| docker compose exec -T php-fpm composer install --optimize-autoloader --no-interaction | |
| docker compose exec php-fpm php phing -D production.confirm.action=y db-create frontend-api-generate-new-keys build-demo-dev-quick elasticsearch-index-recreate elasticsearch-export | |
| - name: Run Cypress tests | |
| run: | | |
| PULL_REQUEST_LABELS=`gh api -H "Accept: application/vnd.github+json" /repos/shopsys/shopsys/issues/${{ github.event.pull_request.number }}/labels | jq '[.[].name]'` | |
| if ! echo "$PULL_REQUEST_LABELS" | jq -e '. | index("regenerate screenshots")' >/dev/null; then | |
| docker compose run -e TEST_LOCALE=en cypress-regenerate | |
| else | |
| docker compose run -e TEST_LOCALE=en cypress | |
| fi | |
| - name: Upload Cypress videos to artifacts | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cypress-videos | |
| path: ./videos | |
| - name: Upload Cypress screenshots to artifacts | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cypress-screenshots | |
| path: ./screenshots | |
| - name: Upload Cypress snapshot diffs to artifacts | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cypress-snapshot-diffs | |
| path: ./snapshotDiffs | |
| - name: PHP-FPM container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs php-fpm | |
| - name: Nginx container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs webserver | |
| - name: Storefront container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs storefront | |
| - name: Cypress container logs | |
| if: ${{ failure() }} | |
| run: docker compose logs cypress | |
| review: | |
| name: Review | |
| needs: [variables, build-php-fpm-image, build-storefront-image, build-elasticsearch-image] | |
| if: | | |
| always() && !failure() && !cancelled() && | |
| ( | |
| github.event.pull_request.head.repo.full_name == 'shopsys/shopsys' || | |
| github.ref_protected == true | |
| ) && | |
| (needs.build-php-fpm-image.result == 'success' || needs.build-php-fpm-image.result == 'skipped') && | |
| (needs.build-storefront-image.result == 'success' || needs.build-storefront-image.result == 'skipped') && | |
| (needs.build-elasticsearch-image.result == 'success' || needs.build-elasticsearch-image.result == 'skipped') | |
| runs-on: [self-hosted, linux, review-stage] | |
| timeout-minutes: 10 | |
| env: | |
| BRANCH_NAME: ${{ needs.variables.outputs.BRANCH_NAME }} | |
| BRANCH_NAME_ESCAPED: ${{ needs.variables.outputs.BRANCH_NAME_ESCAPED }} | |
| TRAEFIK_HOSTS: ${{ needs.variables.outputs.TRAEFIK_HOSTS }} | |
| GOPAY_CONFIG_VALUE: ${{ secrets.GOPAY_CONFIG }} | |
| GTM_ID_VALUE: ${{ secrets.GTM_ID }} | |
| PACKETERY_API_KEY_VALUE: ${{ secrets.PACKETERY_API_KEY }} | |
| PACKETERY_API_PASSWORD_VALUE: ${{ secrets.PACKETERY_API_PASSWORD }} | |
| FACEBOOK_CLIENTID: ${{ secrets.FACEBOOK_CLIENTID }} | |
| FACEBOOK_CLIENTSECRET: ${{ secrets.FACEBOOK_CLIENTSECRET }} | |
| GOOGLE_CLIENTID: ${{ secrets.GOOGLE_CLIENTID }} | |
| GOOGLE_CLIENTSECRET: ${{ secrets.GOOGLE_CLIENTSECRET }} | |
| SEZNAM_CLIENTID: ${{ secrets.SEZNAM_CLIENTID }} | |
| SEZNAM_CLIENTSECRET: ${{ secrets.SEZNAM_CLIENTSECRET }} | |
| GOOGLE_MAP_API_KEY_VALUE: ${{ secrets.GOOGLE_MAP_API_KEY }} | |
| steps: | |
| - name: Create branch directory | |
| run: | | |
| rm -rf ${BRANCH_NAME_ESCAPED} | |
| mkdir ${BRANCH_NAME_ESCAPED} | |
| - name: Set ENV variables required for review | |
| run: | | |
| HOST=${BRANCH_NAME_ESCAPED}.${{ vars.REVIEW_STAGE_URL }} | |
| echo "HOSTS=${HOST}, cz.${HOST}, ${HOST}/sk" >> $GITHUB_ENV | |
| - name: Download docker-compose.review.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose-review | |
| - name: Download docker-compose.review.simplified.yml from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docker-compose-review-simplified | |
| - name: Download set-urls-for-review-sh from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: set-urls-for-review | |
| path: ${{ needs.variables.outputs.BRANCH_NAME_ESCAPED }} | |
| - name: Download ci-www.conf from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ci-www-conf | |
| path: ${{ needs.variables.outputs.BRANCH_NAME_ESCAPED }} | |
| - name: Download nginx.conf from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nginx-conf | |
| path: ${{ needs.variables.outputs.BRANCH_NAME_ESCAPED }} | |
| - name: Download 12-set-env-variables.envsh from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: 12-set-env-variables-envsh | |
| path: ${{ needs.variables.outputs.BRANCH_NAME_ESCAPED }} | |
| - name: Download rabbitmq-vhost-sh from artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: rabbitmq-vhost-sh | |
| path: ${{ needs.variables.outputs.BRANCH_NAME_ESCAPED }} | |
| - name: Move docker-compose.review.yml to branch folder | |
| if: "contains(github.event.pull_request.labels.*.name, 'Use docker-compose defined services for review')" | |
| run: | | |
| mv docker-compose.review.yml ${BRANCH_NAME_ESCAPED}/docker-compose.yml | |
| - name: Move docker-compose.review.simplified.yml to branch folder | |
| if: "!contains(github.event.pull_request.labels.*.name, 'Use docker-compose defined services for review')" | |
| run: | | |
| mv docker-compose.review.simplified.yml ${BRANCH_NAME_ESCAPED}/docker-compose.yml | |
| bash ./${BRANCH_NAME_ESCAPED}/rabbitmq-vhost.sh create ${BRANCH_NAME_ESCAPED} | |
| - name: Start project | |
| run: | | |
| cd ${BRANCH_NAME_ESCAPED} | |
| chmod +x set-urls-for-review.sh | |
| chmod +x 12-set-env-variables.envsh | |
| ./set-urls-for-review.sh setDomainsToDockerCompose | |
| docker compose down -v --remove-orphans || true | |
| docker compose up -d --wait --force-recreate | |
| ./set-urls-for-review.sh setUrlsToDomainsUrls | |
| docker compose exec -T php-fpm php phing -D production.confirm.action=y db-create frontend-api-generate-new-keys demo-data warmup | |
| docker compose exec -T php-consumer php phing -D production.confirm.action=y frontend-api-generate-new-keys | |
| ./set-urls-for-review.sh printDomains | |
| - name: Add Review URL to Pull request description | |
| uses: Jerome1337/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| description-message: | | |
| ---- | |
| :globe_with_meridians: Live Preview: | |
| - https://${{ needs.variables.outputs.BRANCH_NAME_ESCAPED }}.${{ vars.REVIEW_STAGE_URL }} | |
| - https://cz.${{ needs.variables.outputs.BRANCH_NAME_ESCAPED }}.${{ vars.REVIEW_STAGE_URL }} | |
| - https://${{ needs.variables.outputs.BRANCH_NAME_ESCAPED }}.${{ vars.REVIEW_STAGE_URL }}/sk | |
| delete-previous-comment: false | |
| build-successful: | |
| if: | | |
| always() | |
| name: Build successful | |
| needs: [tests-acceptance, standards, tests-unit-functional-smoke, tests-unit-functional-smoke-first-czech-domain, check-demo-data-limited-domains, standards-storefront, translations-dump-check, review, build-fork-docker-images, check-console-commands, tests-storefront-smoke, tests-storefront-acceptance, tests-storefront-acceptance-regenerate, push-regenerated-snapshots, unit-test-storefront,] | |
| runs-on: ubuntu-22.04 | |
| env: | |
| BUILD_FORK_RESULT: ${{ needs.build-fork-docker-images.result }} | |
| STANDARDS_RESULT: ${{ needs.standards.result }} | |
| TESTS_RESULT: ${{ needs.tests-unit-functional-smoke.result }} | |
| TESTS_CZECH_RESULT: ${{ needs.tests-unit-functional-smoke-first-czech-domain.result }} | |
| CHECK_DEMO_DATA_LIMITED_DOMAINS_RESULT: ${{ needs.check-demo-data-limited-domains.result }} | |
| TESTS_ACCEPTANCE_RESULT: ${{ needs.tests-acceptance.result }} | |
| STANDARDS_STOREFRONT_RESULT: ${{ needs.standards-storefront.result }} | |
| TRANSLATIONS_DUMP_RESULT: ${{ needs.translations-dump-check.result }} | |
| REVIEW_RESULT: ${{ needs.review.result }} | |
| CHECK_CONSOLE_COMMANDS_RESULT: ${{ needs.check-console-commands.result }} | |
| TESTS_STOREFRONT_SMOKE_RESULT: ${{ needs.tests-storefront-smoke.result }} | |
| TESTS_STOREFRONT_ACCEPTANCE_RESULT: ${{ needs.tests-storefront-acceptance.result }} | |
| UNIT_TESTS_STOREFRONT_RESULT: ${{ needs.unit-test-storefront.result }} | |
| TESTS_STOREFRONT_ACCEPTANCE_REGENERATE_RESULT: ${{ needs.tests-storefront-acceptance-regenerate.result }} | |
| REGENERATION_STARTED: ${{ needs.tests-storefront-acceptance-regenerate.outputs.SHOULD_RUN_TESTS_REGENERATE || 'false' }} | |
| steps: | |
| - name: GIT checkout branch - ${{ github.ref }} | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Build successful | |
| run: | | |
| EXIT_CODE=`. .github/get-build-exit-code.sh && getBuildExitCodeBasedOnJobResults ${BUILD_FORK_RESULT} ${STANDARDS_RESULT} ${TESTS_RESULT} ${TESTS_CZECH_RESULT} ${CHECK_DEMO_DATA_LIMITED_DOMAINS_RESULT} ${TESTS_ACCEPTANCE_RESULT} ${STANDARDS_STOREFRONT_RESULT} ${TRANSLATIONS_DUMP_RESULT} ${REVIEW_RESULT} ${CHECK_CONSOLE_COMMANDS_RESULT} ${TESTS_STOREFRONT_SMOKE_RESULT} ${TESTS_STOREFRONT_ACCEPTANCE_RESULT} ${UNIT_TESTS_STOREFRONT_RESULT} ${TESTS_STOREFRONT_ACCEPTANCE_REGENERATE_RESULT} ${REGENERATION_STARTED} > /dev/null ; echo $?` | |
| exit "${EXIT_CODE}" |