Skip to content

Commit

Permalink
GH Actions: run workflows more selectively
Browse files Browse the repository at this point in the history
Only run the workflows when there is a chance that the result of the workflow run will be different from before.

The path selection is set up to cast a wide net to make the risk of the workflows not running when the build could potentially break as small as possible.

This means that, aside from files of the type being checked in the workflow changing, the workflow will also run when:
* The configuration used changes.
* Dependencies used in the workflow may potentially have changed.
* Composer scripts used in the workflow may potentially have changed.
* Shell scripts used in the workflow have changed.
* The workflow itself changes.
* Miscellaneous related files have changed.

Note: the lists of files _may_ include some files which don't currently exist in the repo (like `.eslintignore`) for consistency across workflows and to prevent issues if/when such file(s) would be introduced to the repo.
  • Loading branch information
jrfnl committed May 17, 2023
1 parent f71f101 commit d176d0c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
name: CS

on:
# Run on all pushes (except to main) and on all pull requests.
# Run on all relevant pushes (except to main) and on all relevant pull requests.
push:
branches-ignore:
- 'main'
paths:
- '**.php'
- 'composer.json'
- 'composer.lock'
- '.phpcs.xml.dist'
- 'phpcs.xml.dist'
- '.github/workflows/cs.yml'
pull_request:
paths:
- '**.php'
- 'composer.json'
- 'composer.lock'
- '.phpcs.xml.dist'
- 'phpcs.xml.dist'
- '.github/workflows/cs.yml'
# Allow manually triggering the workflow.
workflow_dispatch:

Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/js.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
name: CheckJS

on:
# Run on pushes to select branches and on all pull requests.
# Run on relevant pushes to select branches and on all relevant pull requests.
push:
branches:
- main
- develop
- 'release/[0-9]+.[0-9]+*'
- 'hotfix/[0-9]+.[0-9]+*'
paths:
- '**.js' # Includes Gruntfile.js.
- '.eslintignore'
- '.eslintrc'
- 'package.json'
- 'yarn.lock'
- '.github/workflows/js.yml'
- 'grunt/**'
pull_request:
paths:
- '**.js' # Includes Gruntfile.js.
- '.eslintignore'
- '.eslintrc'
- 'package.json'
- 'yarn.lock'
- '.github/workflows/js.yml'
- 'grunt/**'
# Allow manually triggering the workflow.
workflow_dispatch:

Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
name: Lint

on:
# Run on pushes to select branches and on all pull requests.
# Run on relevant pushes to select branches and on all relevant pull requests.
push:
branches:
- main
- develop
- 'release/[0-9]+.[0-9]+*'
- 'hotfix/[0-9]+.[0-9]+*'
paths:
- '**.php'
- 'composer.json'
- 'composer.lock'
- '.github/workflows/lint.yml'
pull_request:
paths:
- '**.php'
- 'composer.json'
- 'composer.lock'
- '.github/workflows/lint.yml'
# Allow manually triggering the workflow.
workflow_dispatch:

Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
name: Test

on:
# Run on pushes to select branches and on all pull requests.
# Run on relevant pushes to select branches and on all relevant pull requests.
push:
branches:
- main
- develop
- 'release/[0-9]+.[0-9]+*'
- 'hotfix/[0-9]+.[0-9]+*'
paths:
- '**.php'
- '**.xsl'
- 'composer.json'
- 'composer.lock'
- 'phpunit.xml.dist'
- 'wpml-config.xml'
- '.github/workflows/test.yml'
- 'config/scripts/install-wp-tests.sh'
- 'tests/**'
pull_request:
paths:
- '**.php'
- '**.xsl'
- 'composer.json'
- 'composer.lock'
- 'phpunit.xml.dist'
- 'wpml-config.xml'
- '.github/workflows/test.yml'
- 'config/scripts/install-wp-tests.sh'
- 'tests/**'
# Allow manually triggering the workflow.
workflow_dispatch:

Expand Down

0 comments on commit d176d0c

Please sign in to comment.