Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Revert to single-job conditional approach for efficiency

Neeraj Guptaff1b7f7f79aa
diff --git a/.github/scripts/get-affected-packages.sh b/.github/scripts/get-affected-packages.sh
index f8c64ef596..269734aa77 100755
--- a/.github/scripts/get-affected-packages.sh
+++ b/.github/scripts/get-affected-packages.sh
@@ -10,7 +10,7 @@
#
# Output (JSON to stdout):
# {
-# "packages": ["pkg1", "pkg2", "pkg3"],
+# "packages": "pkg1 pkg2 pkg3",
# "lint_photos": "true/false",
# "lint_auth": "true/false",
# "lint_locker": "true/false",
@@ -165,23 +165,10 @@ main() {
# If linting all, return all packages
if [ "$lint_all" = "true" ]; then
- local all_pkgs=$(find "$PACKAGES_DIR" -maxdepth 1 -type d -not -name "packages" -not -name "rust" -exec basename {} \; | sort)
-
- # Convert to JSON array
- local json_array="["
- local first=true
- for pkg in $all_pkgs; do
- if [ "$first" = true ]; then
- json_array="$json_array\"$pkg\""
- first=false
- else
- json_array="$json_array, \"$pkg\""
- fi
- done
- json_array="$json_array]"
+ local all_pkgs=$(find "$PACKAGES_DIR" -maxdepth 1 -type d -not -name "packages" -not -name "rust" -exec basename {} \; | sort | tr '\n' ' ')
echo "{"
- echo " \"packages\": $json_array,"
+ echo " \"packages\": \"$all_pkgs\","
echo " \"lint_photos\": \"true\","
echo " \"lint_auth\": \"true\","
echo " \"lint_locker\": \"true\","
@@ -206,7 +193,7 @@ main() {
# If no packages changed, nothing to lint
if [ -z "$(echo $changed_pkgs | tr -d ' ')" ]; then
echo "{"
- echo " \"packages\": [],"
+ echo " \"packages\": \"\","
echo " \"lint_photos\": \"false\","
echo " \"lint_auth\": \"false\","
echo " \"lint_locker\": \"false\","
@@ -226,22 +213,9 @@ main() {
local lint_auth=$(check_app_affected "auth" "$affected_pkgs")
local lint_locker=$(check_app_affected "locker" "$affected_pkgs")
- # Convert affected_pkgs to JSON array
- local json_array="["
- local first=true
- for pkg in $affected_pkgs; do
- if [ "$first" = true ]; then
- json_array="$json_array\"$pkg\""
- first=false
- else
- json_array="$json_array, \"$pkg\""
- fi
- done
- json_array="$json_array]"
-
# Output JSON
echo "{"
- echo " \"packages\": $json_array,"
+ echo " \"packages\": \"$affected_pkgs\","
echo " \"lint_photos\": \"$lint_photos\","
echo " \"lint_auth\": \"$lint_auth\","
echo " \"lint_locker\": \"$lint_locker\","
diff --git a/.github/workflows/mobile-packages-lint.yml b/.github/workflows/mobile-packages-lint.yml
index 14f7bc8e29..4d148e7773 100644
--- a/.github/workflows/mobile-packages-lint.yml
+++ b/.github/workflows/mobile-packages-lint.yml
@@ -64,7 +64,7 @@ jobs:
echo "$RESULT"
# Extract values from JSON
- PACKAGES=$(echo "$RESULT" | jq -c '.packages')
+ PACKAGES=$(echo "$RESULT" | jq -r '.packages')
LINT_PHOTOS=$(echo "$RESULT" | jq -r '.lint_photos')
LINT_AUTH=$(echo "$RESULT" | jq -r '.lint_auth')
LINT_LOCKER=$(echo "$RESULT" | jq -r '.lint_locker')
@@ -89,11 +89,7 @@ jobs:
needs: detect-changes
runs-on: ubuntu-latest
# Skip if no packages need linting
- if: needs.detect-changes.outputs.lint_all == 'true' || toJson(fromJson(needs.detect-changes.outputs.packages)) != '[]'
- strategy:
- fail-fast: false
- matrix:
- package: ${{ fromJson(needs.detect-changes.outputs.packages) }}
+ if: needs.detect-changes.outputs.lint_all == 'true' || needs.detect-changes.outputs.packages != ''
steps:
- name: Checkout code and submodules
uses: actions/checkout@v4
@@ -124,14 +120,109 @@ jobs:
working-directory: mobile/packages/rust
- name: Generate strings localizations
- if: matrix.package == 'strings'
run: flutter gen-l10n
working-directory: mobile/packages/strings
- # Lint the package from the matrix
- - name: Lint package - ${{ matrix.package }}
+ # Lint all affected packages conditionally
+ - name: Lint package - accounts
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'accounts')
run: flutter pub get && flutter analyze --no-fatal-infos
- working-directory: mobile/packages/${{ matrix.package }}
+ working-directory: mobile/packages/accounts
+
+ - name: Lint package - base
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'base')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/base
+
+ - name: Lint package - configuration
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'configuration')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/configuration
+
+ - name: Lint package - dir_utils
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'dir_utils')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/dir_utils
+
+ - name: Lint package - ente_crypto_api
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'ente_crypto_api')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/ente_crypto_api
+
+ - name: Lint package - ente_crypto_dart_adapter
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'ente_crypto_dart_adapter')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/ente_crypto_dart_adapter
+
+ - name: Lint package - ente_icons
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'ente_icons')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/ente_icons
+
+ - name: Lint package - ente_pure_utils
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'ente_pure_utils')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/ente_pure_utils
+
+ - name: Lint package - events
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'events')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/events
+
+ - name: Lint package - legacy
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'legacy')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/legacy
+
+ - name: Lint package - lock_screen
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'lock_screen')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/lock_screen
+
+ - name: Lint package - log_viewer
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'log_viewer')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/log_viewer
+
+ - name: Lint package - logging
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'logging')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/logging
+
+ - name: Lint package - native_video_editor
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'native_video_editor')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/native_video_editor
+
+ - name: Lint package - network
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'network')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/network
+
+ - name: Lint package - qr
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'qr')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/qr
+
+ - name: Lint package - sharing
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'sharing')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/sharing
+
+ - name: Lint package - strings
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'strings')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/strings
+
+ - name: Lint package - ui
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'ui')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/ui
+
+ - name: Lint package - utils
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'utils')
+ run: flutter pub get && flutter analyze --no-fatal-infos
+ working-directory: mobile/packages/utils
rust-lint:
needs: detect-changes