Skip to content

Commit

Permalink
Switch to a shell script in local_ci.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusc83 committed Sep 5, 2023
1 parent 5d2f35e commit 1d28667
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ The whole project is covered by a set of static analysis tools, linters and test

# Runs the unit tests
./local_ci.sh --test

# Update session replay payloads
./local_ci.sh --update-session-replay-payloads
```

## Submitting Issues
Expand Down Expand Up @@ -296,9 +299,9 @@ Because we sometimes need to reuse some setup or assertions in our tests, we ten
Session Replay has a suite of functional tests which can be found in the `instrumentation:integration` module.
Those tests are assessing the recorded payload for a specific scenario against a given payload from `assets/session_replay_payloads` in the `androidTest` source set.
In case you need to update these payloads after a change in the SDK, you can run the following command:

```shell
./gradlew :instrumented:integration:srPayloadUpdate
./local_ci.sh --update-session-replay-payloads
```

#### Implementation
Expand Down
1 change: 0 additions & 1 deletion instrumented/integration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.datadog.gradle.config.kotlinConfig
plugins {
id("com.android.application")
kotlin("android")
id("sessionReplayPayloadUpdate")
}

android {
Expand Down
26 changes: 25 additions & 1 deletion local_ci.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env sh

local_ci_usage="Usage: local_ci.sh [-s|--setup] [-n|--clean] [-a|--analysis] [-c|--compile] [-t|--test]"
local_ci_usage="Usage: local_ci.sh [-s|--setup] [-n|--clean] [-a|--analysis] [-c|--compile] [-t|--test] [--update-session-replay-payloads] [-h|--help]"


SETUP=0
CLEANUP=0
ANALYSIS=0
COMPILE=0
TEST=0
UPDATE_SESSION_REPLAY_PAYLOAD=0

while [[ $# -gt 0 ]]; do
case $1 in
Expand All @@ -30,6 +32,10 @@ while [[ $# -gt 0 ]]; do
TEST=1
shift
;;
--updateSessionReplayPayload)
UPDATE_SESSION_REPLAY_PAYLOAD=1
shift
;;
-h | --help)
echo $local_ci_usage
shift
Expand Down Expand Up @@ -163,4 +169,22 @@ if [[ $TEST == 1 ]]; then
./gradlew uTR
fi


if [[ $UPDATE_SESSION_REPLAY_PAYLOAD == 1 ]]; then
PAYLOAD_INPUT_DIRECTORY_PATH="storage/emulated/0/Android/data/com.datadog.android.sdk.integration/cache/session_replay_payloads/."
PAYLOAD_OUTPUT_DIRECTORY_PATH="instrumented/integration/src/androidTest/assets/session_replay_payloads/"
SESSION_REPLAY_TESTS_PACKAGE="com.datadog.android.sdk.integration.sessionreplay"
SESSION_REPLAY_TESTS_RUNNER="com.datadog.android.sdk.integration.test/androidx.test.runner.AndroidJUnitRunner"

echo "---- Updating session replay payload"
echo "---- Build and install the integration test app on the device"
./gradlew :instrumented:integration:assembleDebug :instrumented:integration:installDebug :instrumented:integration:assembleDebugAndroidTest :instrumented:integration:installDebugAndroidTest

echo "---- Run the Session Replay integration tests and generate new payloads"
adb shell am instrument -w -r -e debug false -e updateSrPayloads true -e package $SESSION_REPLAY_TESTS_PACKAGE $SESSION_REPLAY_TESTS_RUNNER

echo "---- Override the existing payloads with the new ones from the device"
adb pull $PAYLOAD_INPUT_DIRECTORY_PATH $PAYLOAD_OUTPUT_DIRECTORY_PATH
fi

echo "-- Done ✔︎"

0 comments on commit 1d28667

Please sign in to comment.