Skip to content

Commit

Permalink
Fixes and Updates GitHub Actions
Browse files Browse the repository at this point in the history
* Updates GitHub Actions for better handling of environment
  versions and caching.
* Fixes GitHub Actions to leverage environment variables
  and matrices.
  • Loading branch information
timnolte committed Aug 19, 2022
1 parent 0603783 commit c93431d
Show file tree
Hide file tree
Showing 11 changed files with 390 additions and 506 deletions.
25 changes: 7 additions & 18 deletions .github/workflows/i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,31 @@ on:
push:
branches:
- dev
- main
- 'release/**'
- 'feature/**'
- 'fix/**'

env:
WP_MULTISITE: 0
ACTION_VERSION: 2

jobs:
check:
name: Setup & Check
check_i18n:
name: Setup & Check Internationalization

runs-on: ubuntu-latest

steps:
- name: Checkout Code
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v2

- name: Setup Node Environment
uses: actions/setup-node@v1
# https://github.com/marketplace/actions/setup-node-js-environment
uses: actions/setup-node@v2
with:
node-version: 14.x

- name: Cache node modules
uses: actions/cache@v2
env:
npm-cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.npm-cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.npm-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
node-version-file: '.nvmrc'
cache: ${{ !env.ACT && 'npm' || '' }}

- name: NPM Install
run: npm ci
Expand Down
44 changes: 27 additions & 17 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,53 @@ on:
push:
branches:
- dev
- main
- 'release/**'
- 'feature/**'
- 'fix/**'

env:
PHP_VERSION: 7.4
PHP_VERSION: '7.4'
WP_MULTISITE: 0
COMPOSER_VERSION: '2.2'
ACTION_VERSION: 2

jobs:
check:
name: Setup & Check
check_linting:
name: Setup & Check Coding Standards

runs-on: ubuntu-latest

steps:
- name: Checkout Code
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v2

- name: Setup PHP Environment
uses: shivammathur/setup-php@v2
# https://github.com/marketplace/actions/setup-php-action
with:
php-version: ${{ env.PHP_VERSION }}
tools: composer:v2
- name: Get Composer Cache Directory
id: composer-cache
if: ${{ !env.ACT }}
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache Composer dependencies
uses: actions/cache@v2
if: ${{ !env.ACT }}
# https://github.com/marketplace/actions/cache
uses: actions/cache@v3
env:
composer-cache-name: cache-vendor
composer-cache-name: cache-composer
with:
path: ~/vendor
key: ${{ runner.os }}-build-${{ env.composer-cache-name }}-${{ hashFiles('**/composer.lock') }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.composer-cache-name }}-v${{ env.ACTION_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.composer-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
${{ runner.os }}-build-${{ env.composer-cache-name }}-v${{ env.ACTION_VERSION }}-
- name: Setup PHP & Composer Environment
# https://github.com/marketplace/actions/setup-php-action
uses: shivammathur/setup-php@v2
with:
php-version: "${{ env.PHP_VERSION }}"
tools: "composer:${{ env.COMPOSER_VERSION }}"

- name: Environment Check
run: php -v && composer --version

- name: Install Composer Dependencies
run: composer install
Expand Down
69 changes: 35 additions & 34 deletions .github/workflows/pr-unit-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,61 @@ on:
pull_request:

env:
PHP_STABLE_VERSION: '7.4'
WP_PREF_STABLE_VERSION: '5.7.*'
PHP_VERSION: '7.4'
WP_VERSION: '5.9.*'
WP_MULTISITE: 0
COMPOSER_VERSION: '2.2'
ACTION_VERSION: 2

jobs:
test:
pr_unit_testing:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- job-name: 'Preferred Stable Requirements'
bleeding-edge: false
php-version: '7.4'
wordpress-version: '5.7.*'
wp-multisite-mode: 0

name: '${{ matrix.job-name }} (PHP:${{ matrix.php-version }}/WP:${{ matrix.wordpress-version }})'
name: 'Unit Test PR in Latest Stable Requirements'

steps:
- name: Checkout Code
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v2

- name: Setup PHP Environment
uses: shivammathur/setup-php@v2
# https://github.com/marketplace/actions/setup-php-action
- name: Get Composer Cache Directory
id: composer-cache
if: ${{ !env.ACT }}
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache Composer dependencies
if: ${{ !env.ACT }}
uses: actions/cache@v2
env:
composer-cache-name: cache-composer
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.composer-cache-name }}-wp-${{ env.WP_VERSION }}-v${{ env.ACTION_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.composer-cache-name }}-wp-${{ env.WP_VERSION }}-v${{ env.ACTION_VERSION }}-
- name: Setup Node Environment
uses: actions/setup-node@v1
# https://github.com/marketplace/actions/setup-node-js-environment
uses: actions/setup-node@v2
with:
node-version: 14.x
node-version-file: '.nvmrc'
cache: ${{ !env.ACT && 'npm' || '' }}

