Skip to content

Commit

Permalink
[#491] Migrate SetUpTestFirebase
Browse files Browse the repository at this point in the history
  • Loading branch information
blyscuit committed Aug 4, 2023
1 parent 4a661bc commit d4ef290
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_upload_build_to_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
run: sh make.sh --bundle-id co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface UIKit

- name: Start Setup Script for Template App Firebase Upload
run: cat Scripts/Swift/SetUpTestFirebase.swift Scripts/Swift/Extensions/FileManager+Utils.swift Scripts/Swift/Helpers/SafeShell.swift | swift -
run: cat Scripts/Swift/SetUpTestFirebase.swift Scripts/Swift/Extensions/FileManager+Bash.swift Scripts/Swift/Helpers/SafeShell.swift | swift -
env:
MATCH_REPO: ${{ secrets.MATCH_REPO }}
STAGING_FIREBASE_APP_ID: ${{ secrets.STAGING_FIREBASE_APP_ID }}
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Swift/Extensions/FileManager+Bash.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation

extension FileManager {

func replaceAllOccurrences(of original: String, to replacing: String) throws {
try safeShell("LC_ALL=C find \(currentDirectoryPath) -type f -exec sed -i \"\" \"s/\(original)/\(replacing)/g\" {} +")
}
}
9 changes: 4 additions & 5 deletions Scripts/Swift/SetUpTestFirebase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ let matchRepoEscaped = envMatchRepo.replacingOccurrences(of: "/", with: "\\/")
let firebaseTesterGroup = "nimble"

let fileManager = FileManager.default
let workingDirectory = fileManager.currentDirectoryPath.replacingOccurrences(of: "/", with: "\\/")

try safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantTeamId)/\(envTeamId)/g\" {} +")
try safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantStagingFirebaseAppId)/\(envStagingFirebaseAppId)/g\" {} +")
try safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantFirebaseTesterGroups)/\(firebaseTesterGroup)/g\" {} +")
try safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantMatchRepo)/\(matchRepoEscaped)/g\" {} +")
try fileManager.replaceAllOccurrences(of: ConstantTeamId, to: envTeamId)
try fileManager.replaceAllOccurrences(of: ConstantStagingFirebaseAppId, to: envStagingFirebaseAppId)
try fileManager.replaceAllOccurrences(of: ConstantFirebaseTesterGroups, to: firebaseTesterGroup)
try fileManager.replaceAllOccurrences(of: ConstantMatchRepo, to: matchRepoEscaped)
2 changes: 1 addition & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ if [[ -z "${CI}" ]]; then
rm -f set_up_test_testflight.sh
cat Scripts/Swift/SetUpCICDService.swift Scripts/Swift/Extensions/FileManager+Utils.swift Scripts/Swift/Helpers/SafeShell.swift > t.swift && swift t.swift && rm -rf 't.swift'
cat Scripts/Swift/SetUpDeliveryConstants.swift Scripts/Swift/Extensions/FileManager+Utils.swift Scripts/Swift/Helpers/SafeShell.swift > t.swift && swift t.swift && rm -rf 't.swift'
rm -rf Scripts
fi

rm -rf Scripts

echo "✅ Completed"

Expand Down

0 comments on commit d4ef290

Please sign in to comment.