From c4f70502ffebd13d805372782129f0c29d5e959f Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 26 Sep 2024 14:16:21 -0600 Subject: [PATCH 1/5] Try testing out the Plugin Check Action --- .github/workflows/plugin-check.yml | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/plugin-check.yml diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml new file mode 100644 index 000000000..31487d301 --- /dev/null +++ b/.github/workflows/plugin-check.yml @@ -0,0 +1,42 @@ +name: WordPress Plugin Checks + +on: + push: + branches: + - develop + - trunk + pull_request: + branches: + - develop + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set PHP version + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: none + tools: composer:v2 + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + + - name: Install dependencies and build + run: | + npm ci --no-optional + npm run build + composer install + + - name: Run plugin check + uses: wordpress/plugin-check-action@v1 + with: + exclude-directories: 'node_modules,vendor' From 35ad5c0cdb01e234eb73d2ce02c8117ffb6ad553 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 26 Sep 2024 14:33:56 -0600 Subject: [PATCH 2/5] Modify our build action to allow this to be called by other workflows; add caching to this so it runs faster; use this action in our plugin check action so we're testing on the final build version --- .github/workflows/build-release-zip.yml | 42 ++++++++++++++++++++++--- .github/workflows/plugin-check.yml | 29 +++++++---------- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-release-zip.yml b/.github/workflows/build-release-zip.yml index c8f139de0..ef2460007 100644 --- a/.github/workflows/build-release-zip.yml +++ b/.github/workflows/build-release-zip.yml @@ -2,25 +2,59 @@ 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 + if: steps.cache-composer.outputs.cache-hit != 'true' + 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: diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 31487d301..7af525616 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -10,33 +10,28 @@ on: - develop jobs: + build: + uses: 10up/classifai/.github/workflows/build-release-zip.yml@feature/plugin-check-action # TODO: Update branch before merge. + test: + needs: build runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Set PHP version - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - coverage: none - tools: composer:v2 - - - name: Setup node - uses: actions/setup-node@v4 + - name: Download built zip + uses: actions/download-artifact@v4 with: - node-version-file: .nvmrc - cache: npm + name: ${{ github.event.repository.name }} + path: ${{ github.event.repository.name }} - - name: Install dependencies and build - run: | - npm ci --no-optional - npm run build - composer install + - 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 with: - exclude-directories: 'node_modules,vendor' + build-dir: ${{ github.event.repository.name }} From 57a6769bb45eea004cf32b9155959e157339635b Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 26 Sep 2024 14:43:06 -0600 Subject: [PATCH 3/5] Exclude some checks that are more specific to being on .org; fix the issues flagged --- .github/workflows/plugin-check.yml | 2 ++ .../Classifai/Providers/OpenAI/TextToSpeech.php | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 7af525616..fccf54342 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -35,3 +35,5 @@ jobs: uses: wordpress/plugin-check-action@v1 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' diff --git a/includes/Classifai/Providers/OpenAI/TextToSpeech.php b/includes/Classifai/Providers/OpenAI/TextToSpeech.php index 1b44702f1..ff332b527 100644 --- a/includes/Classifai/Providers/OpenAI/TextToSpeech.php +++ b/includes/Classifai/Providers/OpenAI/TextToSpeech.php @@ -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 model depending on your requirement.', 'classifai' ), [ 'a' => [ @@ -120,7 +121,8 @@ public function render_provider_fields(): void { '' : sprintf( wp_kses( - __( 'Select the speech voice.', 'classifai' ), + /* translators: %s is replaced with the OpenAI Text to Speech voice options URL */ + __( 'Select the speech voice.', 'classifai' ), [ 'a' => [ 'href' => [], @@ -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' ), @@ -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. } From 23e619a781b975c3e65ed8665abaacf304a4cc40 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 26 Sep 2024 14:49:55 -0600 Subject: [PATCH 4/5] Ensure we always run composer install so we have our dependencies we need --- .github/workflows/build-release-zip.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-release-zip.yml b/.github/workflows/build-release-zip.yml index ef2460007..2e18f68c3 100644 --- a/.github/workflows/build-release-zip.yml +++ b/.github/workflows/build-release-zip.yml @@ -46,7 +46,6 @@ jobs: run: npm ci --no-optional - name: Install composer dependencies - if: steps.cache-composer.outputs.cache-hit != 'true' run: composer install --no-dev -o - name: Build From 8171dfce986f05f7104344798aae790c83ec218a Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 27 Sep 2024 09:03:36 -0600 Subject: [PATCH 5/5] Update branch name --- .github/workflows/plugin-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index fccf54342..00c112f2a 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -11,7 +11,7 @@ on: jobs: build: - uses: 10up/classifai/.github/workflows/build-release-zip.yml@feature/plugin-check-action # TODO: Update branch before merge. + uses: 10up/classifai/.github/workflows/build-release-zip.yml@develop test: needs: build