refactor: use l10n
for localization and centralize translation keys
#120
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: Linting & Tests Validation | |
on: | |
pull_request: | |
branches: | |
- develop | |
jobs: | |
lint_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.24.5' | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Run Dart Format Check (Efficient) | |
run: | | |
dart format . --set-exit-if-changed --output none || ( | |
echo "Code formatting issues detected. Run 'dart format .' and commit the changes."; | |
exit 1; | |
) | |
- name: Generate Localization Files | |
id: gen_l10n | |
run: | | |
# Run the command to generate localization files and capture the output | |
output=$(flutter gen-l10n) | |
echo "$output" | |
# Check if there are untranslated messages in the output | |
if echo "$output" | grep -q "untranslated message"; then | |
echo "::error file=lib/l10n/l10n.yaml::Error: Untranslated messages detected in your localization files." | |
echo "::error::There are untranslated messages in the following languages:" | |
echo "$output" | grep "untranslated message" | |
echo "::error::Please ensure that all translations are provided in the respective .arb files." | |
exit 1 | |
fi | |
- name: Check Localization Files | |
run: | | |
git diff --exit-code lib/l10n/ || ( | |
echo "Localization files are outdated. Run 'flutter gen-l10n' and commit changes."; | |
exit 1; | |
) | |
- name: Check if translations_utils.dart has changes | |
run: | | |
git diff --exit-code lib/src/core/utils/gen/localization/translations_utils.dart || ( | |
echo "Error: Changes detected in translations_utils.dart. Please run the necessary custom translation utilities and commit changes."; | |
exit 1; | |
) | |
- name: Generate Assets Files | |
run: | | |
# Command to rebuild asset files | |
dart run build_runner build --delete-conflicting-outputs --build-filter="lib/src/core/utils/gen/assets/*.dart" || ( | |
echo "Error: Failed to generate asset files."; | |
exit 1; | |
) | |
- name: Check Asset Files Changes | |
run: | | |
# Check if there are changes after generating asset files | |
git diff --exit-code lib/src/core/utils/gen/assets || ( | |
echo "Error: Asset files are outdated. Run the generation command and commit the changes."; | |
exit 1; | |
) | |
- name: Run Flutter Analyze | |
run: flutter analyze | |
- name: Run Dart Format and Check Localization Files Changes | |
run: | | |
# Run dart format without failing the step | |
dart format . || echo "dart format completed with warnings, but continuing pipeline." | |
# Check if there are changes in the localization files after generation | |
git diff --exit-code lib/src/core/utils/gen/localization || ( | |
echo "Error: Localization files are outdated. Run the generation command and commit the changes."; | |
exit 1; | |
) | |
- name: Run tests | |
run: flutter test | |
merge_check: | |
runs-on: ubuntu-latest | |
needs: lint_and_test | |
if: ${{ success() }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Merge Pull Request | |
run: echo "Linting and tests passed successfully.Merge request is ready for merge" |