mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
feat(check-extension): add new check-extension workflow (#201)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
name: Check Extension Test
|
||||
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "_test/demo-package/**"
|
||||
- ".github/workflows/_internal_check_extension.yaml"
|
||||
- ".github/workflows/check-extension.yaml"
|
||||
- "supported-version/**"
|
||||
- "!(**/*.md)"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "_test/demo-package/**"
|
||||
- ".github/workflows/_internal_check_extension.yaml"
|
||||
- ".github/workflows/check-extension.yaml"
|
||||
- "supported-version/**"
|
||||
- "!(**/*.md)"
|
||||
jobs:
|
||||
compute_matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.supported-version.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./supported-version
|
||||
with:
|
||||
kind: currently-supported
|
||||
id: supported-version
|
||||
check-workflow:
|
||||
needs: compute_matrix
|
||||
uses: ./.github/workflows/check-extension.yaml
|
||||
with:
|
||||
path: _test/demo-package
|
||||
matrix: ${{ needs.compute_matrix.outputs.matrix }}
|
||||
@@ -0,0 +1,49 @@
|
||||
# MageCheck Extension
|
||||
|
||||
A Github Workflow that runs various kinds of quality checks for a Magento Extension.
|
||||
|
||||
## Inputs
|
||||
|
||||
See the [check-extension.yaml](./check-extension.yaml)
|
||||
|
||||
| Input | Description | Required | Default |
|
||||
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------------------------- |
|
||||
| matrix | JSON string of [version matrix for Magento](./#matrix-format) | true | NULL |
|
||||
| fail-fast | Same as Github's [fail-fast](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast) | false | true |
|
||||
| path | The folder of the Magento store or extension that you are testing | false | . |
|
||||
| magento_repository | Where to install Magento from | false | https://mirror.mage-os.org/ |
|
||||
| composer_cache_key | A key to version the composer cache. Can be incremented if you need to bust the cache. | false | \_mageos |
|
||||
|
||||
### Matrix Format
|
||||
|
||||
The Magento matrix format outlined by the [supported versions action.](https://github.com/graycoreio/github-actions-magento2/tree/main/supported-version/supported.json)
|
||||
|
||||
## Usage
|
||||
|
||||
```yml
|
||||
name: Unit Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
compute_matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.supported-version.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: graycoreio/github-actions-magento2/supported-version@main
|
||||
id: supported-version
|
||||
- run: echo ${{ steps.supported-version.outputs.matrix }}
|
||||
check-extension:
|
||||
needs: compute_matrix
|
||||
uses: graycoreio/github-actions-magento2/.github/workflows/check-extension.yaml@main
|
||||
with:
|
||||
matrix: ${{ needs.compute_matrix.outputs.matrix }}
|
||||
```
|
||||
@@ -0,0 +1,90 @@
|
||||
name: MageCheck Extension
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
path:
|
||||
type: string
|
||||
required: false
|
||||
default: "."
|
||||
description: "The folder of the Magento store or extension that you are testing."
|
||||
|
||||
magento_repository:
|
||||
type: string
|
||||
required: false
|
||||
default: "https://mirror.mage-os.org/"
|
||||
description: "Where to install Magento from"
|
||||
|
||||
matrix:
|
||||
type: string
|
||||
required: true
|
||||
description: "The matrix of Magento versions to test against"
|
||||
|
||||
fail-fast:
|
||||
type: boolean
|
||||
required: false
|
||||
default: true
|
||||
|
||||
composer_cache_key:
|
||||
type: string
|
||||
required: false
|
||||
default: "_mageos"
|
||||
description: A key to version the composer cache. Can be incremented if you need to bust the cache.
|
||||
jobs:
|
||||
unit-test-extension:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix: ${{ fromJSON(inputs.matrix) }}
|
||||
fail-fast: ${{ inputs.fail-fast }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: graycoreio/github-actions-magento2/setup-magento@main
|
||||
id: setup-magento
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
tools: composer:v${{ matrix.composer }}
|
||||
mode: extension
|
||||
magento_version: ${{ matrix.magento }}
|
||||
magento_repository: ${{ inputs.magento_repository }}
|
||||
|
||||
- uses: graycoreio/github-actions-magento2/cache-magento@main
|
||||
with:
|
||||
mode: extension
|
||||
composer_cache_key: ${{ inputs.composer_cache_key }}
|
||||
|
||||
- name: Add extension repository
|
||||
working-directory: ${{ steps.setup-magento.outputs.path }}
|
||||
run: composer config repositories.local path ${{ github.workspace }}/${{ inputs.path }}
|
||||
|
||||
- name: Get package name
|
||||
id: package
|
||||
run: echo "name=$(jq -r .name ${{ github.workspace }}/${{ inputs.path }}/composer.json)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Require extension
|
||||
working-directory: ${{ steps.setup-magento.outputs.path }}
|
||||
run: composer require "${{ steps.package.outputs.name }}:@dev" --no-install
|
||||
|
||||
- name: Composer install
|
||||
working-directory: ${{ steps.setup-magento.outputs.path }}
|
||||
run: composer install
|
||||
|
||||
- name: Configure phpunit.xml.dist
|
||||
working-directory: ${{ steps.setup-magento.outputs.path }}
|
||||
run: |
|
||||
## Add the testsuite
|
||||
cat > /tmp/testsuite.xml << 'EOF'
|
||||
<testsuite name="Extension_Unit_Tests">
|
||||
<directory>../../../vendor/${{ steps.package.outputs.name }}/Test/Unit</directory>
|
||||
</testsuite>
|
||||
EOF
|
||||
sed -i '/<testsuites>/r /tmp/testsuite.xml' dev/tests/unit/phpunit.xml.dist
|
||||
|
||||
## Disable allure (See https://github.com/magento/magento2/issues/36702 )
|
||||
## (╯°□°)╯︵ ┻━┻
|
||||
sed -i '/<extensions>/,/<\/extensions>/d' dev/tests/unit/phpunit.xml.dist
|
||||
|
||||
- name: Run extension unit tests
|
||||
working-directory: ${{ steps.setup-magento.outputs.path }}
|
||||
run: vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist --testsuite Extension_Unit_Tests
|
||||
|
||||
|
||||
@@ -11,15 +11,16 @@
|
||||
|
||||
Opinionated Github Actions and Workflows to make building, testing, and maintaining Magento 2 Modules easier.
|
||||
|
||||
* [README if you are new to Github Actions.](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#the-components-of-github-actions)
|
||||
* [What is a workflow?](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#workflows)
|
||||
* [What is an action?](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#actions)
|
||||
- [README if you are new to Github Actions.](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#the-components-of-github-actions)
|
||||
- [What is a workflow?](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#workflows)
|
||||
- [What is an action?](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#actions)
|
||||
|
||||
## Workflows
|
||||
|
||||
| Workflow Name | Description |
|
||||
| ------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
||||
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
||||
| [Integration Test](./.github/workflows/integration-README.md) | A Github Workflow that runs the Integration Tests of a Magento Package |
|
||||
| [MageCheck Extension](./.github/workflows/check-extension-README.md) | A Github Workflow that runs various kinds of quality checks for a Magento Extension. |
|
||||
|
||||
## Actions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user