From 3e7ab3692b77cd09454a380e74f23361d719bc2a Mon Sep 17 00:00:00 2001 From: Swashata Ghosh Date: Wed, 31 Jan 2024 12:51:53 +0530 Subject: [PATCH] [ci] [doc] Add translation and build checking in the CI + Add methods to contributing.md file. --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++---- CONTRIBUTING.md | 18 ++++++++++++++++++ gulpfile.js | 7 ++++++- gulptasks/translate.js | 2 ++ languages/freemius.pot | 2 +- package.json | 1 + 6 files changed, 59 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 976c868a..774ca659 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ # Run CI tests via Github. -name: PHPCS and Static Analysis. +name: Static Analysis and Build on: pull_request: @@ -8,9 +8,9 @@ on: - master jobs: - run: + staticAnalysis: runs-on: ubuntu-latest - name: PHPCS + name: PHP Static Analysis continue-on-error: ${{ matrix.experimental }} strategy: fail-fast: false @@ -43,4 +43,31 @@ jobs: run: composer phpstan - name: Run PHPCS - run: composer phpcs:ci \ No newline at end of file + run: composer phpcs:ci + + canBuild: + runs-on: ubuntu-latest + name: Can Build + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + + - name: Log debug information + run: | + node --version + npm --version + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Create POT file + run: npm run pot \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ae327ff..26ce28b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,4 +37,22 @@ Now, you can run the following commands: ```bash # Run the script to extract translations and generate the POT file. npm run translate +``` + +## Development and Build + +To compile SASS and JS during development, run + +```bash +npm run dev +``` + +This will watch for changes and compile changed files. The system is also hooked with +live-reload, so you don't need to refresh the page to see the changes. Simply install the +[LiveReload browser extension](https://chromewebstore.google.com/detail/livereload++/ciehpookapcdlakedibajeccomagbfab) and enable it. + +To build the SDK for production, run + +```bash +npm run build ``` \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index ef55b0ad..a25dcebf 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,7 +1,7 @@ require('dotenv').config(); const {parallel, watch} = require('gulp'); const livereload = require('gulp-livereload'); -const {createTranslation} = require('./gulptasks/translate'); +const {createTranslation, createPot} = require('./gulptasks/translate'); const {getSdkScssCompiler, scssSources} = require('./gulptasks/sass'); const {getSdkJSCompilers, jsSources} = require('./gulptasks/scripts'); @@ -17,6 +17,11 @@ const DEFAULT_GULP_WATCH_OPTIONS = {ignoreInitial: false, usePolling: true}; */ exports.translate = createTranslation; +/** + * Create `languages/freemius.pot` file. Used mainly by the CI to make sure POT can be created. + */ +exports.pot = createPot; + /** * The build task. This will build * 1. SASS files. diff --git a/gulptasks/translate.js b/gulptasks/translate.js index f8834607..061e8583 100644 --- a/gulptasks/translate.js +++ b/gulptasks/translate.js @@ -113,3 +113,5 @@ async function syncWithTransifex() { } exports.createTranslation = series(translatePHP, syncWithTransifex); + +exports.createPot = translatePHP; diff --git a/languages/freemius.pot b/languages/freemius.pot index adae08a8..36db178c 100644 --- a/languages/freemius.pot +++ b/languages/freemius.pot @@ -8,7 +8,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Language-Team: Freemius Team \n" "Last-Translator: Vova Feldman \n" -"POT-Creation-Date: 2024-01-30 15:42+0000\n" +"POT-Creation-Date: 2024-01-31 07:21+0000\n" "Report-Msgid-Bugs-To: https://github.com/Freemius/wordpress-sdk/issues\n" "X-Poedit-Basepath: ..\n" "X-Poedit-KeywordsList: get_text_inline;get_text_x_inline:1,2c;$this->get_text_inline;$this->get_text_x_inline:1,2c;$this->_fs->get_text_inline;$this->_fs->get_text_x_inline:1,2c;$this->fs->get_text_inline;$this->fs->get_text_x_inline:1,2c;$fs->get_text_inline;$fs->get_text_x_inline:1,2c;$this->_parent->get_text_inline;$this->_parent->get_text_x_inline:1,2c;fs_text_inline;fs_echo_inline;fs_esc_js_inline;fs_esc_attr_inline;fs_esc_attr_echo_inline;fs_esc_html_inline;fs_esc_html_echo_inline;fs_text_x_inline:1,2c;fs_echo_x_inline:1,2c;fs_esc_attr_x_inline:1,2c;fs_esc_js_x_inline:1,2c;fs_esc_js_echo_x_inline:1,2c;fs_esc_html_x_inline:1,2c;fs_esc_html_echo_x_inline:1,2c\n" diff --git a/package.json b/package.json index f51de1a7..d645ad0a 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "main": "gulpfile.js", "scripts": { "translate": "gulp translate", + "pot": "gulp pot", "build": "gulp build", "dev": "gulp dev", "postinstall": "patch-package"