-
Notifications
You must be signed in to change notification settings - Fork 7
Fix build tooling and modernize WPCS integration #109
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
lihsaa591
wants to merge
7
commits into
master
Choose a base branch
from
chore/build-tooling-and-phpcs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8b8499e
Fix missing grunt-cli/gulp-rename and PHP 8 makepot crash
lihsaa591 e9d6051
Modernize WPCS tooling and fix a stale/wrong phpcs.xml
lihsaa591 4008e88
Add PR build ZIP workflow
lihsaa591 8339fa1
Trigger initial PR build ZIP run
lihsaa591 55c977c
Use npm install instead of npm ci in the build-zip workflow
lihsaa591 50a7868
Exclude bundled Kirki library strings from the generated POT
lihsaa591 da155f1
Align PHPCompatibility testVersion with the theme's declared PHP minimum
lihsaa591 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: PHPCS | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - '**.php' | ||
|
|
||
| jobs: | ||
| phpcs: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '7.4' | ||
| tools: composer | ||
|
|
||
| - name: Get changed PHP files | ||
| id: changed-files | ||
| uses: tj-actions/changed-files@v45 | ||
| with: | ||
| files: '**.php' | ||
| separator: ' ' | ||
|
|
||
| - name: Install Composer dependencies | ||
| if: steps.changed-files.outputs.any_changed == 'true' | ||
| run: composer install --no-interaction --no-progress | ||
|
|
||
| - name: Run PHPCS on changed files | ||
| if: steps.changed-files.outputs.any_changed == 'true' | ||
| env: | ||
| PHP_FILES: ${{ steps.changed-files.outputs.added_files }} ${{ steps.changed-files.outputs.copied_files }} ${{ steps.changed-files.outputs.modified_files }} ${{ steps.changed-files.outputs.renamed_files }} | ||
| run: | | ||
| if [ -n "$(echo "$PHP_FILES" | xargs)" ]; then | ||
| composer phpcs -- $PHP_FILES | ||
| else | ||
| echo "No existing PHP files to lint (only deletions in this PR)." | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Build Testable ZIP | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
| branches: [master] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| zip: | ||
| uses: themegrill/.github/.github/workflows/pr-build-zip.yml@master | ||
| with: | ||
| node-version: '20.x' | ||
| php-version: '7.4' | ||
| package-manager: npm | ||
| # package-lock.json isn't committed in this repo (.gitignore), so `npm ci` | ||
| # (the default install here) has nothing to install from. | ||
| install-command: npm install | ||
| composer-install: true | ||
| build-command: npm run build | ||
| zip-glob: 'dist/*.zip' | ||
| artifacts-bucket: themegrill-pr-artifacts | ||
| public-base-url: https://themegrill-pr-artifacts.s3.amazonaws.com | ||
| s3-region: us-east-1 | ||
| secrets: | ||
| BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | ||
| ARTIFACTS_KEY: ${{ secrets.ARTIFACTS_KEY }} | ||
| ARTIFACTS_SECRET: ${{ secrets.ARTIFACTS_SECRET }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| omit=optional |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,15 @@ module.exports = function( grunt ){ | |
| // Minify all .js files. | ||
| uglify: { | ||
| options: { | ||
| preserveComments: /(?:^!|@(?:license|preserve|cc_on))/ | ||
| // Keep output ES5 for legacy-browser support. | ||
| compress: { | ||
| arrows: false | ||
| }, | ||
| // `preserveComments` was removed in grunt-contrib-uglify 2.x+; | ||
| // this is the option UglifyJS itself understands. | ||
| output: { | ||
| comments: /(?:^!|@(?:license|preserve|cc_on))/ | ||
| } | ||
| }, | ||
| frontend: { | ||
| files: [{ | ||
|
|
@@ -91,6 +99,7 @@ module.exports = function( grunt ){ | |
| options: { | ||
| type: 'wp-theme', | ||
| domainPath: 'languages', | ||
| potComments: 'Copyright (C) {year} ThemeGrill\nThis file is distributed under the GNU General Public License, version 3 (GPLv3).', | ||
| potHeaders: { | ||
| 'report-msgid-bugs-to': 'themegrill@gmail.com', | ||
| 'language-team': 'ThemeGrill <themegrill@gmail.com' | ||
|
Comment on lines
+102
to
105
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 50a7868 — makepot's exclude list only had deploy/.; added inc/kirki/. alongside it. Regenerated the .pot: Kirki-related string count went from 217 matches to 0, confirmed with grep -ci kirki languages/flash.pot before/after. |
||
|
|
@@ -100,7 +109,8 @@ module.exports = function( grunt ){ | |
| options: { | ||
| potFilename: 'flash.pot', | ||
| exclude: [ | ||
| 'deploy/.*' // Exclude deploy directory | ||
| 'deploy/.*', // Exclude deploy directory | ||
| 'inc/kirki/.*' // Exclude bundled third-party Kirki library | ||
| ] | ||
| } | ||
| } | ||
|
|
@@ -157,6 +167,8 @@ module.exports = function( grunt ){ | |
| '!node_modules/**', | ||
| '!sass/**', | ||
| '!phpcs.xml', | ||
| '!composer.json', | ||
| '!composer.lock', | ||
| 'README.md' | ||
| ], | ||
| dest: 'flash', | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked this against both tools' own docs rather than changing it on faith: GitHub's own path-filter syntax docs give
**.jsas the documented example for "all .js files in the repository" (i.e. it already matches nested paths, no leading**/needed) — same semantics apply to**.phpin theon.pull_request.pathsfilter. And tj-actions/changed-files' own README (thefiles:input used in the second step) has an identical example,**.md, specifically captioned "Get all changed markdown files" including nested ones under docs/ — it explicitly adopted GitHub's native glob semantics as of v13, not minimatch's. So**.phpalready matches nested PHP files under both tools as written. Switching to**/*.phpwould be redundant at best, and in some glob dialects**/*.phpactually fails to match root-level .php files (no directory segment before the file) — which would be a real regression for a WordPress theme, where most template files (front-page.php, single.php, etc.) live at the theme root. Leaving as-is unless you have a specific counter-example of a nested file this pattern misses.