Skip to content

Commit 4269299

Browse files
therajanmauryaRajan Maurya
andauthored
chore(infra): bootstrap template sync-dirs + retarget to store5Migration (#2681)
Co-authored-by: Rajan Maurya <therajanmaurya@Rajans-MacBook-Pro.local>
1 parent b3ed04e commit 4269299

3 files changed

Lines changed: 72 additions & 48 deletions

File tree

.github/workflows/sync-dirs.yaml

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v4
2424
with:
2525
fetch-depth: 0
26-
ref: dev
26+
ref: store5Migration
2727

2828
- name: Setup Git config
2929
run: |
@@ -56,6 +56,7 @@ jobs:
5656
shell: bash
5757
run: |
5858
set -euo pipefail
59+
5960
# Declare directories and files to sync
6061
DIRS=(
6162
"cmp-android"
@@ -66,33 +67,38 @@ jobs:
6667
"core-base"
6768
"build-logic"
6869
"fastlane"
70+
"fastlane-config"
6971
"scripts"
7072
"config"
7173
".github"
7274
".run"
7375
)
74-
76+
7577
FILES=(
7678
"Gemfile"
7779
"Gemfile.lock"
7880
"ci-prepush.bat"
7981
"ci-prepush.sh"
8082
)
81-
83+
8284
# Define exclusions
85+
# Consumer-branded assets and project-specific configs are preserved across syncs.
8386
declare -A EXCLUSIONS=(
8487
["cmp-android"]="src/main/res dependencies src/main/ic_launcher-playstore.png google-services.json"
85-
["cmp-web"]="src/jsMain/resources src/wasmJsMain/resources"
86-
["cmp-desktop"]="icons"
8788
["cmp-ios"]="iosApp/Assets.xcassets"
89+
["cmp-web"]="src/jsMain/resources src/wasmJsMain/resources"
90+
["cmp-desktop"]="icons build.gradle.kts"
91+
["fastlane-config"]="project_config.rb extract_config.rb"
92+
[".github"]="workflows/sync-dirs.yaml"
93+
["build-logic"]="convention/src/main/kotlin/local"
8894
["root"]="secrets.env"
8995
)
90-
96+
9197
# Function to check if path should be excluded
9298
should_exclude() {
9399
local dir=$1
94100
local path=$2
95-
101+
96102
# Check for root exclusions (when dir is "." or "root")
97103
if [[ "$dir" == "." || "$dir" == "root" ]] && [[ -v "EXCLUSIONS[root]" ]]; then
98104
local root_excluded_paths
@@ -103,7 +109,7 @@ jobs:
103109
fi
104110
done
105111
fi
106-
112+
107113
# Check directory-specific exclusions
108114
if [[ -v "EXCLUSIONS[$dir]" ]]; then
109115
local excluded_paths
@@ -116,7 +122,7 @@ jobs:
116122
fi
117123
return 1
118124
}
119-
125+
120126
# Function to preserve excluded paths
121127
preserve_excluded() {
122128
local dir=$1
@@ -134,7 +140,7 @@ jobs:
134140
done
135141
fi
136142
}
137-
143+
138144
# Function to restore excluded paths
139145
restore_excluded() {
140146
local dir=$1
@@ -153,7 +159,7 @@ jobs:
153159
done
154160
fi
155161
}
156-
162+
157163
# Function to preserve root-level excluded files
158164
preserve_root_files() {
159165
if [[ -v "EXCLUSIONS[root]" ]]; then
@@ -168,7 +174,7 @@ jobs:
168174
done
169175
fi
170176
}
171-
177+
172178
# Function to restore root-level excluded files
173179
restore_root_files() {
174180
if [[ -v "EXCLUSIONS[root]" ]]; then
@@ -182,35 +188,37 @@ jobs:
182188
done
183189
fi
184190
}
185-
191+
186192
# Create temp directory for exclusions
187193
mkdir -p temp_excluded
188-
194+
189195
# Preserve root-level exclusions before sync
190196
preserve_root_files
191-
192-
# Switch to dev branch
193-
git checkout dev
194-
197+
198+
# Switch to integration branch (store5Migration for this epic)
199+
git checkout store5Migration
200+
195201
# Sync directories
196202
for dir in "${DIRS[@]}"; do
197-
if [ ! -d "$dir" ]; then
203+
if [[ ! -d "$dir" ]]; then
198204
echo "Creating $dir..."
199205
mkdir -p "$dir"
200206
fi
201-
207+
202208
# Preserve excluded paths before sync
203209
if [[ -d "$dir" ]]; then
204210
preserve_excluded "$dir"
205211
fi
206-
212+
207213
echo "Syncing $dir..."
208-
git checkout "${{ env.TEMP_BRANCH }}" -- "$dir" || exit 1
209-
214+
if ! git checkout "${{ env.TEMP_BRANCH }}" -- "$dir" 2>/dev/null; then
215+
echo "Warning: Could not sync directory $dir (may not exist in upstream)"
216+
fi
217+
210218
# Restore excluded paths after sync
211219
restore_excluded "$dir"
212220
done
213-
221+
214222
# Sync files
215223
for file in "${FILES[@]}"; do
216224
file_dir=$(dirname "$file")
@@ -225,20 +233,20 @@ jobs:
225233
elif should_exclude "$file_dir" "$file"; then
226234
echo "Skipping excluded file: $file"
227235
continue
228-
fi
229-
230-
echo "Syncing $file..."
231-
if ! git checkout "${{ env.TEMP_BRANCH }}" -- "$file" 2>/dev/null; then
232-
echo "Warning: Could not sync file $file (may not exist in upstream)"
236+
fi
237+
238+
echo "Syncing $file..."
239+
if ! git checkout "${{ env.TEMP_BRANCH }}" -- "$file" 2>/dev/null; then
240+
echo "Warning: Could not sync file $file (may not exist in upstream)"
233241
fi
234242
done
235-
243+
236244
# Restore root-level excluded files
237245
restore_root_files
238-
246+
239247
# Cleanup temp directory
240248
rm -rf temp_excluded
241-
249+
242250
echo "Sync completed successfully!"
243251
244252
- name: Clean up temporary branch
@@ -266,37 +274,38 @@ jobs:
266274
title: "chore: Sync directories and files from upstream"
267275
body: |
268276
Automated sync of directories and files from upstream repository.
269-
277+
270278
Changes included in this sync:
271-
272-
**Directories**:
273-
- cmp-android (excluding src/main/res, dependencies, ic_launcher-playstore.png, google-services.json)
274-
- cmp-desktop (excluding icons)
279+
280+
**Directories:**
281+
- cmp-android (excluding src/main/res, dependencies, src/main/ic_launcher-playstore.png, google-services.json)
282+
- cmp-desktop (excluding icons, build.gradle.kts)
275283
- cmp-ios (excluding iosApp/Assets.xcassets)
276284
- cmp-web (excluding src/jsMain/resources, src/wasmJsMain/resources)
277285
- cmp-shared
278286
- core-base
279-
- build-logic
287+
- build-logic (excluding convention/src/main/kotlin/local — consumer flavor extension point)
280288
- fastlane
289+
- fastlane-config (excluding project_config.rb, extract_config.rb)
281290
- scripts
282291
- config
283-
- .github
292+
- .github (excluding workflows/sync-dirs.yaml — self-overwrite guard)
284293
- .run
285-
286-
**Files**:
294+
295+
**Files:**
287296
- Gemfile
288297
- Gemfile.lock
289298
- ci-prepush.bat
290299
- ci-prepush.sh
291-
292-
**Root-level exclusions**:
300+
301+
**Root-level exclusions:**
293302
- secrets.env
294-
303+
295304
---
296305
Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
297306
branch: sync-dirs-${{ github.run_number }}
298307
delete-branch: true
299308
labels: |
300309
sync
301310
automated pr
302-
base: dev
311+
base: store5Migration

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
*.iml
22
.gradle
33
/local.properties
4+
secrets.env
5+
secrets/
46
/.idea/workspace.xml
57
/.idea/libraries
68
/build

sync-dirs.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ SYNC_DIRS=(
3131
"core-base"
3232
"build-logic"
3333
"fastlane"
34+
"fastlane-config"
3435
"scripts"
3536
"config"
3637
".github"
@@ -49,11 +50,23 @@ SYNC_FILES=(
4950
# type can be 'dir' or 'file'
5051
# Use "root" key for files in the root directory
5152
declare -A EXCLUSIONS=(
53+
# Android — consumer-branded resources (drawables, strings, mipmaps), Firebase config,
54+
# launcher icon, and the dependency-guard baseline directory are preserved across syncs.
5255
["cmp-android"]="src/main/res:dir dependencies:dir src/main/ic_launcher-playstore.png:file google-services.json:file"
53-
["cmp-web"]="src/jsMain/resources:dir src/wasmJsMain/resources:dir"
54-
["cmp-desktop"]="icons:dir"
56+
# iOS — consumer-branded asset catalog (app icon, color palette) preserved across syncs.
5557
["cmp-ios"]="iosApp/Assets.xcassets:dir"
58+
["cmp-web"]="src/jsMain/resources:dir src/wasmJsMain/resources:dir"
59+
["cmp-desktop"]="icons:dir build.gradle.kts:file"
60+
["fastlane-config"]="project_config.rb:file extract_config.rb:file"
61+
[".github"]="workflows/sync-dirs.yaml:file"
5662
["root"]="secrets.env:file"
63+
# DO NOT REMOVE — preserves consumer-specific flavor extensions across syncs.
64+
# Each downstream consumer app (mifos-mobile, mifos-pay, mifos-x-field-officer-app,
65+
# mifos-x-group-banking, mifos-x-open-banking, reels-downloader-new, ...) may
66+
# create build-logic/convention/src/main/kotlin/local/LocalFlavors.kt to add
67+
# their own flavors / dimensions / overrides on top of the synced base.
68+
# See docs/FLAVORS_EXTENSION.md for the pattern.
69+
["build-logic"]="convention/src/main/kotlin/local:dir"
5770
)
5871

5972
# Display help information
@@ -584,4 +597,4 @@ This PR syncs the following items with upstream:
584597
fi
585598
else
586599
echo -e "\n${YELLOW}${BOLD}Dry run completed. No changes were made.${NC}\n"
587-
fi
600+
fi

0 commit comments

Comments
 (0)