cache translation compilation action step
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
name: 'Build Translations'
|
||||||
|
description: 'Compile translations with caching and optionally check for errors'
|
||||||
|
inputs:
|
||||||
|
check-for-errors:
|
||||||
|
description: 'Whether to check for i18n compilation errors'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: 📝 Extract English source strings
|
||||||
|
shell: bash
|
||||||
|
run: yarn intl:extract
|
||||||
|
|
||||||
|
- name: 🔑 Generate cache key
|
||||||
|
id: cache-key
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
EN_HASH=$(cat src/locale/locales/en/messages.po | shasum -a 256 | cut -d' ' -f1)
|
||||||
|
YARN_HASH=$(cat yarn.lock | shasum -a 256 | cut -d' ' -f1)
|
||||||
|
CACHE_KEY="translations-${EN_HASH}-${YARN_HASH}"
|
||||||
|
echo "key=${CACHE_KEY}" >> $GITHUB_OUTPUT
|
||||||
|
echo "Cache key: ${CACHE_KEY}"
|
||||||
|
|
||||||
|
- name: 📦 Restore translations cache
|
||||||
|
id: cache-translations
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
src/locale/locales/*/messages.po
|
||||||
|
src/locale/locales/*/messages.js
|
||||||
|
key: ${{ steps.cache-key.outputs.key }}
|
||||||
|
|
||||||
|
- name: 🔤 Compile translations
|
||||||
|
if: steps.cache-translations.outputs.cache-hit != 'true'
|
||||||
|
shell: bash
|
||||||
|
run: yarn intl:compile 2>&1 | tee i18n.log
|
||||||
|
|
||||||
|
- name: Check for i18n compilation errors
|
||||||
|
if: inputs.check-for-errors == 'true' && steps.cache-translations.outputs.cache-hit != 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if grep -q "invalid syntax" "i18n.log"; then
|
||||||
|
echo -e "\n\nFound compilation errors!\n\n"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "\n\nNo compilation errors!\n\n"
|
||||||
|
fi
|
||||||
@@ -60,10 +60,9 @@ jobs:
|
|||||||
run: yarn install --frozen-lockfile
|
run: yarn install --frozen-lockfile
|
||||||
|
|
||||||
- name: 🔤 Compile translations
|
- name: 🔤 Compile translations
|
||||||
run: yarn intl:build 2>&1 | tee i18n.log
|
uses: ./.github/actions/build-translations
|
||||||
|
with:
|
||||||
- name: Check for i18n compilation errors
|
check-for-errors: 'true'
|
||||||
run: if grep -q "invalid syntax" "i18n.log"; then echo "\n\nFound compilation errors!\n\n" && exit 1; else echo "\n\nNo compilation errors!\n\n"; fi
|
|
||||||
|
|
||||||
# EXPO_PUBLIC_ENV is handled in eas.json
|
# EXPO_PUBLIC_ENV is handled in eas.json
|
||||||
- name: Env
|
- name: Env
|
||||||
|
|||||||
@@ -73,10 +73,9 @@ jobs:
|
|||||||
key: ${{ runner.os }}-pods-${{ hashFiles('yarn.lock') }}
|
key: ${{ runner.os }}-pods-${{ hashFiles('yarn.lock') }}
|
||||||
|
|
||||||
- name: 🔤 Compile translations
|
- name: 🔤 Compile translations
|
||||||
run: yarn intl:build 2>&1 | tee i18n.log
|
uses: ./.github/actions/build-translations
|
||||||
|
with:
|
||||||
- name: Check for i18n compilation errors
|
check-for-errors: 'true'
|
||||||
run: if grep -q "invalid syntax" "i18n.log"; then echo "\n\nFound compilation errors!\n\n" && exit 1; else echo "\n\nNo compilation errors!\n\n"; fi
|
|
||||||
|
|
||||||
# EXPO_PUBLIC_ENV is handled in eas.json
|
# EXPO_PUBLIC_ENV is handled in eas.json
|
||||||
- name: ✏️ Write environment variables
|
- name: ✏️ Write environment variables
|
||||||
|
|||||||
@@ -79,10 +79,9 @@ jobs:
|
|||||||
run: yarn prettier --check .
|
run: yarn prettier --check .
|
||||||
|
|
||||||
- name: 🔤 Compile translations
|
- name: 🔤 Compile translations
|
||||||
run: yarn intl:build 2>&1 | tee i18n.log
|
uses: ./.github/actions/build-translations
|
||||||
|
with:
|
||||||
- name: Check for i18n compilation errors
|
check-for-errors: 'true'
|
||||||
run: if grep -q "invalid syntax" "i18n.log"; then echo "\n\nFound compilation errors!\n\n" && exit 1; else echo "\n\nNo compilation errors!\n\n"; fi
|
|
||||||
|
|
||||||
- name: Type check
|
- name: Type check
|
||||||
run: yarn typecheck
|
run: yarn typecheck
|
||||||
@@ -214,7 +213,7 @@ jobs:
|
|||||||
key: ${{ runner.os }}-pods-${{ hashFiles('yarn.lock') }}
|
key: ${{ runner.os }}-pods-${{ hashFiles('yarn.lock') }}
|
||||||
|
|
||||||
- name: 🔤 Compile translations
|
- name: 🔤 Compile translations
|
||||||
run: yarn intl:build
|
uses: ./.github/actions/build-translations
|
||||||
|
|
||||||
# EXPO_PUBLIC_ENV is handled in eas.json
|
# EXPO_PUBLIC_ENV is handled in eas.json
|
||||||
- name: Env
|
- name: Env
|
||||||
@@ -307,7 +306,7 @@ jobs:
|
|||||||
run: yarn install --frozen-lockfile
|
run: yarn install --frozen-lockfile
|
||||||
|
|
||||||
- name: 🔤 Compile translations
|
- name: 🔤 Compile translations
|
||||||
run: yarn intl:build
|
uses: ./.github/actions/build-translations
|
||||||
|
|
||||||
# EXPO_PUBLIC_ENV is handled in eas.json
|
# EXPO_PUBLIC_ENV is handled in eas.json
|
||||||
- name: Env
|
- name: Env
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ jobs:
|
|||||||
- name: Prettier check
|
- name: Prettier check
|
||||||
run: yarn prettier --check .
|
run: yarn prettier --check .
|
||||||
- name: Check & compile i18n
|
- name: Check & compile i18n
|
||||||
run: yarn intl:build
|
uses: ./.github/actions/build-translations
|
||||||
|
with:
|
||||||
|
check-for-errors: 'true'
|
||||||
- name: Type check
|
- name: Type check
|
||||||
run: yarn typecheck
|
run: yarn typecheck
|
||||||
testing:
|
testing:
|
||||||
@@ -55,7 +57,9 @@ jobs:
|
|||||||
attempt_limit: 3
|
attempt_limit: 3
|
||||||
attempt_delay: 2000
|
attempt_delay: 2000
|
||||||
- name: Check & compile i18n
|
- name: Check & compile i18n
|
||||||
run: yarn intl:build
|
uses: ./.github/actions/build-translations
|
||||||
|
with:
|
||||||
|
check-for-errors: 'true'
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
NODE_ENV=test yarn test --forceExit
|
NODE_ENV=test yarn test --forceExit
|
||||||
|
|||||||
@@ -133,10 +133,7 @@ jobs:
|
|||||||
run: yarn lockfile-lint
|
run: yarn lockfile-lint
|
||||||
|
|
||||||
- name: 🔤 Compile translations
|
- name: 🔤 Compile translations
|
||||||
run: yarn intl:build 2>&1 | tee i18n.log
|
uses: ./.github/actions/build-translations
|
||||||
|
|
||||||
- name: Check for i18n compilation errors
|
|
||||||
run: if grep -q "invalid syntax" "i18n.log"; then echo "\n\nFound compilation errors!\n\n" && exit 1; else echo "\n\nNo compilation errors!\n\n"; fi
|
|
||||||
|
|
||||||
- name: Type check
|
- name: Type check
|
||||||
run: yarn typecheck
|
run: yarn typecheck
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ jobs:
|
|||||||
git config --global user.name "github-actions[bot]"
|
git config --global user.name "github-actions[bot]"
|
||||||
git merge --no-edit $HEAD_REF
|
git merge --no-edit $HEAD_REF
|
||||||
yarn install
|
yarn install
|
||||||
yarn intl:build
|
|
||||||
|
- name: 🔤 Compile translations
|
||||||
|
uses: ./.github/actions/build-translations
|
||||||
|
|
||||||
- name: 🔦 Generate stats file for PR
|
- name: 🔦 Generate stats file for PR
|
||||||
run: |
|
run: |
|
||||||
@@ -81,7 +83,14 @@ jobs:
|
|||||||
if: ${{ !steps.get-base-stats.outputs.cache-hit }}
|
if: ${{ !steps.get-base-stats.outputs.cache-hit }}
|
||||||
run: |
|
run: |
|
||||||
yarn install
|
yarn install
|
||||||
yarn intl:build
|
|
||||||
|
- name: 🔤 Compile translations (base)
|
||||||
|
if: ${{ !steps.get-base-stats.outputs.cache-hit }}
|
||||||
|
uses: ./.github/actions/build-translations
|
||||||
|
|
||||||
|
- name: 🔦 Generate base stats
|
||||||
|
if: ${{ !steps.get-base-stats.outputs.cache-hit }}
|
||||||
|
run: |
|
||||||
yarn generate-webpack-stats-file
|
yarn generate-webpack-stats-file
|
||||||
mv stats.json stats-base.json
|
mv stats.json stats-base.json
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user