Skip to content

Commit

Permalink
ci: reorder CI tasks for improved workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
esmaeil.ahmadipour committed Jan 9, 2025
1 parent 2b3e3ab commit 555c38b
Showing 1 changed file with 37 additions and 38 deletions.
75 changes: 37 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,69 @@ jobs:
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)

- name: Run Dart Format Check
run: |
dart format . --set-exit-if-changed --output none || (
echo "Code formatting issues detected. Run 'dart format .' and commit the changes.";
exit 1;
)
- name: Run Flutter Analyze
run: flutter analyze
- name: Generate Localization Files (Easy Localization)
run: |
# Generate locale keys
dart run easy_localization:generate -f keys -o locale_keys.g.dart --source-dir=assets/translations --output-dir=lib/src/core/utils/gen/localization || (
echo "Error: Failed to generate locale keys.";
exit 1;
)
- name: Generate Assets Files
# Asset Generation and Check
- name: Generate Asset 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: 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: Run Dart Format Check
run: |
dart format . --set-exit-if-changed || (
echo "Code formatting issues detected. Run 'dart format .' and commit the changes.";
exit 1;
)
# Localization Generation and Check
- name: Generate Localization Files
id: gen_l10n
run: |
# Run the command to generate localization files and capture the output
output=$(flutter gen-l10n --arb-dir=assets/translations)
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: Run Flutter Analyze
run: flutter analyze

- name: Run tests
run: flutter test

merge_check:
runs-on: ubuntu-latest
needs: lint_and_test
Expand All @@ -81,4 +80,4 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Merge Pull Request
run: echo "Linting and tests passed successfully.Merge request is ready for merge"
run: echo "Linting and tests passed successfully. Merge request is ready for merge."

0 comments on commit 555c38b

Please sign in to comment.