android-emulator-runner icon indicating copy to clipboard operation
android-emulator-runner copied to clipboard

Allow multiline scripts

Open TWiStErRob opened this issue 1 year ago • 0 comments

At the moment there's some (seemingly unnecessary) parsing of script: input, which prevents everyday usages.

Examples:

Standard Gradle or adb invocation, we all know how long the parameter list can get with filters, and instrumentation arguments, no-one wants to maintain that potentially 500 character line on a single line.

script: |
  command \
    long \
    long \
    param \
    list

Really simple if-else:

script: |
  if [[ $ENV_VAR = "xx" ]]; then
    x
  else
    y
  fi

Function definition and complex scripts.

script: |
  some() {
    ...
  }
  if [[ some() ]]; then ...; fi

The workaround is to dump the script into a file and just call the file as single command:

      - name: "Prepare script to run."
        id: script
        env:
          SCRIPT: |
            # complex parts that are multiline
            ${{ inputs.script }}
        run: |
          script_file="${TEMP}/reactivecircus-android-emulator-runner-preapred-script.sh"
          echo "${SCRIPT}" > "${script_file}"
          echo "file=${script_file}" >> "${GITHUB_OUTPUT}"

      - name: "Run Instrumentation Tests on emulator."
        timeout-minutes: ${{ inputs.timeout-minutes }}
        uses: reactivecircus/android-emulator-runner@v2
        with:
          script: bash "${{ steps.script.outputs.file }}"

but this is so unwieldy.

Would you mind explaining why this parsing is in place, and would you be open to remove it and replace it with just executing the input as is?

(I've faced this issue about 6 times in the last few years, and always had to work around it in some way.)

TWiStErRob avatar Apr 27 '24 13:04 TWiStErRob