Skip to content

Commit 638ef04

Browse files
Add scripts/e2e.sh for running the live Step tests
1 parent 171ced7 commit 638ef04

9 files changed

Lines changed: 150 additions & 3 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ _tmp/
44
.bitrise.secrets.yml
55
# `bitrise run check` drops a golangci-lint binary here
66
bin/
7+
# downloaded e2e fixtures
8+
.fixtures/
79

810
# macOS
911
.DS_Store

‎README.md‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,21 @@ account and spends no device minutes. The stubs record the argument vector each
8888
Step builds, which is what lets the tests assert on flag mapping and drive the
8989
CLI's exit code to check how a test failure becomes a build result.
9090

91-
Live checks live in each Step's own `bitrise.yml` `test` workflow and do run real
92-
tests on real devices. They need credentials and sample artifacts; see the
93-
`app.envs` block at the top of each one.
91+
Live checks run real tests on real devices and spend device minutes:
92+
93+
```bash
94+
scripts/e2e.sh espresso # or upload-app, xcuitest, maestro, tunnel
95+
```
96+
97+
It reads credentials from a git-ignored `.bitrise.secrets.yml` at the repo root
98+
and downloads the sample APKs from
99+
[android-espresso-demo-app](https://github.com/testingbot/android-espresso-demo-app):
100+
101+
```yaml
102+
envs:
103+
- TESTINGBOT_KEY: <your key>
104+
- TESTINGBOT_SECRET: <your secret>
105+
```
94106
95107
For the `step.yml` audit and the live workflows you need the Bitrise CLI:
96108

‎scripts/e2e.sh‎

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Run a Step's live `test` workflow against the real TestingBot service.
4+
#
5+
# Unlike tests/run.sh, this spends device minutes and needs credentials. It
6+
# reads them from ONE .bitrise.secrets.yml at the repo root (git-ignored) rather
7+
# than a copy per Step, and downloads the sample artifacts it needs.
8+
#
9+
# scripts/e2e.sh espresso # or: upload-app, xcuitest, maestro, tunnel
10+
# scripts/e2e.sh # list what each Step needs
11+
#
12+
# Credentials go in <repo root>/.bitrise.secrets.yml:
13+
#
14+
# envs:
15+
# - TESTINGBOT_KEY: <your key>
16+
# - TESTINGBOT_SECRET: <your secret>
17+
18+
set -euo pipefail
19+
20+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
21+
export PATH="${HOME}/.bitrise/tools:${PATH}"
22+
23+
SECRETS="${REPO_ROOT}/.bitrise.secrets.yml"
24+
FIXTURES="${REPO_ROOT}/.fixtures"
25+
26+
# The Espresso demo app ships prebuilt APKs, so no Gradle build is needed.
27+
DEMO_RELEASE="https://github.com/testingbot/android-espresso-demo-app/releases/download/1.0.0"
28+
29+
die() {
30+
echo "error: $*" >&2
31+
exit 1
32+
}
33+
34+
usage() {
35+
cat <<EOF
36+
usage: scripts/e2e.sh <step>
37+
38+
upload-app uploads a real app; needs credentials only
39+
espresso runs the demo Espresso suite on a device
40+
xcuitest needs SAMPLE_APP_IPA and SAMPLE_TEST_BUNDLE (build them yourself)
41+
maestro needs SAMPLE_FLOWS (a Maestro flows directory)
42+
tunnel opens a real tunnel; needs Java 11+ locally
43+
44+
Credentials: ${SECRETS}
45+
46+
envs:
47+
- TESTINGBOT_KEY: <your key>
48+
- TESTINGBOT_SECRET: <your secret>
49+
EOF
50+
}
51+
52+
[ "$#" -ge 1 ] || {
53+
usage
54+
exit 1
55+
}
56+
target="$1"
57+
58+
[ -f "$SECRETS" ] || die "no credentials at ${SECRETS}
59+
60+
Create it with:
61+
62+
envs:
63+
- TESTINGBOT_KEY: <your key>
64+
- TESTINGBOT_SECRET: <your secret>
65+
66+
It is git-ignored."
67+
68+
grep -q 'TESTINGBOT_KEY' "$SECRETS" || die "${SECRETS} has no TESTINGBOT_KEY"
69+
70+
# fetch <url> <dest> -- download once, reuse afterwards.
71+
fetch() {
72+
if [ -s "$2" ]; then
73+
echo " cached $(basename "$2")"
74+
return 0
75+
fi
76+
echo " fetch $(basename "$2")"
77+
mkdir -p "$(dirname "$2")"
78+
curl --fail --location --silent --show-error \
79+
--retry 3 --connect-timeout 10 --max-time 300 \
80+
--output "$2" "$1" || die "could not download $1"
81+
}
82+
83+
case "$target" in
84+
upload-app)
85+
step_dir="${REPO_ROOT}/steps/testingbot-upload-app"
86+
echo "==> Fixtures"
87+
# The upload Step's test workflow uses the remote-URL path, so it just needs
88+
# a public URL to a real binary.
89+
extra_envs=(--inventory "$SECRETS")
90+
export SAMPLE_APP_URL="${DEMO_RELEASE}/app-debug.apk"
91+
echo " SAMPLE_APP_URL=${SAMPLE_APP_URL}"
92+
;;
93+
94+
espresso)
95+
step_dir="${REPO_ROOT}/steps/testingbot-espresso"
96+
echo "==> Fixtures"
97+
fetch "${DEMO_RELEASE}/app-debug.apk" "${FIXTURES}/app-debug.apk"
98+
fetch "${DEMO_RELEASE}/app-debug-androidTest.apk" "${FIXTURES}/app-debug-androidTest.apk"
99+
extra_envs=(--inventory "$SECRETS")
100+
export SAMPLE_APP_APK="${FIXTURES}/app-debug.apk"
101+
export SAMPLE_TEST_APK="${FIXTURES}/app-debug-androidTest.apk"
102+
;;
103+
104+
xcuitest | maestro | tunnel)
105+
step_dir="${REPO_ROOT}/steps/testingbot-${target}"
106+
extra_envs=(--inventory "$SECRETS")
107+
;;
108+
109+
*)
110+
usage
111+
die "unknown step: ${target}"
112+
;;
113+
esac
114+
115+
echo
116+
echo "==> bitrise run test (steps/$(basename "$step_dir"))"
117+
echo " This runs on real devices and spends device minutes."
118+
echo
119+
120+
cd "$step_dir"
121+
exec bitrise run test "${extra_envs[@]}"

