Skip to content

Commit

Permalink
Alpha fixes (#3)
Browse files Browse the repository at this point in the history
* clear 'test create' args composer output
* make curl fail on error
* add test-infos-file output parameter

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
vitaly4n and github-actions[bot] authored Sep 16, 2024
1 parent ce8bb18 commit ecd6081
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 28 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ A list of directories containing `test-config.yaml` test configuration files sho
|Output|Description|
|------|-----------|
|`test-ids`|IDs of performed tests.|
|`test-infos-file`|File containing a JSON array of objects with information about performed tests.|
|`test-infos`|JSON array of objects with information about performed tests.|
|`execution-report-file`|Path to generated .md execution report file.|
|`checks-report-file`|Path to generated .md checks report file.|
Expand Down Expand Up @@ -257,6 +258,7 @@ A directory containing `test-config.yaml` test configuration file should be prov
|Output|Description|
|------|-----------|
|`test-id`|ID of performed test.|
|`test-info-file`|File containing a JSON object with information about performed test.|
|`test-info`|JSON object with information about performed test.|
|`report-file`|Path to generated .md report file.|
|`artifacts-dir`|Action artifacts directory. If needed, save it using actions/upload_artifacts.|
Expand Down
5 changes: 1 addition & 4 deletions _impl/_compose_test_create_args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,4 @@ if [[ -n ${_artifacts_bucket} ]]; then
_ARGS+=(--artifacts-output-bucket "${_artifacts_bucket}")
fi

(
IFS=$'\t'
echo "${ARGS[*]}"
)
printf '%s\0' "${ARGS[@]}"
14 changes: 7 additions & 7 deletions _impl/_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ function _log_outs() {
local _level=0
fi

if [[ -n "$YC_SECRET_OUTPUT" ]]; then
_stdout='***SECRET***'
fi

_logv "$_level" "Command $1 finished with status $_rc:"
_logv "$_level" " stderr: $_stderr"
_logv "$_level" " stdout: $_stdout"
if [[ -n "$YC_SECRET_OUTPUT" ]]; then
_logv "$_level" " stdout: ***SECRET***"
else
_logv "$_level" " stdout: $_stdout"
fi

printf '%s' "$_stdout" 2>/dev/null
return ${_rc}
Expand Down Expand Up @@ -229,7 +229,7 @@ function yc_s3_upload {

local -r token=${VAR_TOKEN:-$(yc_get_token)}
local -r auth_h="X-YaCloud-SubjectToken: $token"
curl -L -H "$auth_h" --upload-file - "$VAR_OBJECT_STORAGE_URL/$bucket/$bucket_path" \
curl --fail -L -H "$auth_h" --upload-file - "$VAR_OBJECT_STORAGE_URL/$bucket/$bucket_path" \
2>/dev/null \
<"$file"

Expand All @@ -247,7 +247,7 @@ function yc_s3_delete {

local -r token=${VAR_TOKEN:-$(yc_get_token)}
local -r auth_h="X-YaCloud-SubjectToken: $token"
curl -L -H "$auth_h" -X DELETE "$VAR_OBJECT_STORAGE_URL/$bucket/$bucket_path" \
curl --fail -L -H "$auth_h" -X DELETE "$VAR_OBJECT_STORAGE_URL/$bucket/$bucket_path" \
2>/dev/null

return $?
Expand Down
16 changes: 10 additions & 6 deletions _impl/test_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,18 @@ if [[ -n $VAR_ARTIFACTS_BUCKET ]]; then
_composer_args+=(--artifacts-bucket "${VAR_ARTIFACTS_BUCKET}")
fi

if ! _composer_output=$(run_script "$_SCRIPT_DIR/_compose_test_create_args.sh" "${_composer_args[@]}"); then
_log "Failed: output=$_composer_output"
fi
function _call_composer() {
if ! run_script "$_SCRIPT_DIR/_compose_test_create_args.sh" "${_composer_args[@]}"; then
_log "Failed to compose arguments"
fi
}

_logv 1 "Composer arguments:"
_test_create_args=()
IFS=$'\t' read -d '' -ra _test_create_args <<<"$_composer_output" || true

_logv 1 "Composed: ${_test_create_args[*]}"
while IFS= read -d '' -r _arg; do
_logv 1 " arg: $_arg"
_test_create_args+=("$_arg")
done < <(_call_composer)

# ---------------------------------------------------------------------------- #
# Run the test #
Expand Down
17 changes: 12 additions & 5 deletions test-single-run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ outputs:
description: |-
ID of performed test.
test-info-file:
value: ${{ steps.output-info.outputs.res-file }}
description: |-
File containing a JSON object with information about performed test.
test-info:
value: ${{ steps.output-info.outputs.res }}
description: |-
Expand Down Expand Up @@ -168,14 +173,16 @@ runs:
if: always()
shell: bash
run: |
if [[ -z "${{ steps.output-id.outputs.res }}" ]]; then
echo "res='{}'" >> "$GITHUB_OUTPUT"
exit 0
fi
RES_FILE="${{ steps.make-artifacts-dir.outputs.res }}/test-info.json"
echo "{}" > "$RES_FILE"
echo "res-file=$RES_FILE" >> "$GITHUB_OUTPUT"
if [[ -n "${{ steps.output-id.outputs.res }}" ]]; then
yc loadtesting test get "${{ steps.output-id.outputs.res }}" --format json > "$RES_FILE"
fi
{
echo 'res<<EOF'
yc loadtesting test get "${{ steps.output-id.outputs.res }}" --format json
cat "$RES_FILE"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
Expand Down
20 changes: 14 additions & 6 deletions test-suite/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ outputs:
description: |-
IDs of performed tests.
test-infos-file:
value: ${{ steps.output-infos.outputs.res-file }}
description: |-
File containing a JSON array of objects with information about performed tests.
test-infos:
value: ${{ steps.output-infos.outputs.res }}
description: |-
Expand Down Expand Up @@ -183,16 +188,19 @@ runs:
if: always()
shell: bash
run: |
if [[ -z "${{ steps.output-ids.outputs.res }}" ]]; then
echo "res='[]'" >> "$GITHUB_OUTPUT"
exit 0
RES_FILE="${{ steps.make-artifacts-dir.outputs.res }}/test-infos.json"
echo "[]" > "$RES_FILE"
echo "res-file=$RES_FILE" >> "$GITHUB_OUTPUT"
if [[ -n "${{ steps.output-ids.outputs.res }}" ]]; then
echo "${{ steps.output-ids.outputs.res }}" \
| xargs -n1 yc --format json loadtesting test get \
| jq --slurp > "$RES_FILE"
fi
_ARGS=()
read -d '' -ra _ARGS <<< "${{ steps.output-ids.outputs.res }}" || true
{
echo 'res<<EOF'
yc loadtesting test get "${_ARGS[@]}" --format json
cat "$RES_FILE"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
Expand Down

0 comments on commit ecd6081

Please sign in to comment.