mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
feat: add unit test action (#2)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
name: Unit Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- "docs/**"
|
||||
- README.md
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- "docs/**"
|
||||
- README.md
|
||||
|
||||
jobs:
|
||||
install-test:
|
||||
strategy:
|
||||
matrix:
|
||||
php_version:
|
||||
- 7.4
|
||||
- 8.1
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./unit-test
|
||||
with:
|
||||
source_folder: _test/demo-package
|
||||
php_version: ${{ matrix.php_version }}
|
||||
composer_auth: ${{ secrets.COMPOSER_AUTH }}
|
||||
@@ -9,6 +9,9 @@
|
||||
"email": "damienwebdev@gmail.com"
|
||||
}
|
||||
],
|
||||
"scripts": {
|
||||
"test": "./vendor/bin/phpunit Test/Unit"
|
||||
},
|
||||
"archive": {
|
||||
"exclude": [
|
||||
"/docs",
|
||||
@@ -37,5 +40,8 @@
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
colors="true"
|
||||
columns="max"
|
||||
beStrictAboutTestsThatDoNotTestAnything="false">
|
||||
<php>
|
||||
<ini name="memory_limit" value="-1"/>
|
||||
<ini name="date.timezone" value="America/Los_Angeles"/>
|
||||
<ini name="xdebug.max_nesting_level" value="200"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
@@ -0,0 +1,63 @@
|
||||
name: "Unit Test"
|
||||
author: "Graycore"
|
||||
description: "A Github Action that runs the Unit Tests of a Magento Package"
|
||||
inputs:
|
||||
php_version:
|
||||
required: true
|
||||
default: "8.1"
|
||||
description: "PHP Version to use"
|
||||
|
||||
source_folder:
|
||||
required: true
|
||||
default: .
|
||||
description: "The source folder of the package"
|
||||
|
||||
test_command:
|
||||
required: true
|
||||
default: composer run test
|
||||
description: "The test command"
|
||||
|
||||
composer_auth:
|
||||
required: true
|
||||
description: "Composer Authentication Credentials"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Set PHP Version
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ inputs.php_version }}
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.source_folder }}
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: "Cache Composer Packages"
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
key: 'composer | v3 | "$(Agent.OS)" | composer.lock | ${{ inputs.php_version }}'
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
|
||||
- run: composer install
|
||||
name: Require and attempt install
|
||||
working-directory: ${{ inputs.source_folder }}
|
||||
shell: bash
|
||||
env:
|
||||
COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }}
|
||||
COMPOSER_AUTH: ${{ inputs.composer_auth }}
|
||||
|
||||
- run: ${{ inputs.test_command }}
|
||||
name: Run Unit Tests
|
||||
working-directory: ${{ inputs.source_folder }}
|
||||
shell: bash
|
||||
env:
|
||||
COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }}
|
||||
COMPOSER_AUTH: ${{ inputs.composer_auth }}
|
||||
|
||||
branding:
|
||||
icon: "code"
|
||||
color: "green"
|
||||
Reference in New Issue
Block a user