‎steps/testingbot-espresso/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ _tmp/
44
.bitrise.secrets.yml
55
# `bitrise run check` drops a golangci-lint binary here
66
bin/
7+
# downloaded e2e fixtures
8+
.fixtures/
79

810
# macOS
911
.DS_Store

‎steps/testingbot-maestro/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ _tmp/
44
.bitrise.secrets.yml
55
# `bitrise run check` drops a golangci-lint binary here
66
bin/
7+
# downloaded e2e fixtures
8+
.fixtures/
79

810
# macOS
911
.DS_Store

‎steps/testingbot-tunnel-stop/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ _tmp/
44
.bitrise.secrets.yml
55
# `bitrise run check` drops a golangci-lint binary here
66
bin/
7+
# downloaded e2e fixtures
8+
.fixtures/
79

810
# macOS
911
.DS_Store

‎steps/testingbot-tunnel/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ _tmp/
44
.bitrise.secrets.yml
55
# `bitrise run check` drops a golangci-lint binary here
66
bin/
7+
# downloaded e2e fixtures
8+
.fixtures/
79

810
# macOS
911
.DS_Store

‎steps/testingbot-upload-app/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ _tmp/
44
.bitrise.secrets.yml
55
# `bitrise run check` drops a golangci-lint binary here
66
bin/
7+
# downloaded e2e fixtures
8+
.fixtures/
79

810
# macOS
911
.DS_Store

‎steps/testingbot-xcuitest/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ _tmp/
44
.bitrise.secrets.yml
55
# `bitrise run check` drops a golangci-lint binary here
66
bin/
7+
# downloaded e2e fixtures
8+
.fixtures/
79

810
# macOS
911
.DS_Store

0 commit comments

Comments
 (0)