Skip to content
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

Fix theme validation and theme check workflow errors #8198

Merged
merged 5 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
38 changes: 3 additions & 35 deletions .github/workflows/theme-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,41 +41,9 @@ jobs:
wp-env run cli wp plugin install https://github.com/WordPress/theme-check/archive/refs/pull/458/head.zip --activate

- name: Get changed root folders
uses: actions/github-script@v6
with:
script: |
const { owner, repo, number } = context.issue;
let allFiles = [];
let page = 1;

while (true) {
const { data: files } = await github.rest.pulls.listFiles({
owner,
repo,
pull_number: number,
per_page: 100,
page: page
});

allFiles = allFiles.concat(files);

if (files.length < 100) break;
page++;
}

console.log('files', allFiles.map(file => file.filename));

const rootFolders = new Set();
for (const file of allFiles) {
const parts = file.filename.split('/');
if (parts.length > 1) {
rootFolders.add(parts[0]);
}
}

const rootFoldersArray = Array.from(rootFolders);
core.exportVariable('THEME_FOLDERS', rootFoldersArray.join(','));
console.log(`Changed root folders: ${rootFoldersArray.join(', ')}`);
run: |
THEME_FOLDERS=$(git diff --name-only HEAD^ | awk '!/^\./ && /\//' | awk -F/ '{print $1}' | uniq | paste -s -d, -)
echo "THEME_FOLDERS=${THEME_FOLDERS}" >> $GITHUB_ENV
madhusudhand marked this conversation as resolved.
Show resolved Hide resolved

- name: Debug THEME_FOLDERS
run: echo "THEME_FOLDERS is ${{ env.THEME_FOLDERS }}"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/validate-theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on:
- '**/theme.json'
- '**/styles/*.json'
- '**/assets/fonts/*.json'
- '**/style.css'

env:
PR_PATHS: >-
'**/theme.json'
'**/styles/*.json'
'**/assets/fonts/*.json'
'**/style.css'
HUSKY: 0

jobs:
Expand Down
8 changes: 5 additions & 3 deletions theme-utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,18 @@ const commands = {
run: async ( args ) => {
args.shift();
const options = {};
while ( args[ 0 ].startsWith( '--' ) ) {
while ( args[ 0 ] && args[ 0 ].startsWith( '--' ) ) {
const flag = args.shift().slice( 2 );
const [ key, value ] = flag.split( '=' );
const camelCaseKey = key.replace( /-([a-z])/g, ( [ , c ] ) =>
c.toUpperCase()
);
options[ camelCaseKey ] = value ?? true;
}
const themes = args[ 0 ].split( /[ ,]+/ );
await validateThemes( themes, options );
const themes = args[ 0 ] ? args[ 0 ].split( /[ ,]+/ ) : [];
if ( themes.length ) {
await validateThemes( themes, options );
}
},
},
help: {
Expand Down
Loading