Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ echo "app_url: $app_url"
echo "disable_animations: $disable_animations"
echo "quiet: $quiet"
echo "use_beta: $use_beta"
echo "check_name: $check_name"

# check_name is passed as its own quoted `-m` pair rather than folded into
# metadata_parsed, which expands unquoted: a check name containing a space would
# split into two argv entries and the stray word would land as a positional (app
# file / workspace).
echo "Running command: npx --yes \"$DCD_VERSION\" cloud --quiet \
--apiKey \"$api_key\" \
${allure_path:+--allure-path \"$allure_path\"} \
Expand Down Expand Up @@ -121,6 +126,7 @@ ${junit_path:+--junit-path \"$junit_path\"} \
${is_maestro_chrome_onboarding:+--maestro-chrome-onboarding} \
${maestro_version:+--maestro-version \"$maestro_version\"} \
${name:+--name \"$name\"} \
${check_name:+-m \"gh_check_name=$check_name\"} \
${orientation:+--orientation \"$orientation\"} \
${report:+--report \"$report\"} \
${retry:+--retry \"$retry\"} \
Expand Down Expand Up @@ -170,6 +176,7 @@ ${junit_path:+--junit-path "$junit_path"} \
${is_maestro_chrome_onboarding:+--maestro-chrome-onboarding} \
${maestro_version:+--maestro-version "$maestro_version"} \
${name:+--name "$name"} \
${check_name:+-m "gh_check_name=$check_name"} \
${orientation:+--orientation "$orientation"} \
${report:+--report "$report"} \
${retry:+--retry "$retry"} \
Expand Down
7 changes: 7 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ inputs:
is_expand: true
is_required: false

- check_name: ""
opts:
title: "GitHub Check Name"
summary: "Names the GitHub check this run posts, e.g. \"iOS\" gives \"DeviceCloud / iOS\". Only applies when the run carries GitHub commit metadata (gh_sha/gh_repo) and your org has the DeviceCloud GitHub App installed. Use it when a commit is tested more than once so each run gets a check that can be required separately in branch protection, and keep the value fixed for a given workflow."
is_expand: true
is_required: false

- device_locale: ""
opts:
title: "Device Locale"
Expand Down
25 changes: 23 additions & 2 deletions test/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ done
case "$sub" in
cloud)
echo "STUB_CLOUD_CALLED_WITH: $*"
# One line per argv entry as well, so a test can tell "-m a=b c" (three
# words, from an unquoted expansion) from "-m" plus "a=b c" (two args).
for a in "$@"; do echo "STUB_CLOUD_ARG: $a"; done
echo "View results: https://console.devicecloud.dev/results?upload=fake-upload-id"
exit "${STUB_CLOUD_EXIT:-0}"
;;
Expand Down Expand Up @@ -70,8 +73,8 @@ STUB
# step.sh reads Bitrise inputs from lowercase env vars; clear any the host
# runner may have exported so each test specifies exactly what it wants.
unset api_key app_file workspace android_device android_api_level ios_device \
name async google_play debug disable_animations use_beta env_list \
metadata download_artifacts STUB_STATUS STUB_CLOUD_EXIT
name check_name async google_play debug disable_animations use_beta \
env_list metadata download_artifacts STUB_STATUS STUB_CLOUD_EXIT
}

teardown() {
Expand Down Expand Up @@ -127,6 +130,24 @@ teardown() {
[[ "$output" == *"--name My Run"* ]]
}

@test "sends check_name as a single gh_check_name metadata pair" {
# A space in the value must survive as one argument: it reaches the backend as
# the GitHub check's name, and a split would leave a stray positional where the
# app file / workspace go.
export api_key="k"
export check_name="iOS smoke"
run bash "${TEST_DIR}/step.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"STUB_CLOUD_ARG: gh_check_name=iOS smoke"* ]]
}

@test "sends no gh_check_name when check_name is unset" {
export api_key="k"
run bash "${TEST_DIR}/step.sh"
[ "$status" -eq 0 ]
[[ "$output" != *"gh_check_name"* ]]
}

@test "passes --async only when async=true" {
export api_key="k"

Expand Down
Loading