45 lines
1.1 KiB
YAML
45 lines
1.1 KiB
YAML
name: compare
|
|
description: "Compare the output of a command to an expected value."
|
|
inputs:
|
|
expected:
|
|
description: "Expected output."
|
|
required: false
|
|
actual:
|
|
description: "Actual output."
|
|
required: true
|
|
exitOnFail:
|
|
description: "Should the program exit on a failure."
|
|
required: true
|
|
default: "true"
|
|
outputs:
|
|
success:
|
|
description: "The result of the comparison."
|
|
value: ${{ steps.compare.outputs.success }}
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: "Compare input and output"
|
|
id: compare
|
|
run: |
|
|
EXPECTED=$(cat <<EOF
|
|
${{ inputs.expected }}
|
|
EOF
|
|
)
|
|
ACTUAL=$(cat <<EOF
|
|
${{ inputs.actual }}
|
|
EOF
|
|
)
|
|
|
|
if [[ "$EXPECTED" == "$ACTUAL" ]]; then
|
|
echo "success=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "success=false" >> "$GITHUB_OUTPUT"
|
|
if [[ "${{ inputs.exitOnFail }}" == "true" ]]; then
|
|
echo EXPECTED: "$EXPECTED"
|
|
echo --------------------------------
|
|
echo ACTUAL: "$ACTUAL"
|
|
exit 1
|
|
fi
|
|
fi
|
|
shell: bash
|