-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOEN-32286: Updated with base branch
- Loading branch information
Showing
45 changed files
with
612 additions
and
148 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env kotlin | ||
|
||
import java.io.BufferedReader | ||
import java.io.File | ||
import java.io.InputStreamReader | ||
|
||
private val pluginsPath = setOf( | ||
"/sdk/cards", | ||
"/sdk/core", | ||
"/sdk/geofence", | ||
"/sdk/inbox" | ||
) | ||
|
||
/** | ||
* Executes the provided command in working directory on the bash shell. | ||
*/ | ||
fun executeCommandOnShell(command: String): Int { | ||
val process = ProcessBuilder("/bin/bash", "-c", command).inheritIO().start() | ||
return process.waitFor() | ||
} | ||
|
||
/** | ||
* Executes the provided command in given directory on the bash shell. | ||
*/ | ||
fun executeCommandOnShell(directory: String, command: String): Int { | ||
val process = ProcessBuilder("/bin/bash", "-c", command).inheritIO() | ||
.directory(File(directory)).start() | ||
return process.waitFor() | ||
} | ||
|
||
/** | ||
* Executes the given command on bash shell and returns the output as a string. | ||
*/ | ||
fun executeShellCommandWithStringOutput(command: String): String { | ||
val process = ProcessBuilder("/bin/bash", "-c", command).start() | ||
val reader = BufferedReader(InputStreamReader(process.inputStream)) | ||
var line: String? | ||
val builder = StringBuilder() | ||
while (reader.readLine().also { line = it } != null) { | ||
builder.append(line).append(System.getProperty("line.separator")) | ||
} | ||
return builder.toString().trim() | ||
} | ||
|
||
/** | ||
* Returns all the plugins list | ||
*/ | ||
fun getAllPluginsPath(): Set<String> = pluginsPath | ||
|
||
/** | ||
* Returns the install-local command to install all plugins into sampleapp directory | ||
*/ | ||
fun getInstallLocalCommand(): String { | ||
var command = "install-local " | ||
pluginsPath.forEach { module -> | ||
command += "../$module " | ||
} | ||
return command | ||
} | ||
|
||
/** | ||
* Create the local.properties file in given directory | ||
*/ | ||
fun createLocalPropertiesFile(directory: String) { | ||
executeCommandOnShell(directory, "echo moengageAppId=\"Dummy MoEngage Key\" >> ./local.properties") | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/usr/bin/env kotlin | ||
|
||
@file:Import("common-utils.main.kts") | ||
|
||
import kotlin.system.exitProcess | ||
|
||
val sampleAppDirectory = "SampleApp" | ||
val androidAppDirectory = "android" | ||
val iOSAppDirectory = "ios" | ||
|
||
val workingDirectory = executeShellCommandWithStringOutput("pwd") | ||
println(workingDirectory) | ||
|
||
/** | ||
* Verify the react-native plugins | ||
* Verification: | ||
* 1. Install | ||
* 2. Testcases | ||
* 2. Tsc Configuration | ||
*/ | ||
getAllPluginsPath().forEach { module -> | ||
println("::group::Verifying: $module") | ||
val moduleDirectory = workingDirectory + module | ||
executeCommandOnShell(moduleDirectory, "npm install") | ||
|
||
if (executeCommandOnShell(moduleDirectory, "npm test") != 0) { | ||
println("::error::Test Cases Failed: $module") | ||
exitProcess(1) | ||
} | ||
|
||
if (executeCommandOnShell(moduleDirectory, "tsc --noEmit") != 0) { | ||
println("::error::Typescript Config Failed: $module") | ||
exitProcess(1) | ||
} | ||
|
||
println("::notice::Verified: $module") | ||
println("::endgroup::") | ||
} | ||
|
||
// SampleApp Setup | ||
executeCommandOnShell("$workingDirectory/$sampleAppDirectory", "npm install -g install-local") | ||
executeCommandOnShell("$workingDirectory/$sampleAppDirectory", "npm install") | ||
executeCommandOnShell("$workingDirectory/$sampleAppDirectory", getInstallLocalCommand()) | ||
createLocalPropertiesFile("$workingDirectory/$sampleAppDirectory/$androidAppDirectory") | ||
|
||
/** | ||
* Verify the Android SampleApp | ||
*/ | ||
println("::group::Verifying: SampleApp/Android") | ||
if (executeCommandOnShell("$workingDirectory/$sampleAppDirectory/$androidAppDirectory", "./gradlew assemble") != 0) { | ||
println("::error::Android Assemble Failed") | ||
exitProcess(1) | ||
} | ||
|
||
println("::notice::Verified: SampleApp/Android") | ||
println("::endgroup::") | ||
|
||
/** | ||
* Verify the iOS SampleApp | ||
*/ | ||
|
||
println("::group::Verifying: SampleApp/iOS") | ||
|
||
// Attempt to install CocoaPods | ||
if (executeCommandOnShell("$workingDirectory/$sampleAppDirectory/$iOSAppDirectory", "sudo gem install cocoapods") != 0) { | ||
println("::error::Failed to install CocoaPods") | ||
exitProcess(1) | ||
} else { | ||
println("::notice::CocoaPods installed successfully") | ||
} | ||
|
||
|
||
// Remove Podfile Lock | ||
val removePodfileLockResult = executeCommandOnShell("$workingDirectory/$sampleAppDirectory/$iOSAppDirectory", "rm -f Podfile.lock") | ||
if (removePodfileLockResult != 0) { | ||
println("::error::Failed to delete Podfile.lock") | ||
exitProcess(1) | ||
} | ||
|
||
// Update the pod repository | ||
val updateRepoResult = executeCommandOnShell("$workingDirectory/$sampleAppDirectory/$iOSAppDirectory", "pod repo update") | ||
if (updateRepoResult != 0) { | ||
println("::error::Failed to update pod repo") | ||
exitProcess(1) | ||
} | ||
|
||
if (executeCommandOnShell("$workingDirectory/$sampleAppDirectory/$iOSAppDirectory", "NO_FLIPPER=1 pod install") != 0) { | ||
println("::error::iOS Pod install Failed") | ||
exitProcess(1) | ||
} | ||
|
||
if (executeCommandOnShell("$workingDirectory/$sampleAppDirectory/$iOSAppDirectory", | ||
"xcodebuild -workspace SampleApp.xcworkspace " + | ||
"-scheme SampleApp " + | ||
"-sdk iphonesimulator") != 0) { | ||
exitProcess(1) | ||
} | ||
println("::notice::Verified: SampleApp/ios") | ||
println("::endgroup::") | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Verify Pull Request | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [ opened, reopened, ready_for_review, synchronize ] | ||
branches: [ "development", "master" ] | ||
jobs: | ||
verify: | ||
runs-on: macos-latest | ||
if: ${{ !github.event.pull_request.draft }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
xcode: ["15.3"] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.5.1 | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: 17 | ||
- name: Set up gradle cache | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
cache-read-only: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/development'}} | ||
- name: Setup script | ||
run: | | ||
chmod +x .github/scripts/common-utils.main.kts | ||
chmod +x .github/scripts/verify-plugins.main.kts | ||
- name: Verify | ||
run: | | ||
kotlinc -script .github/scripts/verify-plugins.main.kts |
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
Oops, something went wrong.