Skip to content

Commit

Permalink
Merge pull request #777 from carstingaxion/feature/increase-workflow-…
Browse files Browse the repository at this point in the history
…speed

Increase workflow speed
  • Loading branch information
mauteri authored Aug 25, 2024
2 parents 4c5b27d + 888daeb commit bb4dea5
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 27 deletions.
69 changes: 62 additions & 7 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ on:
branches:
- main
pull_request:

paths:
- '.github/workflows/coding-standards.yml'
- 'includes/**'
- 'src/**'
- 'test/**'
- 'package.*'
- '*.js'
- '*.php'
jobs:
phpcs:
name: PHP Coding Standards
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Get Composer cache directory
id: composer-cache
Expand Down Expand Up @@ -53,7 +60,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Log debug information
run: |
Expand All @@ -64,23 +71,48 @@ jobs:
composer --version
- name: Install NodeJS
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

# Restoring the short lived node_modules cache
# to be used accross all workflows running on the last commit.
# https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache
- uses: actions/cache/restore@v4
id: node_modules-cache
with:
node-version-file: '.nvmrc'
path: |
./node_modules
key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }}

- name: NPM install
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci --legacy-peer-deps

# Creating a short lived node_modules cache
- uses: actions/cache/save@v4
if: steps.node_modules-cache.outputs.cache-hit != 'true'
with:
path: |
./node_modules
key: ${{ steps.node_modules-cache.outputs.cache-primary-key }}

- name: Run JSHint
run: npm run lint:js
if: ${{ success() || failure() }}

stylelint:
name: CSS Coding Standards
needs: jshint # Wait for jshint job, to mak use of node_modules caching.
if: always() # Run always, even when the jshint job didn't ran.
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Log debug information
run: |
Expand All @@ -91,13 +123,36 @@ jobs:
composer --version
- name: Install NodeJS
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

# Restoring the short lived node_modules cache
# to be used accross all workflows running on the last commit.
# https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache
- uses: actions/cache/restore@v4
id: node_modules-cache
with:
path: |
./node_modules
key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }}

- name: NPM install
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci --legacy-peer-deps

# Creating a short lived node_modules cache
- uses: actions/cache/save@v4
if: steps.node_modules-cache.outputs.cache-hit != 'true'
with:
path: |
./node_modules
key: ${{ steps.node_modules-cache.outputs.cache-primary-key }}

- name: Run StyleLint
run: npm run lint:css
if: ${{ success() || failure() }}
18 changes: 16 additions & 2 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
on: [pull_request]
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/dependency-review.yml'
- 'package*'
- 'composer*'


permissions:
contents: read
Expand All @@ -32,7 +41,12 @@ jobs:
with:
license-check: true
vulnerability-check: false
comment-summary-in-pr: on-failure

# Prevent this workflow to create a comment on the PR on forks outside of the GatherPress organization,
# because the required permission would not be given and the workflow would fail.
# Using a condition check will skip commenting.
comment-summary-in-pr: ${{ github.repository_owner == 'GatherPress' && 'on-failure' || 'never' }}

# You can only include one of these two options: `allow-licenses` and `deny-licences`
# ([String]). Only allow these licenses (optional)
# Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Log debug information
run: |
Expand All @@ -21,9 +21,13 @@ jobs:
composer --version
- name: Install NodeJS
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
node-version-file: '.nvmrc'
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

- name: NPM install
run: npm ci --legacy-peer-deps
Expand Down
29 changes: 26 additions & 3 deletions .github/workflows/jest-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Log debug information
run: |
Expand All @@ -27,13 +27,36 @@ jobs:
composer --version
- name: Install NodeJS
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
node-version-file: '.nvmrc'
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

# Restoring the short lived node_modules cache
# to be used accross all workflows running on the last commit.
# https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache
- uses: actions/cache/restore@v4
id: node_modules-cache
with:
path: |
./node_modules
key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }}

- name: NPM install
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci --legacy-peer-deps

# Creating a short lived node_modules cache
- uses: actions/cache/save@v4
if: steps.node_modules-cache.outputs.cache-hit != 'true'
with:
path: |
./node_modules
key: ${{ steps.node_modules-cache.outputs.cache-primary-key }}

