Skip to content

Commit

Permalink
extract
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Nov 2, 2023
1 parent d96ac76 commit 7365628
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 44 deletions.
21 changes: 21 additions & 0 deletions .github/composite-actions/install-composer-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Install composer deps"

inputs:
composer-flags:
description: 'OS version'
required: true

runs:
using: "composite"
steps:
- name: Install dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
retry_wait_seconds: 30
command: composer update --optimize-autoloader --no-interaction --no-progress --no-scripts ${{ matrix.composer-flags }} # --no-scripts to avoid installing dev-tools for all jobs on CI level

Check warning on line 17 in .github/composite-actions/install-composer-deps/action.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

17:181 [line-length] line too long (197 > 180 characters)

- name: Report versions
shell: bash
run: composer info -D

Check failure on line 21 in .github/composite-actions/install-composer-deps/action.yml

View workflow job for this annotation

GitHub Actions / Validate YAML

21:28 [new-line-at-end-of-file] no new line character at the end of file
27 changes: 27 additions & 0 deletions .github/composite-actions/setup-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Setup Cache"

inputs:
os:
description: 'OS version'
required: true
php:
description: 'PHP version'
required: true

runs:
using: "composite"
steps:
- name: Get Composer cache directory
id: composer-cache-dir
shell: bash
run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache-dir.outputs.dir }}
key: composer-${{ inputs.os }}-${{ inputs.php }}-${{ hashFiles('**/composer.*') }}
restore-keys: |
composer-${{ inputs.os }}-${{ inputs.php }}-
composer-${{ inputs.os }}-
composer-
25 changes: 25 additions & 0 deletions .github/composite-actions/setup-php/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Setup PHP"

inputs:
version:
description: 'PHP version'
required: true
coverage:
description: 'coverage mode'
required: false
default: 'none'
tools:
description: 'tools'
required: false
default: 'none'

runs:
using: "composite"
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.version }}
coverage: ${{ inputs.coverage }}
tools: ${{ inputs.tools }}
extensions: none, curl, dom, json, mbstring, opcache, simplexml, tokenizer, xml, xmlwriter, zip
28 changes: 11 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,33 +146,27 @@ jobs:
result-encoding: string

- name: Setup PHP
uses: shivammathur/setup-php@v2
uses: ./.github/composite-actions/setup-php
with:
php-version: ${{ matrix.php-version }}
extensions: none, curl, dom, json, mbstring, opcache, simplexml, tokenizer, xml, xmlwriter, zip
version: ${{ matrix.php-version }}
coverage: ${{ steps.code-coverage-driver.outputs.result }}
tools: flex

- name: Get Composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
- name: Setup cache
uses: ./.github/composite-actions/setup-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
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 }}

- name: Install dependencies
uses: nick-invision/retry@v2
with:
Expand Down
37 changes: 10 additions & 27 deletions .github/workflows/sca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,21 @@ jobs:
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
uses: ./.github/composite-actions/setup-php
with:
php-version: ${{ matrix.php-version }}
extensions: none, curl, dom, json, mbstring, opcache, simplexml, tokenizer, xml, xmlwriter, zip
coverage: none # without this Xdebug will be enabled
version: ${{ matrix.php-version }}
tools: cs2pr

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
- name: Install dependencies
uses: nick-invision/retry@v2
- name: Setup cache
uses: ./.github/composite-actions/setup-cache
with:
timeout_minutes: 5
max_attempts: 5
retry_wait_seconds: 30
command: composer update --optimize-autoloader --no-interaction --no-progress ${{ matrix.composer-flags }}
php: ${{ matrix.php-version }}
os: ${{ runner.os }}

- name: Report versions
run: composer info -D
- name: Install Composer deps
uses: ./.github/composite-actions/install-composer-deps
with:
flags: ${{ matrix.composer-flags }}

## 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 7365628

Please sign in to comment.