- name: Cache Composer dependencies
uses: actions/cache@v2
env:
composer-cache-name: cache-vendor
- name: Setup PHP & Composer Environment
# https://github.com/marketplace/actions/setup-php-action
uses: shivammathur/setup-php@v2
with:
path: ~/vendor
key: ${{ runner.os }}-build-${{ env.composer-cache-name }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.composer-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
php-version: "${{ env.PHP_VERSION }}"
tools: "composer:${{ env.COMPOSER_VERSION }}"

- name: Environment Check
run: php -v && composer --version

- name: Require Specified WordPress Version
run: composer require johnpbloch/wordpress-core:${{ matrix.wordpress-version }} --dev --prefer-source --update-with-all-dependencies
- name: Require Specified WordPress & WooCommerce Version
run: composer require johnpbloch/wordpress-core:${{ env.WP_VERSION }} php-stubs/wordpress-stubs:${{ env.WP_VERSION }} wp-phpunit/wp-phpunit:${{ env.WP_VERSION }} --dev --prefer-source --update-with-all-dependencies

- name: Install Composer Dependencies
run: composer install
run: composer install --prefer-dist

- name: NPM Setup
run: npm ci
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

env:
WP_MULTISITE: 0
ACTION_VERSION: 2

jobs:
release:
Expand All @@ -25,18 +26,22 @@ jobs:
with:
node-version: 14.x

- name: Get NPM Cache Directory
id: npm-cache
if: ${{ !env.ACT }}
run: echo "::set-output name=dir::$(npm config get cache)"

- name: Cache Node Modules
if: ${{ !env.ACT }}
uses: actions/cache@v2
env:
npm-cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.npm-cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.npm-cache-name }}-v${{ env.ACTION_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.npm-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
${{ runner.os }}-build-${{ env.npm-cache-name }}-v${{ env.ACTION_VERSION }}-
- name: NPM Install
run: npm ci
Expand Down
47 changes: 26 additions & 21 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,53 @@ on:
push:
branches:
- dev
- main
- 'release/**'
- 'feature/**'
- 'fix/**'

env:
PHP_VERSION: 7.4
WP_MODE: 'single'
PHP_VERSION: '7.4'
WP_MULTISITE: 0
WP_VERSION: '5.7.*'
COMPOSER_VERSION: '2.2'
ACTION_VERSION: 2

jobs:
check:
name: Setup & Check
check_static_analysis:
name: Setup & Perform Static Analysis

runs-on: ubuntu-latest

steps:
- name: Checkout Code
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v2

- name: Setup PHP Environment
uses: shivammathur/setup-php@v2
# https://github.com/marketplace/actions/setup-php-action
with:
php-version: ${{ env.PHP_VERSION }}
tools: composer:v2
- name: Get Composer Cache Directory
id: composer-cache
if: ${{ !env.ACT }}
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache Composer dependencies
uses: actions/cache@v2
if: ${{ !env.ACT }}
# https://github.com/marketplace/actions/cache
uses: actions/cache@v3
env:
composer-cache-name: cache-vendor
composer-cache-name: cache-composer
with:
path: ~/vendor
key: ${{ runner.os }}-build-${{ env.composer-cache-name }}-${{ hashFiles('**/composer.lock') }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.composer-cache-name }}-v${{ env.ACTION_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.composer-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
${{ runner.os }}-build-${{ env.composer-cache-name }}-v${{ env.ACTION_VERSION }}-
- name: Setup PHP & Composer Environment
# https://github.com/marketplace/actions/setup-php-action
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
tools: "composer:${{ env.COMPOSER_VERSION }}"

- name: Require Specified WordPress Version
run: composer require johnpbloch/wordpress-core:${{ env.WP_VERSION }} --dev --prefer-source --update-with-all-dependencies
- name: Environment Check
run: php -v && composer --version

- name: Install Composer Dependencies
run: composer install
Expand Down
Loading

0 comments on commit c93431d

Please sign in to comment.