From d176d0c26a3e74fa11c426514910dd4f1525b0ef Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 12 May 2023 17:23:05 +0200 Subject: [PATCH] GH Actions: run workflows more selectively 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. --- .github/workflows/cs.yml | 16 +++++++++++++++- .github/workflows/js.yml | 18 +++++++++++++++++- .github/workflows/lint.yml | 12 +++++++++++- .github/workflows/test.yml | 22 +++++++++++++++++++++- 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml index bdf3172..cbf6237 100644 --- a/.github/workflows/cs.yml +++ b/.github/workflows/cs.yml @@ -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: diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index a00d93b..a52f003 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -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: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c2fbdc4..d0a4bfc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 425d26b..9ea5e48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: