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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/_internal-setup-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Setup Install Test

on:
workflow_dispatch: {}
push:
branches:
- main
paths:
- "_test/demo-package/**"
- "setup-install/**"
- ".github/workflows/_internal-setup-install.yaml"
- "supported-version/**"
- "!(**/*.md)"
pull_request:
branches:
- main
paths:
- "_test/demo-package/**"
- "setup-install/**"
- ".github/workflows/_internal-setup-install.yaml"
- "supported-version/**"
- "!(**/*.md)"

jobs:
compute_matrix:
if: "!startsWith(github.head_ref, 'release-please')"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.supported-version.outputs.matrix }}
steps:
- uses: actions/checkout@v6
- uses: ./supported-version
id: supported-version
with:
kind: currently-supported
include_services: true

setup-install:
needs: compute_matrix
strategy:
matrix: ${{ fromJSON(needs.compute_matrix.outputs.matrix) }}
fail-fast: false
runs-on: ${{ matrix.os }}
services: ${{ matrix.services }}
steps:
- uses: actions/checkout@v6

- uses: ./setup-magento
id: setup-magento
with:
php-version: ${{ matrix.php }}
tools: composer:v${{ matrix.composer }}
mode: extension
magento_version: ${{ matrix.magento }}
magento_repository: "https://mirror.mage-os.org/"
composer_auth: ${{ secrets.COMPOSER_AUTH }}

- uses: ./cache-magento
with:
composer_cache_key: ${{ matrix.magento }}

- name: Add extension repository
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer config repositories.local path ${{ github.workspace }}/_test/demo-package

- name: Get package name
id: package
run: echo "name=$(jq -r .name ${{ github.workspace }}/_test/demo-package/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
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
COMPOSER_MIRROR_PATH_REPOS: 1

- uses: ./setup-install
with:
services: ${{ toJSON(matrix.services) }}
path: ${{ steps.setup-magento.outputs.path }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Opinionated Github Actions and Workflows to make building, testing, and maintain
| [Installation Test](./installation-test/README.md) | A Github Action that tests the installability of a Magento Package |
| [Semver Compare](./semver-compare/README.md) | A Github Action that semantically compares two versions |
| [Supported Version](./supported-version/README.md) | A Github Action that computes the currently supported Github Actions Matrix for Magento 2 |
| [Setup Install](./setup-install/README.md) | A Github Action that runs `bin/magento setup:install` from the supported-version services matrix |
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.7.3",
"description": "Github Actions for Magento 2",
"scripts": {
"test": "cd supported-version && npm run test && cd -",
"test": "cd supported-version && npm run test && cd - && cd setup-install && npm run test && cd -",
"release": "standard-version"
},
"private": true,
Expand All @@ -18,7 +18,8 @@
},
"homepage": "https://github.com/mage-os/github-actions#readme",
"dependencies": {
"@actions/core": "^1.10.0"
"@actions/core": "^1.10.0",
"@actions/exec": "^3.0.0"
},
"devDependencies": {
"@types/jest": "^29.5.14",
Expand Down
71 changes: 71 additions & 0 deletions setup-install/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Setup Install

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.

## Inputs

| Input | Required | Default | Description |
| ------------ | -------- | ------- | ----------------------------------------------------------- |
| `services` | No | `null` | JSON services object from `supported-version` matrix output |
| `path` | No | `.` | Path to the Magento root directory |
| `extra_args` | No | `""` | Additional arguments to append to `setup:install` |

## Outputs

| Output | Description |
| --------- | --------------------------------------------------------- |
| `command` | The full `bin/magento setup:install` command that was run |

## Usage

This action is designed to work with [`supported-version`](../supported-version/README.md) (with `include_services: true`) and [`setup-magento`](../setup-magento/README.md).

```yml
name: Install 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@v6
- uses: mage-os/github-actions-magento2/supported-version@main
id: supported-version
with:
include_services: "true"

install:
needs: compute_matrix
runs-on: ${{ matrix.os }}
services: ${{ matrix.services }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.compute_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v6

- uses: mage-os/github-actions-magento2/setup-magento@main
id: setup-magento
with:
php-version: ${{ matrix.php }}
tools: composer:v${{ matrix.composer }}
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

- run: composer install
working-directory: ${{ steps.setup-magento.outputs.path }}
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

- uses: mage-os/github-actions-magento2/setup-install@main
with:
services: ${{ toJSON(matrix.services) }}
path: ${{ steps.setup-magento.outputs.path }}
```
31 changes: 31 additions & 0 deletions setup-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Magento setup:install"
author: "MageOS"
description: "A GitHub Action that runs bin/magento setup:install, deriving service flags from the supported-version services matrix."

inputs:
services:
required: false
default: "null"
description: "JSON string of the services key from the supported-version matrix entry (toJSON(matrix.services))."

path:
required: false
default: "."
description: "Path to the Magento root directory. Accepts the output of the setup-magento action."

extra_args:
required: false
default: ""
description: "Additional raw flags to append to the setup:install command."

outputs:
command:
description: "The full bin/magento setup:install command that was run."

runs:
using: "node24"
main: "dist/index.js"

branding:
icon: "tool"
color: "orange"
69 changes: 69 additions & 0 deletions setup-install/dist/index.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions setup-install/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testMatch: ['**/*.spec.ts'],
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}
22 changes: 22 additions & 0 deletions setup-install/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@mage-os/github-actions-magento2-setup-install",
"version": "1.0.0",
"description": "A Github Action that runs bin/magento setup:install from the supported-version services matrix",
"main": "index.js",
"private": true,
"scripts": {
"build": "npx esbuild --outfile=dist/index.js --platform=node --bundle --minify src/index.ts",
"test": "jest"
},
"author": "",
"license": "MIT",
"dependencies": {
"@actions/core": "0.0.0-PLACEHOLDER",
"@actions/exec": "0.0.0-PLACEHOLDER"
},
"devDependencies": {
"@types/jest": "0.0.0-PLACEHOLDER",
"jest": "0.0.0-PLACEHOLDER",
"ts-jest": "0.0.0-PLACEHOLDER"
}
}
Loading
Loading