Skip to content

Commit

Permalink
Add new workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjitse-E committed Feb 19, 2025
1 parent cc77ffb commit 78cb445
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 17 deletions.
60 changes: 60 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: 'Setup Magento'
description: 'Setup Magento'
inputs:
php-version:
description: 'PHP version'
required: true
magento-version:
description: 'Magento version'
required: true
outputs:
docker-container-name:
description: 'Docker container name'
value: ${{ steps.variables.outputs.docker_container_name }}


runs:
using: "composite"
steps:
- name: Install xmllint
shell: bash
run: sudo apt install -y libxml2-utils

- name: Set variables
shell: bash
id: variables
run: |
echo "composer_name=$(cat composer.json | jq .name -r)" >> $GITHUB_OUTPUT
echo "extension_name=$(xmllint --xpath 'string(/config/module/@name)' etc/module.xml)" >> $GITHUB_OUTPUT
echo "directory=$(cat composer.json | jq .name -r | cut -d '/' -f2)" >> $GITHUB_OUTPUT
echo "branch_name=continuous-integration-test-branch-v2" >> $GITHUB_OUTPUT
echo "docker_container_name=magento-project-community-edition" >> $GITHUB_OUTPUT
- name: Start Docker
shell: bash
run: PHP_VERSION=${{ inputs.php-version }} MAGENTO_VERSION=magento${{ inputs.magento-version }} docker compose -f .github/actions/setup/templates/docker-compose.yml up -d

- name: Create branch for Composer
shell: bash
run: git checkout -b ${{ steps.variables.outputs.branch_name }}

- name: Upload our code into the docker container
shell: bash
run: docker cp $(pwd) ${{ steps.variables.outputs.docker_container_name }}:/data/extensions/

- name: Add git safe directory
shell: bash
run: docker exec ${{ steps.variables.outputs.docker_container_name }} git config --global --add safe.directory /data/extensions/${{ steps.variables.outputs.directory }}

- name: Install the extension in Magento
shell: bash
run: docker exec ${{ steps.variables.outputs.docker_container_name }} ./install-composer-package ${{ steps.variables.outputs.composer_name }}:@dev

- name: Install dev dependencies
shell: bash
run: |
docker exec ${{ steps.variables.outputs.docker_container_name }} bash -c "composer require --dev vendic/magento-coding-standard tddwizard/magento2-fixtures"
- name: Activate the extension
shell: bash
run: docker exec ${{ steps.variables.outputs.docker_container_name }} ./retry "php bin/magento module:enable ${{ steps.variables.outputs.extension_name }}"
18 changes: 18 additions & 0 deletions .github/actions/setup/templates/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'

services:
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: magento-test
MYSQL_USER: magento
MYSQL_PASSWORD: magento
MYSQL_SQL_TO_RUN: 'GRANT ALL ON *.* TO "root"@"%";'
web:
image: michielgerritsen/magento-project-community-edition:${PHP_VERSION}-${MAGENTO_VERSION}
container_name: magento-project-community-edition
depends_on:
- db
volumes:
- ./:/data/extensions/workdir
34 changes: 17 additions & 17 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: Integration Test

name: Integration
on: [push]

jobs:
compute_matrix:
integration:
strategy:
matrix:
include:
- PHP_VERSION: php83-fpm
MAGENTO_VERSION: 2.4.7
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.supported-version.outputs.matrix }}
steps:
- uses: mage-os/github-actions/supported-version@main
id: supported-version
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
name: Setup Magento community edition
id: setup
with:
kind: latest
- run: echo ${{ steps.supported-version.outputs.matrix }}
php-version: ${{ matrix.PHP_VERSION }}
magento-version: ${{ matrix.MAGENTO_VERSION }}

- name: Run tests
run: docker exec ${{ steps.setup.outputs.docker-container-name }} bash -c "cd /data/dev/tests/integration/ && ../../../vendor/bin/phpunit"

integration-workflow:
needs: compute_matrix
uses: mage-os/github-actions/.github/workflows/integration.yaml@main
with:
package_name: vendic/magento2-postnl-api
matrix: ${{ needs.compute_matrix.outputs.matrix }}
test_command: ../../../vendor/bin/phpunit ../../../vendor/vendic/magento2-postnl-api/Test/Integration
fail-fast: false
24 changes: 24 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Phpcs
on: [push]

jobs:
phpcs:
strategy:
matrix:
include:
- PHP_VERSION: php83-fpm
MAGENTO_VERSION: 2.4.7
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
name: Setup Magento community edition
id: setup
with:
php-version: ${{ matrix.PHP_VERSION }}
magento-version: ${{ matrix.MAGENTO_VERSION }}

- name: Run tests
run: docker exec ${{ steps.setup.outputs.docker-container-name }} bash -c "cd /data/ && ./vendor/bin/phpcs --standard=VendicMagento2 /data/extensions/"

23 changes: 23 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: phpstan
on: [push]

jobs:
phpstan:
strategy:
matrix:
include:
- PHP_VERSION: php83-fpm
MAGENTO_VERSION: 2.4.7
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
name: Setup Magento community edition
id: setup
with:
php-version: ${{ matrix.PHP_VERSION }}
magento-version: ${{ matrix.MAGENTO_VERSION }}

- name: Run PHPStan
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"
23 changes: 23 additions & 0 deletions .github/workflows/setup-di-compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run setup:di:compile
on: [push]

jobs:
compilation:
strategy:
matrix:
include:
- PHP_VERSION: php83-fpm
MAGENTO_VERSION: 2.4.7
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
name: Setup Magento community edition
id: setup
with:
php-version: ${{ matrix.PHP_VERSION }}
magento-version: ${{ matrix.MAGENTO_VERSION }}

- name: Run setup:di:compile
run: docker exec ${{ steps.setup.outputs.docker-container-name }} ./retry "php bin/magento setup:di:compile"
11 changes: 11 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
level: 5
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#Variable \$block might not be defined.#'
- '#Undefined variable: \$block#'
fileExtensions:
- php
- phtml
excludes_analyse:
- Test/*

0 comments on commit 78cb445

Please sign in to comment.