Skip to content

Commit 9262087

Browse files
committed
Add new GitHub Action workflows
1 parent a1f51dc commit 9262087

2 files changed

Lines changed: 69 additions & 6 deletions

File tree

.github/workflows/compile.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Magento 2 DI compilation
2+
on: ['push', 'pull_request']
3+
4+
jobs:
5+
compile:
6+
name: Magento 2 DI compilation
7+
#runs-on: self-hosted
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
magento_version: ['2.4.5-p14', '2.4.7-p4', '2.4.7-p7', '2.4.8', '2.4.8-p1', '2.4.8-p2', '2.4.8-p3']
12+
container:
13+
image: yireo/magento2installed:${{ matrix.magento_version }}
14+
steps:
15+
- name: Checkout sources
16+
uses: actions/checkout@v4
17+
18+
- name: Configure Yireo GitLab
19+
run: |
20+
test -n "${{ secrets.GITLAB_TOKEN }}" || exit 0
21+
cd /tmp/magento
22+
composer config gitlab-domains gitlab.yireo.com
23+
composer config --global --auth http-basic.gitlab.yireo.com yireo "${{ secrets.GITLAB_TOKEN }}"
24+
composer config repositories.loki-third-party composer https://gitlab.yireo.com/api/v4/group/loki-third-party/-/packages/composer/packages.json
25+
composer config repositories.loki-checkout composer https://gitlab.yireo.com/api/v4/group/loki-checkout/-/packages/composer/packages.json
26+
27+
- name: Add module source
28+
run: |
29+
COMPOSER_NAME=$(grep '^COMPOSER_NAME=' .module.ini | cut -d= -f2- | tr -d '"')
30+
cp -R ${GITHUB_WORKSPACE} /tmp/magento/package-source
31+
cd /tmp/magento
32+
composer config repositories.local-source path package-source/
33+
composer require --prefer-source ${COMPOSER_NAME}:@dev
34+
35+
- name: Run Magento 2 compilation
36+
run: |
37+
cd /tmp/magento
38+
bin/magento module:enable --all
39+
php -dmemory_limit=-1 bin/magento setup:di:compile
40+

.github/workflows/static-tests.yml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@ name: Magento 2 Static Tests
22
on: ['push', 'pull_request']
33

44
jobs:
5-
static-tests:
6-
name: Magento 2 Static Tests
7-
#runs-on: self-hosted
5+
phpcs:
6+
name: Magento PHPCS
7+
runs-on: ubuntu-latest
8+
container:
9+
image: yireo/magento2installed:2.4.8-p3
10+
steps:
11+
- name: Checkout sources
12+
uses: actions/checkout@v4
13+
14+
- name: Run Magento 2 PHPCS Tests
15+
run: |
16+
export PHPCS_LEVEL=$(jq -r '.phpcs_severity // 10' MODULE.json)
17+
test -z "$PHPCS_LEVEL" && PHPCS_LEVEL=10
18+
echo "Testing for PHPCS severity $PHPCS_LEVEL"
19+
cd /tmp/magento
20+
php vendor/bin/phpcs --standard=Magento2 --ignore=Test/,node_modules/ --colors --extensions=php,phtml --severity=$PHPCS_LEVEL ${GITHUB_WORKSPACE}
21+
22+
phpstan:
23+
name: Magento PHPStan
824
runs-on: ubuntu-latest
925
container:
1026
image: yireo/magento2installed:2.4.8-p3
@@ -16,23 +32,30 @@ jobs:
1632
run: |
1733
test -n "${{ secrets.GITLAB_TOKEN }}" || exit 0
1834
cd /tmp/magento
35+
composer config gitlab-domains gitlab.yireo.com
1936
composer config --auth gitlab-token.gitlab.yireo.com ${{ secrets.GITLAB_TOKEN }}
2037
composer config repositories.loki-checkout composer https://gitlab.yireo.com/api/v4/group/loki-checkout/-/packages/composer/packages.json
2138
2239
- name: Add module source
2340
run: |
2441
export COMPOSER_NAME=`cat .module.ini | grep COMPOSER_NAME | cut -f2 -d= | tr -d '"'`
42+
export COMPOSER_DEV_REQUIREMENTS=`jq -r '.["require-dev"] // {} | to_entries | map("\(.key):\(.value)") | join(" ")' composer.json`
2543
cp -R ${GITHUB_WORKSPACE} /tmp/magento/package-source
2644
cd /tmp/magento
2745
composer config repositories.local-source path package-source/
2846
composer config --no-plugins allow-plugins true
47+
composer remove --dev magento/magento-coding-standard
48+
test -z "$COMPOSER_DEV_REQUIREMENTS" || composer require --dev $COMPOSER_DEV_REQUIREMENTS
49+
composer require --dev --prefer-source -- phpstan/phpstan:^2.0 bitexpert/phpstan-magento:^0.42 phpstan/extension-installer
2950
composer require --prefer-source -- ${COMPOSER_NAME}:@dev yireo/magento2-integration-test-helper
30-
composer require --dev --prefer-source -- phpstan/phpstan bitexpert/phpstan-magento phpstan/extension-installer
3151
3252
- name: Run Magento 2 PHPStan Tests
3353
run: |
3454
export COMPOSER_NAME=`cat .module.ini | grep COMPOSER_NAME | cut -f2 -d= | tr -d '"'`
35-
export LEVEL=$(jq -r '.phpstan_level // 1' MODULE.json)
55+
export PHPSTAN_LEVEL=$(jq -r '.phpstan_level // 1' MODULE.json)
56+
test -z "$PHPSTAN_LEVEL" && PHPSTAN_LEVEL=1
3657
test -f /tmp/magento/phpstan.neon || echo 'parameters:' > /tmp/magento/phpstan.neon
37-
php -d memory_limit=4G /tmp/magento/vendor/bin/phpstan analyse --level $LEVEL ${GITHUB_WORKSPACE}
58+
echo "Testing for PHPStan level $PHPSTAN_LEVEL"
59+
cd /tmp/magento
60+
php -d memory_limit=4G vendor/bin/phpstan analyse --level $PHPSTAN_LEVEL ${GITHUB_WORKSPACE}
3861

0 commit comments

Comments
 (0)