- name: Run Jest Tests
run: npm run test:unit:js
if: ${{ success() || failure() }}
8 changes: 6 additions & 2 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
php_versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -33,9 +33,13 @@ jobs:
run: composer install --optimize-autoloader --prefer-dist

- name: Install NodeJS
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

- name: Log debug information
run: |
Expand Down
31 changes: 27 additions & 4 deletions .github/workflows/playground-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ jobs:
# @source https://dev.to/suzukishunsuke/secure-github-actions-by-pullrequesttarget-641#checkout-merge-commits
- uses: suzuki-shunsuke/[email protected]
id: pr

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{steps.pr.outputs.merge_commit_sha}}
ref: ${{ steps.pr.outputs.merge_commit_sha }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Setup PHP
Expand All @@ -70,10 +71,32 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

# Restoring the short lived node_modules cache
# to be used accross all workflows running on the last commit.
# https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache
- uses: actions/cache/restore@v4
id: node_modules-cache
with:
path: |
./node_modules
key: ${{ runner.os }}-node_modules-${{ steps.pr.outputs.merge_commit_sha }}-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
run: npm ci
- name: NPM install
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci --legacy-peer-deps

# Creating a short lived node_modules cache
- uses: actions/cache/save@v4
if: steps.node_modules-cache.outputs.cache-hit != 'true'
with:
path: |
./node_modules
key: ${{ steps.node_modules-cache.outputs.cache-primary-key }}

- name: Build plugin
# - [Incorrect version number used when creating zip archive · Issue #92 · wp-cli/dist-archive-command](https://github.com/wp-cli/dist-archive-command/issues/92)
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -22,13 +22,36 @@ jobs:
run: composer install --optimize-autoloader --prefer-dist

- name: Install NodeJS
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

# Restoring the short lived node_modules cache
# to be used accross all workflows running on the last commit.
# https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache
- uses: actions/cache/restore@v4
id: node_modules-cache
with:
path: |
./node_modules
key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }}

- name: NPM install
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci --legacy-peer-deps

# Creating a short lived node_modules cache
- uses: actions/cache/save@v4
if: steps.node_modules-cache.outputs.cache-hit != 'true'
with:
path: |
./node_modules
key: ${{ steps.node_modules-cache.outputs.cache-primary-key }}

- name: Log debug information
run: |
npm --version
Expand Down
35 changes: 32 additions & 3 deletions .github/workflows/wordpress-org-plugin-guidelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: 'WordPress.org plugin directory guidelines'
on: # rebuild any PRs and main branch changes
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/wordpress-org-plugin-guidelines.yml'
- 'includes/**'
- 'src/**'
- 'package.*'
- '*.js'
- '*.php'
push:
branches:
- main
Expand Down Expand Up @@ -29,10 +36,32 @@ jobs:
with:
# Make sure to use the same version like WordPress/gutenberg.
node-version-file: '.nvmrc'
cache: npm
# Enable built-in functionality for caching and restoring dependencies, which is disabled by default.
# The actions/setup-node uses actions/cache under the hood.
# https://github.com/actions/setup-node#caching-global-packages-data
cache: 'npm'

- name: Install dependencies
run: npm ci
# Restoring the short lived node_modules cache
# to be used accross all workflows running on the last commit.
# https://github.com/actions/cache/blob/main/caching-strategies.md#creating-a-short-lived-cache
- uses: actions/cache/restore@v4
id: node_modules-cache
with:
path: |
./node_modules
key: ${{ runner.os }}-node_modules-${{ github.sha }}-${{ hashFiles('package-lock.json') }}

- name: NPM install
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci --legacy-peer-deps

# Creating a short lived node_modules cache
- uses: actions/cache/save@v4
if: steps.node_modules-cache.outputs.cache-hit != 'true'
with:
path: |
./node_modules
key: ${{ steps.node_modules-cache.outputs.cache-primary-key }}

- name: Build plugin
run: |
Expand Down
Loading

0 comments on commit bb4dea5

Please sign in to comment.