Skip to content

#63170 Increase the specificity of workflow path filtering #9457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/check-built-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ on:
- '6.[8-9]'
- '[7-9].[0-9]'
paths:
# Any change to a CSS, JavaScript, JSON, or SASS file should run checks.
- '**.css'
- '**.js'
- '**.json'
- '**.sass'
# Any change to a source CSS, JavaScript, or JSON file should run checks.
- 'src/**.css'
- 'src/**.js'
- 'src/**.json'
# These files configure npm and the task runner. Changes could affect the outcome.
- 'package*.json'
- '.npmrc'
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ on:
- '3.[89]'
- '[4-9].[0-9]'
paths:
# Any change to a PHP or JavaScript file should run checks.
- '**.js'
- '**.php'
# Any change to a relevant PHP or JavaScript file should run checks.
- 'src/**.js'
- 'src/**.php'
- 'tests/**.php'
Comment on lines +23 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misses files in the root directory, currently the PHP sample configs, webpack.

Which files in particular are you trying to ignore here?

🔢 This applies to other changes too, so I won't repeat myself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, with this change the workflow wouldn't unnecessarily run when an e2e, performance, or QUnit test file is changed (which are all .js files).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we do currently include QUnit test files in the JSHint scans.

Suggested change
- 'src/**.php'
- 'tests/**.php'
- 'src/**.php'
- 'tests/**.php'
- 'tests/qunit/**/*.js

It looks like Gruntfile.js specifies the exclusion of tests/qunit/(vendor|editor)/** as well. But unless I'm missing something, those directories no longer exist, so there's no need to include these exclusions here.

It also looks like grunt jshint:tests uses the tests/qunit/.jshintrc file for configuration. I haven't looked into why there are different configurations, but for the time being, below should also be changed to include that file in case it's updated.

TIL that you can't add comments or suggested changes to unmodified lines in a PR. So instead here's what I suggest for below.

      # This file configures JSHint. Changes could affect the outcome.
      - '**.jshintrc'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wish that there were an easy way to prevent a specific job from running within a workflow when certain path filters do not match (don't run PHPCS when only .js files are touched). However, it seems that can only be accomplished by having a job that detects this (without relying on a third-party action). ChatGPT came up with the following rough example.

  check-files:
    runs-on: ubuntu-latest
    outputs:
      changed: ${{ steps.filter.outputs.changed }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - id: filter
        run: |
          if git diff --name-only ${{ github.base_ref || github.event.before }} ${{ github.sha }} | grep -qE '\.php$'; then
            echo "changed=true" >> "$GITHUB_OUTPUT"
          else
            echo "changed=false" >> "$GITHUB_OUTPUT"
          fi

I don't think there's much benefit in this specific workflow because these jobs complete in under 30 seconds. But if there are any longer-running ones, it may be worthwhile to try.

# These files configure npm. Changes could affect the outcome.
- 'package*.json'
- '.npmrc'
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ on:
- '5.[3-9]'
- '[6-9].[0-9]'
paths:
# Any change to a PHP, CSS, or JavaScript file should run checks.
- '**.css'
- '**.js'
- '**.php'
# Any change to a source PHP, CSS, JavaScript, or JSON file should run checks.
- 'src/**.css'
- 'src/**.js'
- 'src/**.json'
- 'src/**.php'
# These files configure npm and the task runner. Changes could affect the outcome.
- 'package*.json'
- '.npmrc'
Expand All @@ -31,7 +32,7 @@ on:
- 'tools/webpack/**'
# These files configure Composer. Changes could affect the outcome.
- 'composer.*'
# This files affect the e2e tests. Changes could affect the outcome.
# These files affect the e2e tests. Changes could affect the outcome.
- 'tests/e2e/**'
# Confirm any changes to relevant workflow files.
- '.github/workflows/end-to-end-tests.yml'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/javascript-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ on:
- '3.[89]'
- '[4-9].[0-9]'
paths:
# Any change to a JavaScript file should run tests.
- '**.js'
# Any change to a source JavaScript file should run tests.
- 'src/**.js'
# These files configure npm and the task runner. Changes could affect the outcome.
- 'package*.json'
- '.npmrc'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/local-docker-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- 'docker-compose.yml'
# Any changes to local environment related files
- 'tools/local-env/**'
- 'wp-cli.yml'
# These files configure npm and the task runner. Changes could affect the outcome.
- 'package*.json'
- 'Gruntfile.js'
Expand All @@ -38,6 +39,7 @@ on:
- 'docker-compose.yml'
# Any changes to local environment related files
- 'tools/local-env/**'
- 'wp-cli.yml'
# These files configure npm and the task runner. Changes could affect the outcome.
- 'package*.json'
- 'Gruntfile.js'
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ on:
- '6.[2-9]'
- '[7-9].[0-9]'
paths:
# Any change to a PHP, CSS, or JavaScript file should run checks.
- '**.css'
- '**.js'
- '**.php'
# Any change to a source PHP, CSS, JavaScript, or JSON file should run checks.
- 'src/**.css'
- 'src/**.js'
- 'src/**.json'
- 'src/**.php'
# These files configure npm and the task runner. Changes could affect the outcome.
- 'package*.json'
- '.npmrc'
Expand All @@ -30,7 +31,7 @@ on:
- 'tools/webpack/**'
# These files configure Composer. Changes could affect the outcome.
- 'composer.*'
# This files affect the performance tests. Changes could affect the outcome.
# These files affect the performance tests. Changes could affect the outcome.
- 'tests/performance/**'
# Confirm any changes to relevant workflow files.
- '.github/workflows/performance.yml'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ on:
- '5.[5-9]'
- '[6-9].[0-9]'
paths:
# This workflow only scans PHP files.
- '**.php'
# This workflow only scans source PHP files.
- 'src/**.php'
# These files configure Composer. Changes could affect the outcome.
- 'composer.*'
# This file configures PHP compatibility scanning. Changes could affect the outcome.
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ on:
- '3.[7-9]'
- '[4-9].[0-9]'
paths:
# Any change to a PHP, CSS, JavaScript, JSON, HTML, or otherwise tested file should run checks.
- '**.css'
- '**.html'
- '**.js'
- '**.json'
- '**.php'
# Any change to a source PHP, CSS, JavaScript, JSON, HTML, or otherwise tested file should run checks.
- 'src/**.css'
- 'src/**.html'
- 'src/**.js'
- 'src/**.json'
- 'src/**.php'
- 'src/license.txt'
- 'src/SECURITY.md'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including SECURITY.md makes sense because there are specific tests that confirm the contents are accurate. But there are a few other Markdown files in the src directory that could be excluded with !src/**/*.md.

