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
|
||||
|
||||
- name: 🔤 Compile translations
|
||||
run: yarn intl:build 2>&1 | tee i18n.log
|
||||
|
||||
- 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
|
||||
uses: ./.github/actions/build-translations
|
||||
with:
|
||||
check-for-errors: 'true'
|
||||
|
||||
# EXPO_PUBLIC_ENV is handled in eas.json
|
||||
- name: Env
|
||||
|
||||
@@ -73,10 +73,9 @@ jobs:
|
||||
key: ${{ runner.os }}-pods-${{ hashFiles('yarn.lock') }}
|
||||
|
||||
- name: 🔤 Compile translations
|
||||
run: yarn intl:build 2>&1 | tee i18n.log
|
||||
|
||||
- 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
|
||||
uses: ./.github/actions/build-translations
|
||||
with:
|
||||
check-for-errors: 'true'
|
||||
|
||||
# EXPO_PUBLIC_ENV is handled in eas.json
|
||||
- name: ✏️ Write environment variables
|
||||
|
||||
@@ -79,10 +79,9 @@ jobs:
|
||||
run: yarn prettier --check .
|
||||
|
||||
- name: 🔤 Compile translations
|
||||
run: yarn intl:build 2>&1 | tee i18n.log
|
||||
|
||||
- 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
|
||||
uses: ./.github/actions/build-translations
|
||||
with:
|
||||
check-for-errors: 'true'
|
||||
|
||||
- name: Type check
|
||||
run: yarn typecheck
|
||||
@@ -214,7 +213,7 @@ jobs:
|
||||
key: ${{ runner.os }}-pods-${{ hashFiles('yarn.lock') }}
|
||||
|
||||
- name: 🔤 Compile translations
|
||||
run: yarn intl:build
|
||||
uses: ./.github/actions/build-translations
|
||||
|
||||
# EXPO_PUBLIC_ENV is handled in eas.json
|
||||
- name: Env
|
||||
@@ -307,7 +306,7 @@ jobs:
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
- name: 🔤 Compile translations
|
||||
run: yarn intl:build
|
||||
uses: ./.github/actions/build-translations
|
||||
|
||||
# EXPO_PUBLIC_ENV is handled in eas.json
|
||||
- name: Env
|
||||
|
||||
@@ -34,7 +34,9 @@ jobs:
|
||||
- name: Prettier check
|
||||
run: yarn prettier --check .
|
||||
- name: Check & compile i18n
|
||||
run: yarn intl:build
|
||||
uses: ./.github/actions/build-translations
|
||||
with:
|
||||
check-for-errors: 'true'
|
||||
- name: Type check
|
||||
run: yarn typecheck
|
||||
testing:
|
||||
@@ -55,7 +57,9 @@ jobs:
|
||||
attempt_limit: 3
|
||||
attempt_delay: 2000
|
||||
- name: Check & compile i18n
|
||||
run: yarn intl:build
|
||||
uses: ./.github/actions/build-translations
|
||||
with:
|
||||
check-for-errors: 'true'
|
||||
- name: Run tests
|
||||
run: |
|
||||
NODE_ENV=test yarn test --forceExit
|
||||
|
||||
@@ -133,10 +133,7 @@ jobs:
|
||||
run: yarn lockfile-lint
|
||||
|
||||
- name: 🔤 Compile translations
|
||||
run: yarn intl:build 2>&1 | tee i18n.log
|
||||
|
||||
- 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
|
||||
uses: ./.github/actions/build-translations
|
||||
|
||||
- name: Type check
|
||||
run: yarn typecheck
|
||||
|
||||
@@ -57,7 +57,9 @@ jobs:
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git merge --no-edit $HEAD_REF
|
||||
yarn install
|
||||
yarn intl:build
|
||||
|
||||
- name: 🔤 Compile translations
|
||||
uses: ./.github/actions/build-translations
|
||||
|
||||
- name: 🔦 Generate stats file for PR
|
||||
run: |
|
||||
@@ -81,7 +83,14 @@ jobs:
|
||||
if: ${{ !steps.get-base-stats.outputs.cache-hit }}
|
||||
run: |
|
||||
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
|
||||
mv stats.json stats-base.json
|
||||
|
||||
|
||||
Reference in New Issue
Block a user