Use Interactivity API for frontend functionality #14132
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint I18N | |
on: | |
push: | |
paths: | |
- '**.js' | |
- '**.cjs' | |
- '**.ts' | |
- '**.tsx' | |
- '**/package.json' | |
- 'package-lock.json' | |
- 'web-stories.php' | |
- 'includes/**.php' | |
- '.github/workflows/lint-i18n.yml' | |
branches: | |
- main | |
pull_request: | |
paths: | |
- '**.js' | |
- '**.cjs' | |
- '**.ts' | |
- '**.tsx' | |
- '**/package.json' | |
- 'package-lock.json' | |
- 'web-stories.php' | |
- 'includes/**.php' | |
- '.github/workflows/lint-i18n.yml' | |
permissions: | |
contents: read | |
# Cancels all previous workflow runs for pull requests that have not completed. | |
concurrency: | |
# The concurrency group contains the workflow name and the (target) branch name. | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 | |
with: | |
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | |
- name: Checkout | |
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: latest | |
coverage: none | |
tools: wp-cli | |
- name: Install latest version of i18n-command | |
run: wp package install wp-cli/i18n-command:dev-main | |
- name: Setup Node | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 | |
with: | |
node-version-file: '.nvmrc' | |
cache: npm | |
- name: Setup PHP | |
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 | |
with: | |
php-version: '8.0' | |
coverage: none | |
tools: composer | |
- name: Install dependencies | |
run: | | |
npm ci | |
env: | |
PUPPETEER_SKIP_DOWNLOAD: true | |
- name: Install PHP dependencies | |
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a | |
with: | |
composer-options: '--prefer-dist --no-progress --no-interaction' | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@8f24390df009a496891208e5e36b8a1de1f45135 | |
with: | |
bun-version: latest | |
- name: Build plugin | |
run: bun run build:js | |
- name: Bundle regular version | |
run: bun run workflow:build-plugin | |
# Check if as many strings as expected were found. | |
# Fail job if `wp i18n make-pot` returns any warnings. | |
# Some false positive warnings are removed due to a bug in the string extraction. | |
# That's why this step is unfortunately a bit more complex. | |
# See https://github.com/wp-cli/i18n-command/issues/154 | |
- name: Generate POT file | |
run: | | |
OUTPUT=$((wp i18n make-pot build/web-stories build/web-stories.pot) 2>&1 >/dev/null) | |
HAS_ERROR=false | |
EXPECTED_NUMBER_OF_STRINGS=1000 | |
NUMBER_OF_FOUND_STRINGS=$(grep -o msgstr build/web-stories.pot | wc -l | xargs) | |
if (( "$NUMBER_OF_FOUND_STRINGS" < "$EXPECTED_NUMBER_OF_STRINGS" )); then | |
HAS_ERROR=true | |
echo "String extraction found only $NUMBER_OF_FOUND_STRINGS translatable strings. Expected at least $EXPECTED_NUMBER_OF_STRINGS." | |
fi | |
IFS=$'\n' | |
declare -a WARNINGS=($OUTPUT) | |
unset IFS | |
for WARNING in "${WARNINGS[@]}"; do | |
# Filter false positives. | |
if [[ $WARNING == *"translator comment"* ]] && [[ $WARNING != *"%s"* ]]; then | |
continue | |
fi | |
HAS_ERROR=true | |
echo $WARNING | |
done | |
if [[ "$HAS_ERROR" = true ]]; then | |
exit 1 | |
fi |