Skip to content

Commit

Permalink
Extract minimum supported PHP version from plugin file for GH actions (
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakpathania authored Sep 12, 2023
1 parent 8aa1e68 commit 384ca6d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 41 deletions.
8 changes: 2 additions & 6 deletions .github/actions/e2e/env-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ runs:
run: echo -e "machine github.com\n login $E2E_GH_TOKEN" > ~/.netrc

# PHP setup
- name: PHP Setup
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
coverage: none
- name: "Set up PHP"
uses: ./.github/actions/setup-php

# Composer setup
- name: Setup Composer
Expand Down
19 changes: 19 additions & 0 deletions .github/actions/setup-php/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Set up PHP"
description: "Extracts the required PHP version from plugin file and uses it to build PHP."

runs:
using: composite
steps:
- name: "Get minimum PHP version"
shell: bash
id: get_min_php_version
run: |
MIN_PHP_VERSION=$(sed -n 's/.*PHP: //p' woocommerce-payments.php)
echo "MIN_PHP_VERSION=$MIN_PHP_VERSION" >> $GITHUB_OUTPUT
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ steps.get_min_php_version.outputs.MIN_PHP_VERSION }}
tools: composer
coverage: none
19 changes: 5 additions & 14 deletions .github/actions/setup-repo/action.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
name: "Setup WooCommerce Payments repository"
description: "Handles the installation, building, and caching of the projects within the repository."

inputs:
php-version:
description: "The version of PHP that the action should set up."
default: "7.4"

runs:
using: composite
steps:
- name: "Setup Node"
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
node-version-file: ".nvmrc"
cache: "npm"

- name: "Enable composer dependencies caching"
uses: actions/cache@v3
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}

- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
tools: composer
coverage: none

- name: "Set up PHP"
uses: ./.github/actions/setup-php
7 changes: 2 additions & 5 deletions .github/workflows/check-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ jobs:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
# setup PHP, but without debug extensions for reasonable performance
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
coverage: none
- name: "Set up PHP"
uses: ./.github/actions/setup-php
# Install composer packages.
- run: composer self-update && composer install --no-progress
# Fetch the target branch before running the check.
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/i18n-weekly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ jobs:
path: ~/.npm/
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
# setup PHP, but without debug extensions for reasonable performance
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
coverage: none

- name: "Set up PHP"
uses: ./.github/actions/setup-php
- name: Build release
run: |
npm ci
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
coverage: none
- name: "Set up PHP"
uses: ./.github/actions/setup-php
- run: bash bin/phpcs-compat.sh
7 changes: 2 additions & 5 deletions .github/workflows/php-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ jobs:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
# setup PHP, but without debug extensions for reasonable performance
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
coverage: none
- name: "Set up PHP"
uses: ./.github/actions/setup-php
# install dependencies and run linter
- run: composer self-update && composer install --no-progress && ./vendor/bin/phpcs --standard=phpcs.xml.dist $(git ls-files | grep .php$) && ./vendor/bin/psalm

Expand Down
4 changes: 4 additions & 0 deletions changelog/dev-update-workflows
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Comment: Update GH workflows to use PHP version from plugin file.

0 comments on commit 384ca6d

Please sign in to comment.