Skip to content

Commit

Permalink
ci: add new bash scripts for test artifacts generation
Browse files Browse the repository at this point in the history
ci: make flankScripts auto generate jar if needed
  • Loading branch information
jan-goral authored and mergify-bot committed Sep 4, 2020
1 parent 6c3038f commit bd8fb53
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

project="$(cd "$(pwd)/$(dirname "$BASH_SOURCE")" && pwd)"

export FLANK_ROOT=$project
export FLANK_FIXTURES_TMP="$project/test_runner/src/test/kotlin/ftl/fixtures/tmp"

. "$project/test_projects/ops.sh"

function bash_debug() {
set -euxo pipefail
}
9 changes: 7 additions & 2 deletions flank-scripts/bash/flankScripts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

DIR=`dirname "$BASH_SOURCE"`
dir=$(dirname "$BASH_SOURCE")
scriptsJar="$dir/flankScripts.jar"

/usr/bin/env java -jar "$DIR/flankScripts.jar" "$@"
if [ ! -f "$scriptsJar" ]; then
"$dir/buildFlankScripts.sh"
fi

/usr/bin/env java -jar "$scriptsJar" "$@"
4 changes: 3 additions & 1 deletion test_projects/android/bash/generate-multi-modules-apks.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

echo "DEPRECATED!!!"

set -euxo pipefail

PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../.." >/dev/null 2>&1 && pwd )"
Expand Down Expand Up @@ -30,4 +32,4 @@ MULTI_MODULES_DIR="$PROJECT_DIR/test_runner/src/test/kotlin/ftl/fixtures/tmp/apk
:multi-modules:testModule20:assembleAndroidTest \

mkdir -p "$MULTI_MODULES_DIR"
find multi-modules -type f -name "*.apk" -exec cp {} "$MULTI_MODULES_DIR" \;
find multi-modules -type f -name "*.apk" -exec cp {} "$MULTI_MODULES_DIR" \;
2 changes: 2 additions & 0 deletions test_projects/android/bash/generate_apks.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

echo "DEPRECATED!!!"

set -euxo pipefail

APK_OUTPUT=$1
Expand Down
2 changes: 2 additions & 0 deletions test_projects/android/bash/generate_duplicated_names_apks.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

echo "DEPRECATED!!!"

set -euxo pipefail

DIR=`dirname "$BASH_SOURCE"`
Expand Down
124 changes: 124 additions & 0 deletions test_projects/android/ops.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env bash

function base_app_apk() {
local dir=$(dirname "$BASH_SOURCE")
local outputDir="$FLANK_FIXTURES_TMP/apk"

for arg in "$@"; do
case "$arg" in

'--generate' | '-g')
"$dir/gradlew" -p "$dir" app:assemble
;;

'--copy' | '-c')
local apkIn="$dir/app/build/outputs/apk/singleSuccess/debug/app-single-success-debug.apk"
local apkOut="$outputDir/app-debug.apk"

mkdir -p "$outputDir"
cp "$apkIn" "$apkOut"
;;

esac
done
}

# depends on base_app_apk
function base_test_apks() {
local dir=$(dirname "$BASH_SOURCE")

for arg in "$@"; do
case "$arg" in

'--generate' | '-g')
"$dir/gradlew" -p "$dir" app:assembleAndroidTest
;;

'--copy' | '-c')
local outputDir="$FLANK_FIXTURES_TMP/apk"
local testIn="$dir/app/build/outputs/apk/androidTest/**/debug/*.apk"

mkdir -p "$outputDir"
cp $testIn $outputDir/
;;

esac
done
}

# depends on base_app_apk
function duplicated_names_apks() {
local dir=$(dirname "$BASH_SOURCE")

for arg in "$@"; do
case "$arg" in

'--generate' | '-g')
"$dir/gradlew" -p "$dir" \
dir0:testModule:assembleAndroidTest \
dir1:testModule:assembleAndroidTest \
dir2:testModule:assembleAndroidTest \
dir3:testModule:assembleAndroidTest
;;

'--copy' | '-c')
local outputDir="$FLANK_FIXTURES_TMP/apk"
local testIn="$dir/app/build/outputs/apk/androidTest/**/debug/*.apk"

