Skip to content

Commit 78cb445

Browse files
committed
Add new workflows
1 parent cc77ffb commit 78cb445

File tree

7 files changed

+176
-17
lines changed

7 files changed

+176
-17
lines changed

.github/actions/setup/action.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: 'Setup Magento'
2+
description: 'Setup Magento'
3+
inputs:
4+
php-version:
5+
description: 'PHP version'
6+
required: true
7+
magento-version:
8+
description: 'Magento version'
9+
required: true
10+
outputs:
11+
docker-container-name:
12+
description: 'Docker container name'
13+
value: ${{ steps.variables.outputs.docker_container_name }}
14+
15+
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Install xmllint
20+
shell: bash
21+
run: sudo apt install -y libxml2-utils
22+
23+
- name: Set variables
24+
shell: bash
25+
id: variables
26+
run: |
27+
echo "composer_name=$(cat composer.json | jq .name -r)" >> $GITHUB_OUTPUT
28+
echo "extension_name=$(xmllint --xpath 'string(/config/module/@name)' etc/module.xml)" >> $GITHUB_OUTPUT
29+
echo "directory=$(cat composer.json | jq .name -r | cut -d '/' -f2)" >> $GITHUB_OUTPUT
30+
echo "branch_name=continuous-integration-test-branch-v2" >> $GITHUB_OUTPUT
31+
echo "docker_container_name=magento-project-community-edition" >> $GITHUB_OUTPUT
32+
33+
- name: Start Docker
34+
shell: bash
35+
run: PHP_VERSION=${{ inputs.php-version }} MAGENTO_VERSION=magento${{ inputs.magento-version }} docker compose -f .github/actions/setup/templates/docker-compose.yml up -d
36+
37+
- name: Create branch for Composer
38+
shell: bash
39+
run: git checkout -b ${{ steps.variables.outputs.branch_name }}
40+
41+
- name: Upload our code into the docker container
42+
shell: bash
43+
run: docker cp $(pwd) ${{ steps.variables.outputs.docker_container_name }}:/data/extensions/
44+
45+
- name: Add git safe directory
46+
shell: bash
47+
run: docker exec ${{ steps.variables.outputs.docker_container_name }} git config --global --add safe.directory /data/extensions/${{ steps.variables.outputs.directory }}
48+
49+
- name: Install the extension in Magento
50+
shell: bash
51+
run: docker exec ${{ steps.variables.outputs.docker_container_name }} ./install-composer-package ${{ steps.variables.outputs.composer_name }}:@dev
52+
53+
- name: Install dev dependencies
54+
shell: bash
55+
run: |
56+
docker exec ${{ steps.variables.outputs.docker_container_name }} bash -c "composer require --dev vendic/magento-coding-standard tddwizard/magento2-fixtures"
57+
58+
- name: Activate the extension
59+
shell: bash
60+
run: docker exec ${{ steps.variables.outputs.docker_container_name }} ./retry "php bin/magento module:enable ${{ steps.variables.outputs.extension_name }}"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
image: mysql:5.7
6+
environment:
7+
MYSQL_ROOT_PASSWORD: root_password
8+
MYSQL_DATABASE: magento-test
9+
MYSQL_USER: magento
10+
MYSQL_PASSWORD: magento
11+
MYSQL_SQL_TO_RUN: 'GRANT ALL ON *.* TO "root"@"%";'
12+
web:
13+
image: michielgerritsen/magento-project-community-edition:${PHP_VERSION}-${MAGENTO_VERSION}
14+
container_name: magento-project-community-edition
15+
depends_on:
16+
- db
17+
volumes:
18+
- ./:/data/extensions/workdir

.github/workflows/integration.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
name: Integration Test
2-
1+
name: Integration
32
on: [push]
43

54
jobs:
6-
compute_matrix:
5+
integration:
6+
strategy:
7+
matrix:
8+
include:
9+
- PHP_VERSION: php83-fpm
10+
MAGENTO_VERSION: 2.4.7
711
runs-on: ubuntu-latest
8-
outputs:
9-
matrix: ${{ steps.supported-version.outputs.matrix }}
1012
steps:
11-
- uses: mage-os/github-actions/supported-version@main
12-
id: supported-version
13+
- uses: actions/checkout@v4
14+
15+
- uses: ./.github/actions/setup
16+
name: Setup Magento community edition
17+
id: setup
1318
with:
14-
kind: latest
15-
- run: echo ${{ steps.supported-version.outputs.matrix }}
19+
php-version: ${{ matrix.PHP_VERSION }}
20+
magento-version: ${{ matrix.MAGENTO_VERSION }}
21+
22+
- name: Run tests
23+
run: docker exec ${{ steps.setup.outputs.docker-container-name }} bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit"
1624

17-
integration-workflow:
18-
needs: compute_matrix
19-
uses: mage-os/github-actions/.github/workflows/integration.yaml@main
20-
with:
21-
package_name: vendic/magento2-postnl-api
22-
matrix: ${{ needs.compute_matrix.outputs.matrix }}
23-
test_command: ../../../vendor/bin/phpunit ../../../vendor/vendic/magento2-postnl-api/Test/Integration
24-
fail-fast: false

.github/workflows/phpcs.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Phpcs
2+
on: [push]
3+
4+
jobs:
5+
phpcs:
6+
strategy:
7+
matrix:
8+
include:
9+
- PHP_VERSION: php83-fpm
10+
MAGENTO_VERSION: 2.4.7
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: ./.github/actions/setup
16+
name: Setup Magento community edition
17+
id: setup
18+
with:
19+
php-version: ${{ matrix.PHP_VERSION }}
20+
magento-version: ${{ matrix.MAGENTO_VERSION }}
21+
22+
- name: Run tests
23+
run: docker exec ${{ steps.setup.outputs.docker-container-name }} bash -c "cd /data/ && ./vendor/bin/phpcs --standard=VendicMagento2 /data/extensions/"
24+

.github/workflows/phpstan.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: phpstan
2+
on: [push]
3+
4+
jobs:
5+
phpstan:
6+
strategy:
7+
matrix:
8+
include:
9+
- PHP_VERSION: php83-fpm
10+
MAGENTO_VERSION: 2.4.7
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: ./.github/actions/setup
16+
name: Setup Magento community edition
17+
id: setup
18+
with:
19+
php-version: ${{ matrix.PHP_VERSION }}
20+
magento-version: ${{ matrix.MAGENTO_VERSION }}
21+
22+
- name: Run PHPStan
23+
run: docker exec ${{ steps.setup.outputs.docker-container-name }} /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Run setup:di:compile
2+
on: [push]
3+
4+
jobs:
5+
compilation:
6+
strategy:
7+
matrix:
8+
include:
9+
- PHP_VERSION: php83-fpm
10+
MAGENTO_VERSION: 2.4.7
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: ./.github/actions/setup
16+
name: Setup Magento community edition
17+
id: setup
18+
with:
19+
php-version: ${{ matrix.PHP_VERSION }}
20+
magento-version: ${{ matrix.MAGENTO_VERSION }}
21+
22+
- name: Run setup:di:compile
23+
run: docker exec ${{ steps.setup.outputs.docker-container-name }} ./retry "php bin/magento setup:di:compile"

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
level: 5
3+
reportUnmatchedIgnoredErrors: false
4+
ignoreErrors:
5+
- '#Variable \$block might not be defined.#'
6+
- '#Undefined variable: \$block#'
7+
fileExtensions:
8+
- php
9+
- phtml
10+
excludes_analyse:
11+
- Test/*

0 commit comments

Comments
 (0)