Skip to content

Commit 4bc0854

Browse files
authored
feat: add Installation Test Action (#1)
1 parent a6400eb commit 4bc0854

File tree

9 files changed

+246
-0
lines changed

9 files changed

+246
-0
lines changed

.github/workflows/install.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Installation Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- "docs/**"
9+
- README.md
10+
pull_request:
11+
branches:
12+
- main
13+
paths-ignore:
14+
- "docs/**"
15+
- README.md
16+
17+
jobs:
18+
install-test:
19+
strategy:
20+
matrix:
21+
magento:
22+
- magento/project-community-edition:>=2.3 <2.4
23+
- magento/project-community-edition:>=2.4.0 <2.4.1
24+
- magento/project-community-edition:>=2.4.1 <2.4.2
25+
- magento/project-community-edition:>=2.4.2 <2.4.3
26+
- magento/project-community-edition:>=2.4.3 <2.4.4
27+
- magento/project-community-edition:>=2.4.4 <2.4.5
28+
- magento/project-community-edition
29+
include:
30+
31+
- magento: magento/project-community-edition:>=2.3 <2.4
32+
php_version: 7.4
33+
composer_version: 1
34+
35+
- magento: magento/project-community-edition:>=2.4.0 <2.4.1
36+
php_version: 7.4
37+
composer_version: 1
38+
39+
- magento: magento/project-community-edition:>=2.4.1 <2.4.2
40+
php_version: 7.4
41+
composer_version: 1
42+
43+
- magento: magento/project-community-edition:>=2.4.2 <2.4.3
44+
php_version: 7.4
45+
composer_version: 2
46+
47+
- magento: magento/project-community-edition:>=2.4.3 <2.4.4
48+
php_version: 7.4
49+
composer_version: 2
50+
51+
- magento: magento/project-community-edition:>=2.4.4 <2.4.5
52+
php_version: 8.1
53+
composer_version: 2
54+
55+
- magento: magento/project-community-edition
56+
composer_version: 2
57+
php_version: 8.1
58+
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v2
62+
- uses: ./installation-test
63+
with:
64+
composer_version: ${{ matrix.composer_version }}
65+
php_version: ${{ matrix.php_version }}
66+
magento_version: ${{ matrix.magento }}
67+
composer_auth: ${{ secrets.COMPOSER_AUTH }}
68+
package_name: graycore/magento2-demo-package
69+
source_folder: $GITHUB_WORKSPACE/_test/demo-package

_test/demo-package/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/

_test/demo-package/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Magento 2 Demo Package
2+
3+
It does nothing, intentionally...
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Graycore\DemoPackage\Test\Integration;
4+
5+
class TestItWorks extends \PHPUnit\Framework\TestCase
6+
{
7+
8+
public function testItWorks()
9+
{
10+
$this->assertEquals(true, true);
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Graycore\DemoPackage\Test\Unit;
4+
5+
class TestItWorks extends \PHPUnit\Framework\TestCase
6+
{
7+
8+
public function testItWorks()
9+
{
10+
$this->assertEquals(true, true);
11+
}
12+
}

_test/demo-package/composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "graycore/magento2-demo-package",
3+
"description": "A Magento 2 Demostration Package",
4+
"type": "magento2-module",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Damien Retzinger",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"archive": {
13+
"exclude": [
14+
"/docs",
15+
"/Test",
16+
"README.md"
17+
]
18+
},
19+
"minimum-stability": "stable",
20+
"autoload": {
21+
"psr-4": {
22+
"Graycore\\DemoPackage\\": ""
23+
},
24+
"files": [
25+
"registration.php"
26+
]
27+
},
28+
"require": {
29+
"magento/framework": "^102.0 || ^103.0"
30+
},
31+
"repositories": {
32+
"0": {
33+
"type": "composer",
34+
"url": "https://repo.magento.com/"
35+
}
36+
},
37+
"config": {
38+
"preferred-install": "dist",
39+
"sort-packages": true
40+
}
41+
}

_test/demo-package/etc/module.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3+
<module name="Graycore_DemoPackage" setup_version="1.0.0">
4+
<sequence>
5+
<module name="Magento_Framework" />
6+
</sequence>
7+
</module>
8+
</config>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php declare(strict_types=1);
2+
3+
use \Magento\Framework\Component\ComponentRegistrar;
4+
5+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Graycore_DemoPackage', __DIR__);

installation-test/action.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: "Installation Test"
2+
author: "Graycore"
3+
description: " A Github Action that tests the installability of a Magento Package"
4+
5+
inputs:
6+
php_version:
7+
required: true
8+
default: "8.1"
9+
description: "PHP Version to use"
10+
11+
cache_key:
12+
required: true
13+
default: "2"
14+
description: "The cache key used to hold Composer Packages"
15+
16+
composer_version:
17+
required: true
18+
default: "2"
19+
description: "The version of composer to use"
20+
21+
source_folder:
22+
required: true
23+
default: $GITHUB_WORKSPACE
24+
description: "The source folder of the package"
25+
26+
package_name:
27+
required: true
28+
description: "The name of the package"
29+
30+
magento_directory:
31+
required: true
32+
default: "../magento2"
33+
description: "The folder where Magento will be installed"
34+
35+
magento_version:
36+
required: true
37+
default: "magento/project-community-edition"
38+
description: "The version of Magento to test against"
39+
40+
magento_repository:
41+
required: true
42+
default: "https://repo.magento.com/"
43+
description: "Where to install Magento from"
44+
45+
composer_auth:
46+
required: true
47+
description: "Composer Authentication Credentials"
48+
49+
runs:
50+
using: "composite"
51+
steps:
52+
- name: Set PHP Version
53+
uses: shivammathur/setup-php@v2
54+
with:
55+
php-version: ${{ inputs.php_version }}
56+
57+
- run: composer self-update --${{ inputs.composer_version }}
58+
name: Pin to Composer Version ${{ inputs.composer_version }}
59+
shell: bash
60+
61+
- run: composer create-project --repository-url="${{ inputs.magento_repository }}" "${{ inputs.magento_version }}" ${{ inputs.magento_directory }} --no-install
62+
shell: bash
63+
env:
64+
COMPOSER_AUTH: ${{ inputs.composer_auth }}
65+
name: Create Magento ${{ inputs.magento_version }} Project
66+
67+
- name: Get Composer Cache Directory
68+
shell: bash
69+
working-directory: ${{ inputs.magento_directory }}
70+
id: composer-cache
71+
run: |
72+
echo "::set-output name=dir::$(composer config cache-files-dir)"
73+
74+
- name: "Cache Composer Packages"
75+
uses: actions/cache@v3
76+
with:
77+
key: 'composer | v3 | "$(Agent.OS)" | composer.lock | ${{ inputs.composer_version }} | ${{ inputs.php_version }} | ${{ inputs.magento_version }}'
78+
path: ${{ steps.composer-cache.outputs.dir }}
79+
80+
- run: composer config repositories.local path ${{ inputs.source_folder }}
81+
name: Add Github Repo for Testing
82+
working-directory: ${{ inputs.magento_directory }}
83+
shell: bash
84+
85+
- run: composer require ${{ inputs.package_name }} "@dev" --no-update && composer install
86+
name: Require and attempt install
87+
working-directory: ${{ inputs.magento_directory }}
88+
shell: bash
89+
env:
90+
COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }}
91+
COMPOSER_AUTH: ${{ inputs.composer_auth }}
92+
93+
branding:
94+
icon: "code"
95+
color: "green"

0 commit comments

Comments
 (0)