# These files configure npm and the task runner. Changes could affect the outcome.
Expand All @@ -30,7 +30,8 @@ on:
- 'Gruntfile.js'
# These files configure Composer. Changes could affect the outcome.
- 'composer.*'
# This files affect the phpunit tests. Changes could affect the outcome.
# These files affect the phpunit tests. Changes could affect the outcome.
- 'phpunit.xml.dist'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch!

- 'tests/phpunit/**'
# Confirm any changes to relevant workflow files.
- '.github/workflows/phpunit-tests.yml'
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/test-build-processes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ on:
- '3.[7-9]'
- '[4-9].[0-9]'
paths:
# Any change to a PHP, CSS, JavaScript, or JSON file should run checks.
- '**.css'
- '**.js'
- '**.json'
- '**.php'
# Any change to a source PHP, CSS, JavaScript, JSON, or certificate file should run checks.
- 'src/**.css'
- 'src/**.js'
- 'src/**.json'
- 'src/**.php'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnbillion What do you think about removing the composer.* pattern here? The only dependency managed in Composer that is used in the build process is composer/ca-bundle. But the build process will never be affected by this without first manually updating the version (it's pinned to an exact version vs. using a semantic range) AND running grunt certificates:upgrade.

Otherwise, the only files related to certificates that would affect the build process are the .pem and .crt files that are in src/wp-includes/certificates. It may be worth adding **/*.pem and **/*.crt to this list of path filters for those scenarios.

- 'src/**.pem'
- 'src/**.crt'
# These files configure npm and the task runner. Changes could affect the outcome.
- 'package*.json'
- '.npmrc'
Expand Down
Loading