Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Opinionated Github Actions and Workflows to make building, testing, and maintain

| Action Name | Description |
| ------------------------------------------------------ | ----------------------------------------------------------------------------------------- |
| [Unit Test](./unit-test/README.md) | A Github Action that runs the Unit Tests a Magento Package |
| [Unit Test](./unit-test/README.md) | A Github Action that runs the Unit Tests of a Magento Package |
| [Static Test](./static-test/README.md) | A Github Action that runs the Static Tests of a Magento Package |
| [Fix Magento Install](./fix-magento-install/README.md) | A Github Action that fixes Magento before `composer install` |
| [Cache Magento](./cache-magento/README.md) | A Github Action that creates a composer cache for a Magento extension or store. |
| [Setup Magento](./setup-magento/README.md) | A Github Action that sets up Magento before `composer install` for an extension or store. |
Expand Down
36 changes: 36 additions & 0 deletions static-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Magento 2 Static Test Action

A GitHub Action that runs the Static Tests of a Magento Package

## Inputs

See the [action.yml](./action.yml)

## Usage

```yml
name: Static Test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
static-test:
strategy:
matrix:
php_version:
- 7.4
- 8.1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: graycoreio/github-actions-magento2/static-test@main
with:
php_version: ${{ matrix.php_version }}
composer_auth: ${{ secrets.COMPOSER_AUTH }}
```
63 changes: 63 additions & 0 deletions static-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Static Test"
author: "Graycore"
description: "A GitHub Action that runs the Static 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: false
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 "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: "Cache Composer Packages"
uses: actions/cache@v3
with:
key: "composer | v3 | ${{ hashFiles('composer.lock') }} | ${{ runner.os }} | ${{ 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 Static 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"