Skip to content

Commit

Permalink
nested compose action
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Nov 3, 2023
1 parent f944f63 commit b5fe0be
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 51 deletions.
55 changes: 55 additions & 0 deletions .github/composite-actions/setup-php-with-composer-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Setup PHP with Composer deps"

inputs:
os:
description: 'OS version'
required: true
php:
description: 'PHP version'
required: true
coverage:
description: 'coverage mode'
required: false
default: 'none'
tools:
description: 'tools'
required: false
default: 'none'
composer-flags:
description: 'Composer flags'
required: false
composer-flex-with-symfony-version:
description: 'Sf version to determine with Flex'
required: false

runs:
using: "composite"
steps:
- name: Resolve PHP tools flag
uses: actions/github-script@v6
id: setup-php-resolve-tools
with:
script: 'return "${{ inputs.composer-flex-with-symfony-version }}" ? "flex" : "none"'
result-encoding: string

- name: Setup PHP
uses: ./.github/composite-actions/setup-php
with:
version: ${{ inputs.php }}
coverage: ${{ inputs.coverage }}
tools: ${{ steps.setup-php-resolve-tools.outputs.result }}, ${{ inputs.tools }}

- name: Configure Symfony Flex
if: inputs.composer-flex-with-symfony-version
run: composer config extra.symfony.require ${{ inputs.composer-flex-with-symfony-version }}

- name: Setup cache
uses: ./.github/composite-actions/setup-cache
with:
php: ${{ inputs.php }}
os: ${{ inputs.os }}

- name: Install Composer deps
uses: ./.github/composite-actions/install-composer-deps
with:
flags: ${{ inputs.composer-flags }}
46 changes: 9 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,34 +137,14 @@ jobs:
script: 'return "${{ matrix.collect-code-coverage }}" == "yes" ? "pcov" : "none"'
result-encoding: string

- name: Resolve PHP tools flag
uses: actions/github-script@v6
id: setup-php-resolve-tools
- name: Setup PHP with Composer deps
uses: ./.github/composite-actions/setup-php-with-composer-deps
with:
script: 'return "${{ matrix.execute-flex-with-symfony-version }}" ? "flex" : "none"'
result-encoding: string

- name: Setup PHP
uses: ./.github/composite-actions/setup-php
with:
version: ${{ matrix.php-version }}
coverage: ${{ steps.setup-php-resolve-coverage.outputs.result }}
tools: ${{ steps.setup-php-resolve-tools.outputs.result }}

- name: Setup cache
uses: ./.github/composite-actions/setup-cache
with:
php: ${{ matrix.php-version }}
os: ${{ runner.os }}

- name: Configure Symfony Flex
if: matrix.execute-flex-with-symfony-version
run: composer config extra.symfony.require ${{ matrix.execute-flex-with-symfony-version }}

- name: Install Composer deps
uses: ./.github/composite-actions/install-composer-deps
with:
flags: ${{ matrix.composer-flags }}
php: ${{ matrix.php-version }}
coverage: ${{ steps.setup-php-resolve-coverage.outputs.result }}
composer-flags: ${{ matrix.composer-flags }}
composer-flex-with-symfony-version: ${{ matrix.execute-flex-with-symfony-version }}

# Execute migration rules before running tests and self-fixing,
# so we know that our codebase is future-ready.
Expand Down Expand Up @@ -230,19 +210,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: ./.github/composite-actions/setup-php
- name: Setup PHP with Composer deps
uses: ./.github/composite-actions/setup-php-with-composer-deps
with:
version: ${{ matrix.php-version }}

- name: Setup cache
uses: ./.github/composite-actions/setup-cache
with:
php: ${{ matrix.php-version }}
os: ${{ runner.os }}

- name: Install Composer deps
uses: ./.github/composite-actions/install-composer-deps
php: ${{ matrix.php-version }}

- name: Build phar
run: ./dev-tools/build.sh
Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/sca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: ./.github/composite-actions/setup-php
- name: Setup PHP with Composer deps
uses: ./.github/composite-actions/setup-php-with-composer-deps
with:
version: ${{ matrix.php-version }}
tools: cs2pr

- name: Setup cache
uses: ./.github/composite-actions/setup-cache
with:
php: ${{ matrix.php-version }}
os: ${{ runner.os }}

- name: Install Composer deps
uses: ./.github/composite-actions/install-composer-deps
with:
flags: ${{ matrix.composer-flags }}
php: ${{ matrix.php-version }}
tools: cs2pr
coverage: ${{ steps.setup-php-resolve-coverage.outputs.result }}

## We want to have a lock-file used on PR level, so contributors are not bothered by SCA complains unrelated to their changes,
## and same time we want to be aware that we are complying with bleeding edge of SCA tools as maintainers observing the push hook.
Expand Down

0 comments on commit b5fe0be

Please sign in to comment.