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

Add the WordPress Plugin Check Action #806

Merged
merged 5 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
41 changes: 37 additions & 4 deletions .github/workflows/build-release-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,58 @@ name: Build release zip

on:
workflow_dispatch:
workflow_call:

jobs:
build_zip:
name: Build release zip
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set Node.js 16.x

- name: Setup node
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version-file: .nvmrc
- name: npm install and build

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
id: cache-composer
uses: actions/cache@v4
env:
cache-name: cache-composer
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }}

- name: Install node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --no-optional

- name: Install composer dependencies
run: composer install --no-dev -o

- name: Build
run: |
npm install
npm run build
npm run makepot
composer install --no-dev
npm run archive

- name: Upload the ZIP file as an artifact
uses: actions/upload-artifact@v4
with:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/plugin-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: WordPress Plugin Checks

on:
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop

jobs:
build:
uses: 10up/classifai/.github/workflows/build-release-zip.yml@feature/plugin-check-action # TODO: Update branch before merge.
dkotter marked this conversation as resolved.
Show resolved Hide resolved
dkotter marked this conversation as resolved.
Show resolved Hide resolved

test:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download built zip
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: ${{ github.event.repository.name }}

- name: Display structure of downloaded files
run: ls -R
working-directory: ${{ github.event.repository.name }}

- name: Run plugin check
uses: wordpress/plugin-check-action@v1
Copy link
Member

Choose a reason for hiding this comment

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

Are there any options to know specifically what checks we're running or is it all-or-nothing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By default it will run all tests but you can exclude certain checks or certain categories of checks. If you see a few lines below, we're using the exclude-checks setting to remove a couple checks but we run everything else.

You can see all the checks and categories here: https://github.com/wordpress/plugin-check-action/?tab=readme-ov-file#supported-checks

with:
build-dir: ${{ github.event.repository.name }}
exclude-checks: 'plugin_readme,plugin_updater' # Plugin isn't on .org so excluding these for now.
exclude-directories: 'assets,dist,vendor'
14 changes: 8 additions & 6 deletions includes/Classifai/Providers/OpenAI/TextToSpeech.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function render_provider_fields(): void {
'' :
sprintf(
wp_kses(
/* translators: %s is replaced with the OpenAI Text to Speech models URL */
__( 'Select a <a href="%s" title="OpenAI Text to Speech models" target="_blank">model</a> depending on your requirement.', 'classifai' ),
[
'a' => [
Expand Down Expand Up @@ -120,7 +121,8 @@ public function render_provider_fields(): void {
'' :
sprintf(
wp_kses(
__( 'Select the speech <a href="%s" title="OpenAI Text to Speech models" target="_blank">voice</a>.', 'classifai' ),
/* translators: %s is replaced with the OpenAI Text to Speech voice options URL */
__( 'Select the speech <a href="%s" title="OpenAI Text to Speech voice options" target="_blank">voice</a>.', 'classifai' ),
[
'a' => [
'href' => [],
Expand All @@ -144,8 +146,8 @@ public function render_provider_fields(): void {
'option_index' => static::ID,
'label_for' => 'format',
'options' => [
'mp3' => __( '.mp3', 'classifai' ),
'wav' => __( '.wav', 'classifai' ),
'mp3' => __( '.mp3', 'classifai' ),
'wav' => __( '.wav', 'classifai' ),
],
'default_value' => $settings['format'],
'description' => __( 'Select the desired audio format.', 'classifai' ),
Expand Down Expand Up @@ -349,9 +351,9 @@ public function get_debug_information(): array {
$debug_info = [];

if ( $this->feature_instance instanceof FeatureTextToSpeech ) {
$debug_info[ __( 'Model', 'classifai' ) ] = $provider_settings['tts_model'] ?? '';
$debug_info[ __( 'Voice', 'classifai' ) ] = $provider_settings['voice'] ?? '';
$debug_info[ __( 'Audio format', 'classifai' ) ] = $provider_settings['format'] ?? '';
$debug_info[ __( 'Model', 'classifai' ) ] = $provider_settings['tts_model'] ?? '';
$debug_info[ __( 'Voice', 'classifai' ) ] = $provider_settings['voice'] ?? '';
$debug_info[ __( 'Audio format', 'classifai' ) ] = $provider_settings['format'] ?? '';

// We don't save the response transient because WP does not support serialized binary data to be inserted to the options.
}
Expand Down
Loading