Skip to content

Commit

Permalink
Add scripts for gcloud auth and running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tiembo committed Jul 24, 2018
1 parent 7ce35d1 commit e3d5f59
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ references:
jobs:
build:
<<: *config_android

steps:
- checkout
- restore_cache:
Expand All @@ -45,11 +44,20 @@ jobs:

test_instrumented:
<<: *config_gcloud

steps:
- run:
name: Setup Google Cloud auth
command: ls
# command: scripts/ftl_setup.sh
- run:
name: Run tests on Firebase Test Lab and download results
command: ls
# command: scripts/ftl_run_tests.sh $CIRCLE_BUILD_NUM firebase_test_results
when: always
- store_artifacts:
path: firebase_test_results
- store_test_Results:
path: firebase_test_results

workflows:
version: 2
Expand Down
30 changes: 30 additions & 0 deletions scripts/ftl_run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

BUILD_ID=$1
TEST_DIR=$2

test_apk() {
RESULTS_DIR=$1_$BUILD_ID

gcloud firebase test android run \
--type instrumentation \
--app $2 \
--test $3 \
--device model=Nexus6P,version=27,locale=en_US,orientation=portrait \
--timeout 30m \
--results-bucket cloud-test-android-devrel-ci \
--results-dir=$RESULTS_DIR \
--no-record-video \
--no-performance-metrics

# Make result dir
mkdir -p "$TEST_DIR/$RESULTS_DIR"

# Pull down test results
gsutil -m cp -r -U "gs://TODO-PROJECT-ID/$RESULTS_DIR/*" "$TEST_DIR/$RESULTS_DIR"
}

test_apk \
"app" \
"app/build/outputs/apk/debug/app-debug.apk" \
"app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk"
19 changes: 19 additions & 0 deletions scripts/ftl_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

# Check if service key environment variable is set; exit if not
if [ "$GCLOUD_SERVICE_KEY" = "" ]; then
echo "GCLOUD_SERVICE_KEY env variable is empty. Exiting."
exit 1
fi

# Export to secrets file
echo $GCLOUD_SERVICE_KEY | base64 -di > client_secret.json

# Set project ID
gcloud config set project TODO-PROJECT-ID

# Auth account
gcloud auth activate-service-account TODO-SERVICE-ACCT-ID --key-file client_secret.json

# Delete secret
rm client_secret.json

0 comments on commit e3d5f59

Please sign in to comment.