Skip to content

Commit 060c0e3

Browse files
committed
feat(setup-install): create new action
1 parent 51c6533 commit 060c0e3

12 files changed

Lines changed: 594 additions & 2 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Setup Install Test
2+
3+
on:
4+
workflow_dispatch: {}
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- "_test/demo-package/**"
10+
- "setup-install/**"
11+
- ".github/workflows/_internal-setup-install.yaml"
12+
- "supported-version/**"
13+
- "!(**/*.md)"
14+
pull_request:
15+
branches:
16+
- main
17+
paths:
18+
- "_test/demo-package/**"
19+
- "setup-install/**"
20+
- ".github/workflows/_internal-setup-install.yaml"
21+
- "supported-version/**"
22+
- "!(**/*.md)"
23+
24+
jobs:
25+
compute_matrix:
26+
if: "!startsWith(github.head_ref, 'release-please')"
27+
runs-on: ubuntu-latest
28+
outputs:
29+
matrix: ${{ steps.supported-version.outputs.matrix }}
30+
steps:
31+
- uses: actions/checkout@v6
32+
- uses: ./supported-version
33+
id: supported-version
34+
with:
35+
kind: currently-supported
36+
include_services: true
37+
38+
setup-install:
39+
needs: compute_matrix
40+
strategy:
41+
matrix: ${{ fromJSON(needs.compute_matrix.outputs.matrix) }}
42+
fail-fast: false
43+
runs-on: ${{ matrix.os }}
44+
services: ${{ matrix.services }}
45+
steps:
46+
- uses: actions/checkout@v6
47+
48+
- uses: ./setup-magento
49+
id: setup-magento
50+
with:
51+
php-version: ${{ matrix.php }}
52+
tools: composer:v${{ matrix.composer }}
53+
mode: extension
54+
magento_version: ${{ matrix.magento }}
55+
magento_repository: "https://mirror.mage-os.org/"
56+
composer_auth: ${{ secrets.COMPOSER_AUTH }}
57+
58+
- uses: ./cache-magento
59+
with:
60+
composer_cache_key: ${{ matrix.magento }}
61+
62+
- name: Add extension repository
63+
working-directory: ${{ steps.setup-magento.outputs.path }}
64+
run: composer config repositories.local path ${{ github.workspace }}/_test/demo-package
65+
66+
- name: Get package name
67+
id: package
68+
run: echo "name=$(jq -r .name ${{ github.workspace }}/_test/demo-package/composer.json)" >> $GITHUB_OUTPUT
69+
70+
- name: Require extension
71+
working-directory: ${{ steps.setup-magento.outputs.path }}
72+
run: composer require "${{ steps.package.outputs.name }}:@dev" --no-install
73+
74+
- name: Composer install
75+
working-directory: ${{ steps.setup-magento.outputs.path }}
76+
run: composer install
77+
env:
78+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
79+
COMPOSER_MIRROR_PATH_REPOS: 1
80+
81+
- uses: ./setup-install
82+
with:
83+
services: ${{ toJSON(matrix.services) }}
84+
path: ${{ steps.setup-magento.outputs.path }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ Opinionated Github Actions and Workflows to make building, testing, and maintain
3333
| [Installation Test](./installation-test/README.md) | A Github Action that tests the installability of a Magento Package |
3434
| [Semver Compare](./semver-compare/README.md) | A Github Action that semantically compares two versions |
3535
| [Supported Version](./supported-version/README.md) | A Github Action that computes the currently supported Github Actions Matrix for Magento 2 |
36+
| [Setup Install](./setup-install/README.md) | A Github Action that runs `bin/magento setup:install` from the supported-version services matrix |

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.7.3",
44
"description": "Github Actions for Magento 2",
55
"scripts": {
6-
"test": "cd supported-version && npm run test && cd -",
6+
"test": "cd supported-version && npm run test && cd - && cd setup-install && npm run test && cd -",
77
"release": "standard-version"
88
},
99
"private": true,
@@ -18,7 +18,8 @@
1818
},
1919
"homepage": "https://github.com/mage-os/github-actions#readme",
2020
"dependencies": {
21-
"@actions/core": "^1.10.0"
21+
"@actions/core": "^1.10.0",
22+
"@actions/exec": "^3.0.0"
2223
},
2324
"devDependencies": {
2425
"@types/jest": "^29.5.14",

setup-install/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Setup Install
2+
3+
A GitHub Action that runs `bin/magento setup:install` using the services configuration from the [`supported-version`](../supported-version/README.md) matrix output. Database and service credentials are read directly from the service configuration of `supported-version`, so they stay in sync with the running containers automatically.
4+
5+
## Inputs
6+
7+
| Input | Required | Default | Description |
8+
| ------------ | -------- | ------- | ----------------------------------------------------------- |
9+
| `services` | No | `null` | JSON services object from `supported-version` matrix output |
10+
| `path` | No | `.` | Path to the Magento root directory |
11+
| `extra_args` | No | `""` | Additional arguments to append to `setup:install` |
12+
13+
## Outputs
14+
15+
| Output | Description |
16+
| --------- | --------------------------------------------------------- |
17+
| `command` | The full `bin/magento setup:install` command that was run |
18+
19+
## Usage
20+
21+
This action is designed to work with [`supported-version`](../supported-version/README.md) (with `include_services: true`) and [`setup-magento`](../setup-magento/README.md).
22+
23+
```yml
24+
name: Install Test
25+
26+
on:
27+
push:
28+
branches: [main]
29+
pull_request:
30+
branches: [main]
31+
32+
jobs:
33+
compute_matrix:
34+
runs-on: ubuntu-latest
35+
outputs:
36+
matrix: ${{ steps.supported-version.outputs.matrix }}
37+
steps:
38+
- uses: actions/checkout@v6
39+
- uses: mage-os/github-actions-magento2/supported-version@main
40+
id: supported-version
41+
with:
42+
include_services: "true"
43+
44+
install:
45+
needs: compute_matrix
46+
runs-on: ${{ matrix.os }}
47+
services: ${{ matrix.services }}
48+
strategy:
49+
fail-fast: false
50+
matrix: ${{ fromJSON(needs.compute_matrix.outputs.matrix) }}
51+
steps:
52+
- uses: actions/checkout@v6
53+
54+
- uses: mage-os/github-actions-magento2/setup-magento@main
55+
id: setup-magento
56+
with:
57+
php-version: ${{ matrix.php }}
58+
tools: composer:v${{ matrix.composer }}
59+
env:
60+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
61+
62+
- run: composer install
63+
working-directory: ${{ steps.setup-magento.outputs.path }}
64+
env:
65+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
66+
67+
- uses: mage-os/github-actions-magento2/setup-install@main
68+
with:
69+
services: ${{ toJSON(matrix.services) }}
70+
path: ${{ steps.setup-magento.outputs.path }}
71+
```

setup-install/action.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "Magento setup:install"
2+
author: "MageOS"
3+
description: "A GitHub Action that runs bin/magento setup:install, deriving service flags from the supported-version services matrix."
4+
5+
inputs:
6+
services:
7+
required: false
8+
default: "null"
9+
description: "JSON string of the services key from the supported-version matrix entry (toJSON(matrix.services))."
10+
11+
path:
12+
required: false
13+
default: "."
14+
description: "Path to the Magento root directory. Accepts the output of the setup-magento action."
15+
16+
extra_args:
17+
required: false
18+
default: ""
19+
description: "Additional raw flags to append to the setup:install command."
20+
21+
outputs:
22+
command:
23+
description: "The full bin/magento setup:install command that was run."
24+
25+
runs:
26+
using: "node24"
27+
main: "dist/index.js"
28+
29+
branding:
30+
icon: "tool"
31+
color: "orange"

setup-install/dist/index.js

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup-install/jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
clearMocks: true,
3+
moduleFileExtensions: ['js', 'ts'],
4+
testMatch: ['**/*.spec.ts'],
5+
transform: {
6+
'^.+\\.ts$': 'ts-jest'
7+
},
8+
verbose: true
9+
}

setup-install/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@mage-os/github-actions-magento2-setup-install",
3+
"version": "1.0.0",
4+
"description": "A Github Action that runs bin/magento setup:install from the supported-version services matrix",
5+
"main": "index.js",
6+
"private": true,
7+
"scripts": {
8+
"build": "npx esbuild --outfile=dist/index.js --platform=node --bundle --minify src/index.ts",
9+
"test": "jest"
10+
},
11+
"author": "",
12+
"license": "MIT",
13+
"dependencies": {
14+
"@actions/core": "0.0.0-PLACEHOLDER",
15+
"@actions/exec": "0.0.0-PLACEHOLDER"
16+
},
17+
"devDependencies": {
18+
"@types/jest": "0.0.0-PLACEHOLDER",
19+
"jest": "0.0.0-PLACEHOLDER",
20+
"ts-jest": "0.0.0-PLACEHOLDER"
21+
}
22+
}

0 commit comments

Comments
 (0)