github-actions[bot] commented on code in PR #41592:
URL: https://github.com/apache/beam/pull/41592#discussion_r4670022463
##########
.github/actions/test-arguments-action/action.yml:
##########
@@ -37,60 +37,74 @@ runs:
using: composite
steps:
- name: Check if test-type was provided
+ env:
+ INPUT_TEST_TYPE: ${{ inputs.test-type }}
shell: bash
- run: |
- if [ -z "${{ inputs.test-type }}" ]; then
+ run: |
+ if [ -z "${INPUT_TEST_TYPE}" ]; then
echo "Test type was not provided"
exit 1
fi
- name: Check if test-language was provided
+ env:
+ INPUT_TEST_LANGUAGE: ${{ inputs.test-language }}
shell: bash
- run: |
- if [ -z "${{ inputs.test-language }}" ]; then
+ run: |
+ if [ -z "${INPUT_TEST_LANGUAGE}" ]; then
echo "Test language was not provided"
exit 1
fi
- name: Set common arguments
id: common_arguments
shell: bash
run: |
- echo project="apache-beam-testing" >> $GITHUB_OUTPUT
- echo influx_db_name="beam_test_metrics" >> $GITHUB_OUTPUT
- echo influx_host="http://10.128.0.96:8086" >> $GITHUB_OUTPUT
+ echo project="apache-beam-testing" >> "$GITHUB_OUTPUT"
+ echo influx_db_name="beam_test_metrics" >> "$GITHUB_OUTPUT"
+ echo influx_host="http://10.128.0.96:8086" >> "$GITHUB_OUTPUT"
- name: Get default ${{ inputs.test-language }} test arguments
id: default_arguments
+ env:
+ INPUT_TEST_LANGUAGE: ${{ inputs.test-language }}
+ COMMON_PROJECT: ${{ steps.common_arguments.outputs.project }}
+ COMMON_INFLUX_DB: ${{ steps.common_arguments.outputs.influx_db_name }}
+ COMMON_INFLUX_HOST: ${{ steps.common_arguments.outputs.influx_host }}
shell: bash
run: |
DEFAULT_ARGUMENTS=""
- if ${{ inputs.test-language == 'java' }}; then
- DEFAULT_ARGUMENTS=$(echo "
- --project=${{ steps.common_arguments.outputs.project }}
- --influxDatabase=${{ steps.common_arguments.outputs.influx_db_name
}}
- --influxHost=${{ steps.common_arguments.outputs.influx_host }}
- ")
- elif ${{ inputs.test-language == 'python' || inputs.test-language ==
'go' }}; then
- DEFAULT_ARGUMENTS=$(echo "
- --project=${{ steps.common_arguments.outputs.project }}
- --influx_db_name=${{ steps.common_arguments.outputs.influx_db_name
}}
- --influx_hostname=${{ steps.common_arguments.outputs.influx_host }}
- ")
+ if [[ "${INPUT_TEST_LANGUAGE}" == "java" ]]; then
+ DEFAULT_ARGUMENTS="--project=${COMMON_PROJECT}
--influxDatabase=${COMMON_INFLUX_DB} --influxHost=${COMMON_INFLUX_HOST}"
+ elif [[ "${INPUT_TEST_LANGUAGE}" == "python" ||
"${INPUT_TEST_LANGUAGE}" == "go" ]]; then
+ DEFAULT_ARGUMENTS="--project=${COMMON_PROJECT}
--influx_db_name=${COMMON_INFLUX_DB} --influx_hostname=${COMMON_INFLUX_HOST}"
fi
- echo arguments=$DEFAULT_ARGUMENTS >> $GITHUB_OUTPUT
+ echo "arguments=${DEFAULT_ARGUMENTS}" >> "$GITHUB_OUTPUT"
- name: Group arguments
+ env:
+ INPUT_ARGUMENT_FILE_PATHS: ${{ inputs.argument-file-paths }}
+ DEFAULT_ARGUMENTS: ${{ steps.default_arguments.outputs.arguments }}
+ INPUT_ARGUMENTS: ${{ inputs.arguments }}
+ INPUT_TEST_TYPE: ${{ inputs.test-type }}
+ JOB_ID: ${{ github.job }}
shell: bash
run: |
- PATHS=($(echo "${{ inputs.argument-file-paths }}" | tr '\n' ' '))
+ if [[ ! "${JOB_ID}" =~ ^[A-Za-z0-9_-]+$ ]]; then
+ echo "::error::Invalid job identifier: ${JOB_ID}"
+ exit 1
+ fi
+ read -r -a PATHS <<< "$(printf '%s' "${INPUT_ARGUMENT_FILE_PATHS}" |
tr '\n' ' ')"
for index in "${!PATHS[@]}"; do
- CONFIG=$(grep -v "^#.*" ${PATHS[index]})
- ARGUMENTS=$(echo "${{ steps.default_arguments.outputs.arguments }}
${{ inputs.arguments }} $CONFIG" | tr '\n' ' ')
+ CONFIG=$(grep -v "^#.*" "${PATHS[index]}" || true)
+ ARGUMENTS=$(printf '%s %s %s' "${DEFAULT_ARGUMENTS}"
"${INPUT_ARGUMENTS}" "${CONFIG}" | tr '\n\r' ' ' | tr -s ' ')
Review Comment:
**🟠High**: Moving `${{ inputs.arguments }}` into the `INPUT_ARGUMENTS`
environment variable prevents bash from evaluating command substitutions passed
in `inputs.arguments`.
Multiple existing workflows still pass `$(date '+%m%d%H%M%S' --utc)` in
`with: arguments:` when invoking `./.github/actions/test-arguments-action`, and
then pass the resulting `${{ env.<job>_test_arguments_<n> }}` inside single
quotes to `gradle-command-self-hosted-action`:
- `.github/workflows/beam_PerformanceTests_BigQueryIO_Batch_Java_Avro.yml`
- `.github/workflows/beam_PerformanceTests_BigQueryIO_Batch_Java_Json.yml`
- `.github/workflows/beam_PerformanceTests_BigQueryIO_Streaming_Java.yml`
- `.github/workflows/beam_PerformanceTests_BiqQueryIO_Read_Python.yml`
- `.github/workflows/beam_PerformanceTests_BiqQueryIO_Write_Python_Batch.yml`
- `.github/workflows/beam_PerformanceTests_PubsubIOIT_Python_Streaming.yml`
- `.github/workflows/beam_PerformanceTests_SpannerIO_Read_2GB_Python.yml`
-
`.github/workflows/beam_PerformanceTests_SpannerIO_Write_2GB_Python_Batch.yml`
- `.github/workflows/beam_LoadTests_Go_ParDo_Dataflow_Batch.yml` (and other
Go load test workflows)
With this change:
1. For `test-type: performance`, `read -r -a args <<< "${ARGUMENTS}"` splits
`--testBigQueryTable=bqio_write_10GB_java_avro_$(date '+%m%d%H%M%S' --utc)` on
spaces into three separate quoted elements
(`"--testBigQueryTable=..._$(date","'+%m%d%H%M%S'","--utc)"`).
2. Because the downstream `-DintegrationTestPipelineOptions='[...]'` and
`'-PloadTest.args=...'` arguments are single-quoted, `$(date ...)` is never
evaluated by the shell in the Gradle step either, passing literal `$(date`
strings to Dataflow/BigQuery.
Please update the caller workflows to compute the timestamp in a prior step
via `$GITHUB_ENV` (similar to `NOW_UTC` in
`beam_LoadTests_Python_Combine_Dataflow_Batch.yml`) before merging this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]