Skip to content

Commit

Permalink
Merge branch 'master' into #685-add-flank-multi-test-targets-example
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-goral authored Nov 5, 2020
2 parents 6f3e709 + 7b6b0ca commit 9a217d6
Show file tree
Hide file tree
Showing 91 changed files with 1,811 additions and 486 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ local.properties
results
xcuserdata/
test_projects/ios/*/build*
android_shards.json
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
10 changes: 6 additions & 4 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Versions {
const val KOTLIN = "1.4.10"

// https://github.com/Kotlin/kotlinx.coroutines/releases
const val KOTLIN_COROUTINES = "1.3.9"
const val KOTLIN_COROUTINES = "1.4.0"

// https://github.com/remkop/picocli/releases
const val PICOCLI = "4.5.2"
Expand All @@ -38,7 +38,7 @@ object Versions {
const val GOOGLE_NIO = "0.121.2"

// https://search.maven.org/search?q=a:google-cloud-storage%20g:com.google.cloud
const val GOOGLE_STORAGE = "1.113.1"
const val GOOGLE_STORAGE = "1.113.2"

// https://github.com/google/gson/releases
const val GSON = "2.8.6"
Expand Down Expand Up @@ -79,7 +79,7 @@ object Versions {
const val COMMON_TEXT = "1.9"

// https://github.com/fusesource/jansi/releases
const val JANSI = "1.18"
const val JANSI = "2.0.1"

// https://github.com/ben-manes/gradle-versions-plugin/releases
const val BEN_MANES = "0.33.0"
Expand All @@ -88,7 +88,9 @@ object Versions {
const val PROGUARD = "7.0.0"

// ============== flank-scripts ==============
const val KOTLIN_SERIALIZATION = "1.0.0"
const val KOTLIN_SERIALIZATION = "1.0.1"
const val ARCHIVE_LIB = "1.1.0"
const val TUKAANI_XZ = "1.0"
const val FUEL = "2.3.0"
const val CLIKT = "2.8.0"
const val JCABI_GITHUB = "1.1.2"
Expand Down
32 changes: 32 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ gcloud:
# version: 12.0
# locale: es_ES
# orientation: landscape

## A list of paths that will be copied from the device's storage to the designated results bucket after the test
## is complete. These must be absolute paths under /private/var/mobile/Media or /Documents
## of the app under test. If the path is under an app's /Documents, it must be prefixed with the app's bundle id and a colon
# directories-to-pull:
# - /private/var/mobile/Media

## A list of device-path=file-path pairs that specify the paths of the test device and the files you want pushed to the device prior to testing.
## Device paths should either be under the Media shared folder (e.g. prefixed with /private/var/mobile/Media) or
Expand All @@ -160,8 +166,27 @@ gcloud:
# - gs://bucket/additional.ipa
# - path/to/local/ipa/file.ipa

## A list of game-loop scenario numbers which will be run as part of the test (default: all scenarios).
## A maximum of 1024 scenarios may be specified in one test matrix, but the maximum number may also be limited by the overall test --timeout setting.
# scenario-numbers:
# - 1
# - 2
# - 3

## The type of iOS test to run. TYPE must be one of: xctest, game-loop. Default: xctest
# type: xctest

## The path to the application archive (.ipa file) for game-loop testing.
## The path may be in the local filesystem or in Google Cloud Storage using gs:// notation.
## This flag is only valid when --type=game-loop is also set
# app:
# - gs://bucket/additional.ipa OR path/to/local/ipa/file.ipa


## Enables testing special app entitlements. Re-signs an app having special entitlements with a new application-identifier.
## This currently supports testing Push Notifications (aps-environment) entitlement for up to one app in a project.
## Note: Because this changes the app's identifier, make sure none of the resources in your zip file contain direct references to the test app's bundle id.
# test-special-entitlements: false

flank:
# -- FlankYml --
Expand Down Expand Up @@ -361,6 +386,13 @@ gcloud:
# - local/file/path/test1.obb
# - local/file/path/test2.obb

## A list of game-loop scenario numbers which will be run as part of the test (default: all scenarios).
## A maximum of 1024 scenarios may be specified in one test matrix, but the maximum number may also be limited by the overall test --timeout setting.
# scenario-numbers:
# - 1
# - 2
# - 3

## A list of OBB required filenames. OBB file name must conform to the format as specified by Android e.g.
## [main|patch].0300110.com.example.android.obb which will be installed into <shared-storage>/Android/obb/<package-name>/ on the device.
# obb-names:
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() {
}
}
Loading

0 comments on commit 9a217d6

Please sign in to comment.