Skip to content

Commit

Permalink
[ci] [doc] Add translation and build checking in the CI + Add methods…
Browse files Browse the repository at this point in the history
… to contributing.md file.
  • Loading branch information
swashata committed Mar 31, 2024
1 parent 46af7d1 commit 3e7ab36
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Run CI tests via Github.
name: PHPCS and Static Analysis.
name: Static Analysis and Build

on:
pull_request:
Expand All @@ -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
Expand Down Expand Up @@ -43,4 +43,31 @@ jobs:
run: composer phpstan

- name: Run PHPCS
run: composer phpcs:ci
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
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
7 changes: 6 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -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');

Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions gulptasks/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,5 @@ async function syncWithTransifex() {
}

exports.createTranslation = series(translatePHP, syncWithTransifex);

exports.createPot = translatePHP;
2 changes: 1 addition & 1 deletion languages/freemius.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Language-Team: Freemius Team <[email protected]>\n"
"Last-Translator: Vova Feldman <[email protected]>\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"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"main": "gulpfile.js",
"scripts": {
"translate": "gulp translate",
"pot": "gulp pot",
"build": "gulp build",
"dev": "gulp dev",
"postinstall": "patch-package"
Expand Down

0 comments on commit 3e7ab36

Please sign in to comment.