Skip to content

Commit

Permalink
[INTERNAL] fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijusCoding committed Dec 31, 2024
1 parent 8f3041d commit 6702735
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 34 deletions.
78 changes: 44 additions & 34 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,54 +19,64 @@ jobs:
uses: prestashopcorp/github-action-php-cs-fixer@master

test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
env:
# Change these values depending on project.
ps-module-name: mollie
project-workspace-dir: ${{ github.workspace }}/../workspace
strategy:
matrix:
PS: [ 1.7.8-7.1 ]
testsuite: [ lint, phpstan, unit, integration ]

- name: Cache composer folder
uses: actions/cache@v1
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
path: ~/.composer/cache
key: php-composer-cache
access_token: ${{ github.token }}

- run: composer i
- name: Checkout
uses: actions/checkout@v4

- name: Pull PrestaShop files
run: docker run -tid --rm -v ps-volume:/var/www/html -v $PWD/:/var/www/html/modules/mollie --name temp-ps prestashop/prestashop:1.7.8.1-7.4-apache
- name: Set Swap Space
uses: Invertus/set-swap-space@master
with:
swap-size-gb: 10

- name: Run PHPunit
run: docker exec -i temp-ps bash -c "cd /var/www/html/modules/mollie && composer install && ./vendor/bin/phpunit -c tests/phpunit.xml"
- name: Setup PS module workspace
uses: Invertus/[email protected]
with:
ps-module-name: ${{ env.ps-module-name }}
ps-version-dockerhub-tag: ${{ matrix.PS }}
project-workspace-dir: ${{ env.project-workspace-dir }}
ps-module-workspace-private-key: ${{ secrets.PS_MODULE_WORKSPACE_PRIVATE_KEY }}

phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: [ '1.7.6.8', '1.7.7.0', 'nightly-apache' ]
steps:
- name: Checkout
uses: actions/[email protected]
- name: Run PrestaShop
run: |
(cd ${{ env.project-workspace-dir }} && docker compose up -d)
- name: Cache vendor folder
uses: actions/cache@v1
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}
- name: Healthcheck
run: |
timeout 120s sh -c 'until docker ps | grep ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} | grep -q "(healthy)"; do echo "Waiting for container to be healthy..."; sleep 1; done'
- name: Cache composer folder
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: php-composer-cache
path: ${{ env.project-workspace-dir }}/prestashop/${{ matrix.PS }}/modules/${{ env.ps-module-name }}/vendor
key: ${{ github.sha }}

- name: Module composer install
run: (cd ${{ env.project-workspace-dir }} && make module-composer-install)

- run: composer update
- name: Remove conflicting modules
run: docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "cd /var/www/html && rm -rf modules/ps_checkout"

- name: Pull PrestaShop files (Tag ${{ matrix.presta-versions }})
run: docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:${{ matrix.presta-versions }}
- name: Install module
run: docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "cd /var/www/html && php bin/console prestashop:module install ${{ env.ps-module-name }}"

- name: Run PHPStan
run: docker run --rm --volumes-from temp-ps -v $PWD:/web/module -e _PS_ROOT_DIR_=/var/www/html --workdir=/web/module phpstan/phpstan:0.12 analyse --configuration=/web/module/tests/phpstan/phpstan_base.neon --debug --error-format github
- name: Run ${{ matrix.testsuite }} tests
run: docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "cd /var/www/html/modules/${{ env.ps-module-name }} && make ci-${{ matrix.testsuite }} ps_version_tag=${{ matrix.PS }}"

prepare-zip:
name: Prepare module ZIP artifact
Expand Down
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,25 @@ prepare-zip:
composer install --no-dev --optimize-autoloader --classmap-authoritative
composer dump-autoload --no-dev --optimize --classmap-authoritative
rm -rf .git .docker .editorconfig .github tests .php-cs-fixer.php Makefile cypress .docker cypress.config.js cypress.env.json docker-compose*.yml .gitignore bin codeception.yml package-lock.json package.json .php_cs.dist .php-cs-fixer.dist .php-cs-fixer.dist.php

ci-unit:
php vendor/bin/phpunit -c tests/phpunit-unit-ci.xml

ci-integration:
php vendor/bin/phpunit -c tests/phpunit-integration-ci.xml

ci-lint:
./vendor/bin/php-cs-fixer fix --diff --no-interaction --dry-run

ci-phpstan:
# PHPStan version is PHP version-dependent, so we need to install it on the go depending on actual PHP version used by CI.
composer require phpstan/phpstan --dev
ps_version=$(firstword $(subst -, ,$(ps_version_tag))); \
if [ -e tests/phpstan/phpstan-$$ps_version.neon ] ; then \
phpstan_config_path=tests/phpstan/phpstan-$$ps_version.neon ; \
else \
phpstan_config_path=tests/phpstan/phpstan.neon ; \
fi; \
echo Using PHPStan config: $$phpstan_config_path ; \
_PS_ROOT_DIR_=/var/www/html ./vendor/bin/phpstan --configuration=$$phpstan_config_path analyse

0 comments on commit 6702735

Please sign in to comment.