mkdir -p "$outputDir"
local dir=$(dirname "$BASH_SOURCE")
local outputDir="$FLANK_FIXTURES_TMP/apk/duplicated_names/"

for index in 0 1 2 3; do
moduleName="dir$index"
apkDir="$outputDir/$moduleName/"
mkdir -p "$apkDir"
cp "$dir/$moduleName"/testModule/build/outputs/apk/**/debug/*.apk "$apkDir"
done
;;
esac
done
}

function multi_module_apks() {
local dir=$(dirname "$BASH_SOURCE")
local outputDir="$FLANK_FIXTURES_TMP/apk/multi-modules/"

for arg in "$@"; do
case "$arg" in

'--generate' | '-g')
"$dir/gradlew" -p "$dir" \
:multi-modules:multiapp:assemble \
:multi-modules:testModule1:assembleAndroidTest \
:multi-modules:testModule2:assembleAndroidTest \
:multi-modules:testModule3:assembleAndroidTest \
:multi-modules:testModule4:assembleAndroidTest \
:multi-modules:testModule5:assembleAndroidTest \
:multi-modules:testModule6:assembleAndroidTest \
:multi-modules:testModule7:assembleAndroidTest \
:multi-modules:testModule8:assembleAndroidTest \
:multi-modules:testModule9:assembleAndroidTest \
:multi-modules:testModule10:assembleAndroidTest \
:multi-modules:testModule11:assembleAndroidTest \
:multi-modules:testModule12:assembleAndroidTest \
:multi-modules:testModule13:assembleAndroidTest \
:multi-modules:testModule14:assembleAndroidTest \
:multi-modules:testModule15:assembleAndroidTest \
:multi-modules:testModule16:assembleAndroidTest \
:multi-modules:testModule17:assembleAndroidTest \
:multi-modules:testModule18:assembleAndroidTest \
:multi-modules:testModule19:assembleAndroidTest \
:multi-modules:testModule20:assembleAndroidTest
;;

'--copy' | '-c')
mkdir -p "$outputDir"
find "$dir/multi-modules" -type f -name "*.apk" -exec cp {} "$outputDir" \;
;;

esac
done
}

echo "Android test projects ops loaded"
1 change: 1 addition & 0 deletions test_projects/ios/EarlGreyExample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Pods/
Podfile.lock
xcuserdata/
*.xcworkspace/
dd_tmp
49 changes: 49 additions & 0 deletions test_projects/ios/EarlGreyExample/ops.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

function setup_ios_env() {
local dir=$(dirname "$BASH_SOURCE")
gem install cocoapods
cd "$dir"
pod install
}

function earl_grey_example() {
local dir=$(dirname "$BASH_SOURCE")
for arg in "$@"; do
case "$arg" in

'--generate' | '-g')
"$dir/build_example.sh"
;;

'--copy' | '-c')
echo "TODO"
;;

esac
done
}

function earl_grey_ftl() {
local dir=$(dirname "$BASH_SOURCE")
for arg in "$@"; do
case "$arg" in

'--generate' | '-g')
"$dir/build_ftl.sh"
;;

'--copy' | '-c')
echo "--copy TODO"
;;

esac
done
}

function universal_framework() {
local dir=$(dirname "$BASH_SOURCE")
"$dir/universal_framework.sh"
}

echo "iOS test projects ops loaded"
32 changes: 32 additions & 0 deletions test_projects/ops.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

dir="$(dirname "$BASH_SOURCE")"

. "$dir/android/ops.sh"
. "$dir/ios/EarlGreyExample/ops.sh"

function update_test_artifacts() {

for arg in "$@"; do
case "$arg" in

android)
base_app_apk --generate --copy
base_test_apks --generate --copy
;;

ios)
setup_ios_env
earl_grey_example --generate --copy
;;

go)
echo "TODO"
;;

all)
update_test_artifacts android ios go
;;
esac
done
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
gcloud:
app: ./src/test/kotlin/ftl/fixtures/tmp/apk/duplicated_names/app-debug.apk
app: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk
test: ./src/test/kotlin/ftl/fixtures/tmp/apk/duplicated_names/dir0/testModule-debug-androidTest.apk
use-orchestrator: false
flank:
Expand Down

0 comments on commit bd8fb53

Please sign in to comment.