Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Rewrite scripts to Kotlin #1246

Merged
merged 99 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
a9061d0
feat: Change updateFlank script to Kotlin
Oct 7, 2020
42a6370
create PathHelper
Oct 7, 2020
fb5b260
added buildGo script
Oct 7, 2020
54e3a77
GradleCommand, updateFlank - windows compability
adamfilipow92 Oct 7, 2020
45e0a32
fix GradleCommand.kt
Oct 7, 2020
8146ca4
added buildFlankScripts.main.kts
Oct 7, 2020
b4f9081
fixed buildGo script
Oct 7, 2020
0ccd254
added testFilters helpers
Oct 7, 2020
089e338
Add android paths, initial work of android build command
adamfilipow92 Oct 7, 2020
3907e38
Add build of base android apk and tests with copy to directory
adamfilipow92 Oct 8, 2020
6819e5a
added update library kotlin script
Oct 9, 2020
2f1473b
WIP added first iteration of windows file downloads
Sloox Oct 9, 2020
1dcdfa6
Add duplicated apk names build and doc
adamfilipow92 Oct 9, 2020
b873e0a
Update android.ops.main.kts
adamfilipow92 Oct 9, 2020
8aa867c
Added build of multiModule app and cucumber App
adamfilipow92 Oct 9, 2020
8e699d2
Update android.ops.main.kts
adamfilipow92 Oct 9, 2020
61bf5a2
adding updatingJson and generatingJavaClient
Oct 9, 2020
58c85c3
initial ios
adamfilipow92 Oct 9, 2020
e3495b2
Update ios.ops.main.kts
adamfilipow92 Oct 12, 2020
3dd546a
Update ios.ops.main.kts
adamfilipow92 Oct 12, 2020
5354945
Update ios.ops.main.kts
adamfilipow92 Oct 12, 2020
7643a2c
run pod install working
adamfilipow92 Oct 12, 2020
72f30ca
Build and copy ios artifacts
adamfilipow92 Oct 13, 2020
7485a8f
added ios scripts
Oct 13, 2020
ba806ea
added iosScripts
Oct 13, 2020
cc3fcd0
directories reorganization
Oct 13, 2020
2814cf7
refactor utils
Oct 13, 2020
a8762cd
Update ios.ops.main.kts
adamfilipow92 Oct 13, 2020
391f633
Ios Command in separated file
adamfilipow92 Oct 13, 2020
a0d974c
ios example change to createCommand
adamfilipow92 Oct 13, 2020
a3eecf8
Move some functions of ios to downloadSoftware main
adamfilipow92 Oct 13, 2020
39d1929
refactor utils
Oct 13, 2020
dd3986a
Update ios.ops.main.kts
adamfilipow92 Oct 14, 2020
f22a5ff
Add go build execution to ops
adamfilipow92 Oct 14, 2020
6a2169c
added shell and bat script for firebase api
Oct 14, 2020
1415eeb
added shell for generate java client
Oct 14, 2020
0cf94a6
refactor gradle helper
Oct 14, 2020
801163f
Update buildGo.main.kts
adamfilipow92 Oct 14, 2020
3737a4a
Update buildGo.main.kts
adamfilipow92 Oct 14, 2020
cde29b8
add scripts for update flank and build flank scripts
Oct 14, 2020
feb2125
refractor
adamfilipow92 Oct 15, 2020
4f32ae5
added scripts for go
Oct 15, 2020
38972fb
added directory to scripts
Oct 15, 2020
b9fe939
added script fo unversal framework
Oct 15, 2020
f268981
clean up
Oct 15, 2020
eca5b7f
Gradle compability with windows
adamfilipow92 Oct 15, 2020
b4b68cd
fix execution
Oct 15, 2020
88ad0b7
Update android script
adamfilipow92 Oct 15, 2020
b5ff48f
Update updateFlank.main.kts
adamfilipow92 Oct 15, 2020
d84990b
Windows compability for build/update flank
adamfilipow92 Oct 15, 2020
27a3fa5
Update formating
adamfilipow92 Oct 15, 2020
3b18d5c
fast fail on mac only scripts
Oct 15, 2020
8fd0d9c
Added section to web page
Oct 16, 2020
b447e8b
fix windows scripts
Oct 16, 2020
9e0994a
Add build option for standalone run
adamfilipow92 Oct 19, 2020
67f28b9
remove unused environment declaration
piotradamczyk5 Oct 19, 2020
3eb7a88
Update flank-bash/scripts/android.ops.main.kts
adamfilipow92 Oct 19, 2020
7cca63f
code formating
adamfilipow92 Oct 19, 2020
307ef1c
code style changes
Oct 19, 2020
51ecdaa
Add check and install command
adamfilipow92 Oct 20, 2020
060756b
Add download software
adamfilipow92 Oct 20, 2020
af9f4c0
rewrite updateBinaries to flankScripts
Oct 20, 2020
dd12e15
rewrite updateBinaries to flankScripts
Oct 20, 2020
d7dc97a
rewrite updateBinaries to flankScripts
Oct 20, 2020
0706fa4
Move firebase to shell
adamfilipow92 Oct 20, 2020
3d3555f
Add custom error on generate java client
adamfilipow92 Oct 20, 2020
4474e0b
rewrite ios to flankScripts
Oct 20, 2020
e5a79db
Add UpdateApiJsonCommand
adamfilipow92 Oct 20, 2020
ea7b482
Ops commands initial
adamfilipow92 Oct 20, 2020
9b44397
Add android build
adamfilipow92 Oct 20, 2020
ad98549
rewrite buildFlank, testFilter and goops to flankScripts
Oct 20, 2020
9f4f17a
Change classes to objects
adamfilipow92 Oct 20, 2020
21ffcd1
added ios ops and make some code and documentation changes
Oct 20, 2020
1e8bb9b
added shell command
Oct 20, 2020
ba350d1
fixed scripts for building flankScripts
Oct 20, 2020
e087491
remove standalon flank bash
Oct 20, 2020
17e1e4c
fixed native scripts
Oct 20, 2020
5fbfc22
fix native scripts and descriptions
Oct 21, 2020
0b57eb9
update documentation
Oct 21, 2020
4cabf5a
fix scripts
Oct 21, 2020
9fad9d2
Add --copy --generate --artifacts options
adamfilipow92 Oct 21, 2020
615edce
update documentation for ops
Oct 21, 2020
a6f7a66
Update ops.sh
adamfilipow92 Oct 21, 2020
fec6817
Add ios commands
adamfilipow92 Oct 22, 2020
b85308a
Add windows batch script
adamfilipow92 Oct 22, 2020
541e84c
Add batch script to build android
adamfilipow92 Oct 22, 2020
c065c0b
Fix build on windows
adamfilipow92 Oct 22, 2020
0f2b328
Merge branch 'master' into #1178-rewrite_scripts_to_kotlin
adamfilipow92 Oct 27, 2020
d2db108
Update EarlGrey ops
adamfilipow92 Oct 27, 2020
8bece90
Merge branch 'master' into #1178-rewrite_scripts_to_kotlin
adamfilipow92 Oct 29, 2020
7bd1a07
Update simple-ios-flank.yml
adamfilipow92 Oct 29, 2020
32ac866
fix ops.sh script
Oct 26, 2020
c6cd1f2
fixed pipe
Oct 29, 2020
485ed3f
Add support for FlankExample build
adamfilipow92 Oct 29, 2020
cac8b2c
Add commands for biuld flankExample and earlGreyExample
adamfilipow92 Oct 30, 2020
44ae1d4
Update README.md
adamfilipow92 Oct 30, 2020
623f2d8
Merge branch 'master' into #1178-rewrite_scripts_to_kotlin
adamfilipow92 Oct 30, 2020
2680656
Update buildFlankScripts.bat
piotradamczyk5 Oct 30, 2020
60e5f4a
Merge branch 'master' into #1178-rewrite_scripts_to_kotlin
piotradamczyk5 Nov 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ object Dependencies {
const val KOTLIN_SERIALIZATION = "org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.KOTLIN_SERIALIZATION}"

//region flank-scripts
const val ARCHIVE_LIB = "org.rauschig:jarchivelib:${Versions.ARCHIVE_LIB}"
const val TUKAANI_XZ = "org.tukaani:xz:${Versions.TUKAANI_XZ}"
const val CLIKT = "com.github.ajalt:clikt:${Versions.CLIKT}"
const val JCABI_GITHUB = "com.jcabi:jcabi-github:${Versions.JCABI_GITHUB}"
const val SLF4J_NOP = "org.slf4j:slf4j-nop:${Versions.SLF4J_NOP}"
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ object Versions {
const val PROGUARD = "7.0.0"

// ============== flank-scripts ==============
const val ARCHIVE_LIB = "1.1.0"
const val TUKAANI_XZ = "1.0"
const val KOTLIN_SERIALIZATION = "1.0.0"
const val FUEL = "2.3.0"
const val CLIKT = "2.8.0"
Expand Down
2 changes: 2 additions & 0 deletions firebase_apis/generate_java_client.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SET DIR=%~dp0
%DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase generateJavaClient
34 changes: 2 additions & 32 deletions firebase_apis/generate_java_client.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@
#!/bin/bash

# Note: Must have already installed google-apis-client-generator from the master branch. PIP release will not work!

# git clone https://github.com/google/apis-client-generator.git
# xcode-select --install
# brew install python@2
# export PATH="/usr/local/opt/python@2/libexec/bin:$PATH"
# pip install --upgrade pip setuptools
# pip install .

# Generate only the testing library since the others are published officially already.

# generate_library \
# --input=./storage_v1.json \
# --language=java \
# --output_dir=./storage

rm -rf "./test_api/src/"

generate_library \
--input=./json/testing_v1.json \
--language=java \
--package_path=api/services \
--output_dir=./test_api/src/main/java

mv ./test_api/src/main/java/pom.xml ./test_api/pom.xml

# generate_library \
# --input=./toolresults_v1beta3.json \
# --language=java \
# --output_dir=./apis/toolresults
DIR=`dirname "$BASH_SOURCE"`
$DIR/../flank-scripts/bash/flankScripts shell firebase generateJavaClient
2 changes: 2 additions & 0 deletions firebase_apis/update_api_json.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SET DIR=%~dp0
%DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase updateApiJson
20 changes: 2 additions & 18 deletions firebase_apis/update_api_json.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
#!/usr/bin/env bash

# npm -g install sort-json

# Note: API discovery JSON is out of date. Check the gcloud CLI repo for most recent JSON.
# https://github.com/bootstraponline/gcloud_cli/blob/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json

cd json

TOOL_RESULTS=toolresults_v1beta3.json
rm "$TOOL_RESULTS"
curl -o "$TOOL_RESULTS" https://www.googleapis.com/discovery/v1/apis/toolresults/v1beta3/rest
sort-json "$TOOL_RESULTS"

TESTING=testing_v1.json
rm "$TESTING"
curl -o "$TESTING" https://www.googleapis.com/discovery/v1/apis/testing/v1/rest
sort-json "$TESTING"
DIR=`dirname "$BASH_SOURCE"`
$DIR/../flank-scripts/bash/flankScripts shell firebase updateApiJson
81 changes: 81 additions & 0 deletions flank-scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,84 @@ All [testArtifacts](../flank-scripts/src/main/kotlin/flank/scripts/testartifacts
#### `resolve`
Automatically prepare local artifacts if needed.

### Shell

To show all available commands for shell use: `flankScripts shell`

Available commands are:
- `firebase` Contains all firebase commands
- `iosBuildExample` Build example ios app
- `iosBuildFtl` Build ftl ios app
- `iosRunFtlLocal` Run ftl locally ios app
- `iosUniversalFramework` Create Universal Framework
- `ops` Contains all ops command: android, ios, gp
- `updateBinaries` Update binaries used by Flank
- `buildFlank` Build Flank

#### `firebase`

Contains tasks related to firebase client generation.
These tasks are :
- `updateApiJson` Download file for generating client
- `generateJavaClient` Generates Java client

##### `updateApiJson`
Download file for generating client

##### `generateJavaClient`
Generate Java Client from json schema

#### `iosBuildExample`
Build example ios app

#### `iosBuildFtl`
Build ftl ios app

#### `iosRunFtlLocal`
Run ftl locally ios app

| Option | Description |
|-------------|--------------------------------------------------------------------------|
| --device-id | Device id. Please take it from Xcode -> Window -> Devices and Simulators |

#### `iosUniversalFramework`

#### `ops`
Contains tasks related to building sample apps with tests.
These tasks are :
- `go` Build go app with tests
- `ios` Build ios app with tests
- `android` Build android apks with tests

##### `go`
Build go app with tests

##### `build_earl_grey_example`
Build ios earl grey example app with tests

| Option | Short option | Description |
|------------|--------------|--------------------------|
| --generate | -g | Make build |
| --copy | -c | Copy output files to tmp |

##### `build_flank_example`
Build ios flank example app with tests

| Option | Short option | Description |
|------------|--------------|--------------------------|
| --generate | -g | Make build |
| --copy | -c | Copy output files to tmp |

##### `android`
Build android apks with tests

| Option | Short option | Description |
|------------|--------------|--------------------------|
| --generate | -g | Make build |
| --copy | -c | Copy output files to tmp |

#### `updateBinaries`
Update binaries used by Flank

#### `buildFlank`
Build Flank test runner
1 change: 0 additions & 1 deletion flank-scripts/bash/buildFlankScripts.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Rem REPLACE with #1246
SET DIR=%~dp0

SET FLANK_SCRIPTS=%DIR%\..
Expand Down
4 changes: 4 additions & 0 deletions flank-scripts/bash/flankScripts.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
SET DIR=%~dp0
SET scriptsJar=%DIR%\flankScripts.jar

if not exist "%scriptsJar%" {
%DIR%\buildFlankScripts.bat
}

java -jar "%scriptsJar%" %*
2 changes: 2 additions & 0 deletions flank-scripts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ dependencies {
implementation(Dependencies.JCABI_GITHUB)
implementation(Dependencies.SLF4J_NOP)
implementation(Dependencies.GLASSFISH_JSON)
implementation(Dependencies.ARCHIVE_LIB)
implementation(Dependencies.TUKAANI_XZ)

detektPlugins(Dependencies.DETEKT_FORMATTING)

Expand Down
4 changes: 3 additions & 1 deletion flank-scripts/src/main/kotlin/flank/scripts/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.github.ajalt.clikt.core.subcommands
import flank.scripts.ci.CiCommand
import flank.scripts.dependencies.DependenciesCommand
import flank.scripts.release.ReleaseCommand
import flank.scripts.shell.ShellCommand
import flank.scripts.testartifacts.TestArtifactsCommand

class Main : CliktCommand(name = "flankScripts") {
Expand All @@ -17,6 +18,7 @@ fun main(args: Array<String>) {
ReleaseCommand(),
CiCommand(),
DependenciesCommand,
TestArtifactsCommand()
TestArtifactsCommand(),
ShellCommand
).main(args)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ class BugsnagException(val body: BugSnagResponse) : FlankScriptsExceptions() {
return "Error while doing Bugnsag request, because of ${body.errors.joinToString()}"
}
}

class ShellCommandException(private val errorMessage: String) : FlankScriptsExceptions() {
override fun toString(): String {
return "Error while executing shell command, details: $errorMessage"
}
}
35 changes: 35 additions & 0 deletions flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package flank.scripts.shell

import com.github.ajalt.clikt.core.CliktCommand
import flank.scripts.shell.utils.createGradleCommand
import flank.scripts.shell.utils.rootDirectoryPathString
import flank.scripts.utils.runCommand
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption

object BuildFlankCommand : CliktCommand(name = "buildFlank", help = "Build Flank") {
override fun run() {
buildFlank()
}
}

private fun buildFlank() {
createGradleCommand(
workingDir = rootDirectoryPathString,
"-p", rootDirectoryPathString, ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar"
)
.runCommand()

copyFlankOutputFile()
}

private fun copyFlankOutputFile() {
val flankDirectory = Paths.get(rootDirectoryPathString, "test_runner").toString()

Files.copy(
Paths.get(flankDirectory, "build", "libs", "flank.jar"),
Paths.get(flankDirectory, "bash", "flank.jar"),
StandardCopyOption.REPLACE_EXISTING
)
}
33 changes: 33 additions & 0 deletions flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package flank.scripts.shell

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.subcommands
import flank.scripts.shell.firebase.FirebaseCommand
import flank.scripts.shell.ios.BuildExampleCommand
import flank.scripts.shell.ios.BuildFtlCommand
import flank.scripts.shell.ios.InstallXcPrettyCommand
import flank.scripts.shell.ios.RunFtlLocalCommand
import flank.scripts.shell.ios.SetupIosEnvCommand
import flank.scripts.shell.ios.UniversalFrameworkCommand
import flank.scripts.shell.ops.OpsCommand
import flank.scripts.shell.updatebinaries.UpdateBinariesCommand

object ShellCommand : CliktCommand(name = "shell", help = "Task for shell commands") {
init {
subcommands(
FirebaseCommand,
BuildExampleCommand,
BuildFtlCommand,
RunFtlLocalCommand,
UniversalFrameworkCommand,
OpsCommand,
UpdateBinariesCommand,
BuildFlankCommand,
InstallXcPrettyCommand,
SetupIosEnvCommand
)
}

@Suppress("EmptyFunctionBlock")
override fun run() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package flank.scripts.shell.firebase

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.subcommands

object FirebaseCommand : CliktCommand(name = "firebase", help = "Contains all firebase commands") {

init {
subcommands(
UpdateApiJsonCommand,
GenerateJavaClientCommand
)
}

@Suppress("EmptyFunctionBlock")
override fun run() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package flank.scripts.shell.firebase

import com.github.ajalt.clikt.core.CliktCommand
import flank.scripts.exceptions.ShellCommandException
import flank.scripts.utils.checkIfPipInstalled
import flank.scripts.utils.installClientGeneratorIfNeeded
import flank.scripts.utils.runCommand
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption

object GenerateJavaClientCommand : CliktCommand(name = "generateJavaClient", help = "Generate Java Client") {

override fun run() {
checkIfPipInstalled()
installClientGeneratorIfNeeded()
val apiPath = Paths.get("test_api").toString()
val outputDirectory = Paths.get(apiPath, "src", "main", "java").toString()
val testingJsonInput = Paths.get("json", "testing_v1.json").toString()
Paths.get(apiPath, "src").toFile().deleteRecursively()

val generateLibraryCommand = "generate_library " +
"--input=$testingJsonInput " +
"--language=java " +
"--output_dir=$outputDirectory"

val result = generateLibraryCommand.runCommand()
if (result != 0) throw ShellCommandException("Error when execute generate_library command")

Files.move(
Paths.get(outputDirectory, "pom.xml"),
Paths.get(apiPath, "pom.xml"),
StandardCopyOption.REPLACE_EXISTING
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package flank.scripts.shell.firebase

import com.github.ajalt.clikt.core.CliktCommand
import flank.scripts.shell.utils.currentPath
import flank.scripts.utils.downloadFile
import flank.scripts.utils.downloadSortJsonIfNeeded
import flank.scripts.utils.runCommand
import java.nio.file.Paths

object UpdateApiJsonCommand : CliktCommand(name = "updateApiJson", help = "Download file for generating client") {
override fun run() {
val jsonDirectoryPath = Paths.get(currentPath.toString(), "json")
val testingV1Path = Paths.get(jsonDirectoryPath.toString(), "testing_v1.json").toString()
val testingV1Beta3Path = Paths.get(jsonDirectoryPath.toString(), "toolresults_v1beta3.json").toString()

downloadFile(
"https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json",
testingV1Path
)

downloadFile(
"https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json",
testingV1Beta3Path
)

downloadSortJsonIfNeeded()

"sort-json $testingV1Path".runCommand()
"sort-json $testingV1Beta3Path".runCommand()
}
}
Loading