88 name : Code Sniffer
99 runs-on : ubuntu-latest
1010 steps :
11- - uses : actions/checkout@v1
11+ - uses : actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
1212
1313 # ###########################################################################
1414 - name : Set up PHP
1515 uses : shivammathur/setup-php@v2
1616 with :
17- php-version : ' 7.4 '
17+ php-version : ' 8.2 '
1818 tools : composer:v2
1919 extensions : ast, bcmath, gd
2020 coverage : none
2424 id : composer-cache
2525 run : |
2626 composer config cache-files-dir
27- echo "::set-output name= dir:: $(composer config cache-files-dir)"
27+ echo "dir= $(composer config cache-files-dir)" >> "$GITHUB_OUTPUT "
2828 - uses : actions/cache@v4
2929 with :
3030 path : ${{ steps.composer-cache.outputs.dir }}
3939 run : |
4040 composer config repositories.0 composer https://repo.magento.com
4141 composer config http-basic.repo.magento.com "$REPO_USR" "$REPO_PSW"
42- composer install --prefer-dist --no-progress --no-suggest
42+ composer install --prefer-dist --no-progress
4343 # ###########################################################################
4444
4545 - name : Run the sniffer
@@ -56,19 +56,19 @@ jobs:
5656
5757 - name : Report annotations
5858 id : report-annotations
59- run : ./vendor/bin/cs2pr chkphpcs.xml
59+ run : ./vendor/bin/cs2pr --graceful-warnings chkphpcs.xml
6060
6161 phpmd :
6262 name : Mess Detect
6363 runs-on : ubuntu-latest
6464 steps :
65- - uses : actions/checkout@v1
65+ - uses : actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
6666
6767 # ###########################################################################
6868 - name : Set up PHP
6969 uses : shivammathur/setup-php@v2
7070 with :
71- php-version : ' 7.4 '
71+ php-version : ' 8.2 '
7272 tools : composer:v2
7373 extensions : ast, bcmath, gd
7474 coverage : none
7878 id : composer-cache
7979 run : |
8080 composer config cache-files-dir
81- echo "::set-output name= dir:: $(composer config cache-files-dir)"
81+ echo "dir= $(composer config cache-files-dir)" >> "$GITHUB_OUTPUT "
8282 - uses : actions/cache@v4
8383 with :
8484 path : ${{ steps.composer-cache.outputs.dir }}
9393 run : |
9494 composer config repositories.0 composer https://repo.magento.com
9595 composer config http-basic.repo.magento.com "$REPO_USR" "$REPO_PSW"
96- composer install --prefer-dist --no-progress --no-suggest
96+ composer install --prefer-dist --no-progress
9797 # ###########################################################################
9898
9999 - name : Run the mess detector
@@ -105,30 +105,50 @@ jobs:
105105 name : phpmd-xml-result
106106 path : pmdphpmd.xml
107107
108- - name : Report annotations
109- id : report-annotations
110- run : ./vendor/bin/pmd2pr --graceful-warnings pmdphpmd.xml
108+ - name : Detect code standard violations
109+ if : always() && hashFiles('pmdphpmd.xml') != ''
110+ # pmd2pr came from mridang/pmd-annotations, which caps at php ^7.0 and so
111+ # cannot be installed on 8.2. Emit the GitHub annotations directly instead.
112+ run : |
113+ php -r "
114+ \$xml = @simplexml_load_file('pmdphpmd.xml');
115+ if (\$xml === false) { exit(0); }
116+ \$workspace = rtrim(getenv('GITHUB_WORKSPACE') ?: '', '/');
117+ foreach (\$xml->file as \$file) {
118+ \$filepath = (string)\$file['name'];
119+ if (\$workspace !== '' && strpos(\$filepath, \$workspace . '/') === 0) {
120+ \$filepath = substr(\$filepath, strlen(\$workspace) + 1);
121+ }
122+ \$filepath = str_replace(['%', \"\r\", \"\n\"], ['%25', '%0D', '%0A'], \$filepath);
123+ foreach (\$file->violation as \$violation) {
124+ \$line = (int)\$violation['beginline'];
125+ \$msg = trim((string)\$violation);
126+ \$msg = str_replace(['%', \"\r\", \"\n\"], ['%25', '%0D', '%0A'], \$msg);
127+ echo \"::notice file={\$filepath},line={\$line}::PHPMD: {\$msg}\n\";
128+ }
129+ }
130+ " || true
111131
112132 package :
113133 name : Package
114134 runs-on : ubuntu-latest
115135 steps :
116- - uses : actions/checkout@v1
136+ - uses : actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
117137
118138 # ###########################################################################
119139 - name : Set up PHP
120140 uses : shivammathur/setup-php@v2
121141 with :
122- php-version : ' 7.4 '
123- tools : composer:v2.1.14 , pecl
142+ php-version : ' 8.2 '
143+ tools : composer:v2, pecl
124144 extensions : ast, bcmath, gd
125145 coverage : none
126146
127147 # https://github.com/actions/cache/blob/master/examples.md#php---composer
128148 - name : Cache composer packages
129149 id : composer-cache
130150 run : |
131- echo "::set-output name= dir:: $(composer config cache-files-dir)"
151+ echo "dir= $(composer config cache-files-dir)" >> "$GITHUB_OUTPUT "
132152 - uses : actions/cache@v4
133153 with :
134154 path : ${{ steps.composer-cache.outputs.dir }}
@@ -143,17 +163,83 @@ jobs:
143163 run : |
144164 composer config repositories.0 composer https://repo.magento.com
145165 composer config http-basic.repo.magento.com "$REPO_USR" "$REPO_PSW"
166+ # The companion Nosto modules are declared with --no-update on purpose: the
167+ # constraints are written into the archived composer.json without being
168+ # resolved. Resolving is unnecessary here (`composer archive` only zips this
169+ # package's own files and needs no vendor/) and would fail the lock
170+ # consistency check, since these packages are deliberately not in composer.lock.
146171 composer require --no-update nosto/module-nostotagging:@stable
147172 composer require --no-update nosto/module-nosto-msi:@stable
148173 composer require --no-update nosto/module-nosto-itp:@stable
149- composer install --prefer-dist --no-progress --no-suggest
150174 # ###########################################################################
151175
152176 - name : Build archive using composer
153177 run : composer archive --format=zip --file=archive
154178
155- - name : Archive built arhive
179+ - name : Archive built archive
156180 uses : actions/upload-artifact@v4
157181 with :
158182 name : composer-zip-archive
159183 path : archive.zip
184+
185+ # Magento 2.4.8 pins php to ~8.2.0||~8.3.0||~8.4.0, so a normal Magento install cannot
186+ # run on 8.5 yet. This lane runs on PHP 8.5 without installing Magento; it only lints the
187+ # repository and runs PHPCompatibility in an isolated directory to keep the module 8.5-clean
188+ # ahead of Magento allowing 8.5.
189+ php-compat :
190+ name : PHP 8.2-8.5 Compatibility
191+ runs-on : ubuntu-latest
192+ steps :
193+ - uses : actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
194+
195+ - name : Set up PHP
196+ uses : shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
197+ with :
198+ php-version : ' 8.5'
199+ tools : composer:v2
200+ coverage : none
201+
202+ - name : Cache composer packages
203+ id : composer-cache
204+ run : |
205+ composer config cache-files-dir
206+ echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
207+ - uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
208+ with :
209+ path : ${{ steps.composer-cache.outputs.dir }}
210+ key : ${{ runner.os }}-composer-phpcompat-${{ hashFiles('**/composer.json') }}
211+ restore-keys : |
212+ ${{ runner.os }}-composer-phpcompat-
213+
214+ - name : Lint every source file under PHP 8.5
215+ run : |
216+ find . -path ./vendor -prune -o \( -name '*.php' -o -name '*.phtml' \) -print0 \
217+ | xargs -0 -n1 -P4 php -l > /dev/null
218+
219+ - name : Install PHPCompatibility (isolated)
220+ run : |
221+ # magento/magento-coding-standard pulls magento/php-compatibility-fork, which
222+ # `replace`s phpcompatibility/php-compatibility with a 9.x-era fork that does
223+ # NOT implement the PHP 8.4/8.5 sniffs - it detects only 1 of 4 known 8.2-8.5
224+ # deprecations. Install the real sniffs in an isolated directory so this gate
225+ # actually has teeth. This also avoids needing a Magento install here at all.
226+ mkdir -p "$RUNNER_TEMP/phpcompat"
227+ composer --working-dir="$RUNNER_TEMP/phpcompat" init --no-interaction --name=tmp/phpcompat
228+ composer --working-dir="$RUNNER_TEMP/phpcompat" config \
229+ allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
230+ composer --working-dir="$RUNNER_TEMP/phpcompat" require --no-interaction --quiet \
231+ squizlabs/php_codesniffer:^3.13 \
232+ phpcompatibility/php-compatibility:^10.0@alpha \
233+ staabm/annotate-pull-request-from-checkstyle:^1.1
234+
235+ - name : Run the compatibility sniffs
236+ run : |
237+ PHPCS="$RUNNER_TEMP/phpcompat/vendor/bin/phpcs"
238+ "$PHPCS" --standard=ruleset-phpcompat.xml \
239+ --report=checkstyle --report-file=chkphpcompat.xml || true
240+ "$PHPCS" --standard=ruleset-phpcompat.xml --report=full
241+
242+ - name : Report annotations
243+ if : always() && hashFiles('chkphpcompat.xml') != ''
244+ run : |
245+ "$RUNNER_TEMP/phpcompat/vendor/bin/cs2pr" chkphpcompat.xml
0 commit comments