我正在创建我的第一个 GitHub 操作,但我无法弄清楚为什么输出为空。
动作.yml
name: "Run Endtest functional tests"
description: "Register a deployment event with Endtest and run the functional tests"
branding:
icon: play-circle
color: white
inputs:
app_id:
description: 'The Endtest App ID for your account. You can get it from the https://endtest.io/settings page.'
required: true
app_code:
description: 'The Endtest App Code for your account. You can get it from the https://endtest.io/settings page.'
required: true
api_request:
description: 'The Endtest API request for starting the test execution.'
required: true
number_of_loops:
description: 'The number of times the API request for fetching the results will be sent once every 30 seconds.'
required: true
outputs:
test_suite_name:
description: "The name of the test suite"
configuration:
description: "The configuration of the machine or mobile device on which the test was executed"
test_cases:
description: "The number of test cases"
passed:
description: "The number of assertions that have passed"
failed:
description: "The number of assertions that have failed"
errors:
description: "The number of errors that have been encountered"
start_time:
description: "The timestamp for the start of the test execution."
end_time:
description: "The timestamp for the end of the test execution."
#detailed_logs:
#description: "The detailed logs for the test execution"
#screenshots_and_video:
#description: "The URLs for the screenshts and video recordings of the test execution"
runs:
using: "composite"
steps:
- run: sudo apt-get install jq
shell: bash
- run: sudo chmod +x ${{ github.action_path }}/test.sh
shell: bash
- run: echo "${{ inputs.api_request }}"
shell: bash
- run: ${{ github.action_path }}/test.sh ${{ inputs.app_id }} ${{ inputs.app_code }} "${{ inputs.api_request }}" ${{ inputs.number_of_loops }}
shell: bash
测试.sh
#!/bin/bash
set -e
hash=$(curl -X GET --header "Accept: */*" "${3}")
for run in {1.."${4}"}
do
sleep 30
result=$(curl -X GET --header "Accept: */*" "https://endtest.io/api.php?action=getResults&appId=${1}&appCode=${2}&hash=${hash}&format=json")
if [ "$result" == "Test is still running." ]
then
status=$result
# Don't print anything
elif [ "$result" == "Processing video recording." ]
then
status=$result
# Don't print anything
elif [ "$result" == "Stopping." ]
then
status=$result
elif [ "$result" == "Erred." ]
then
status=$result
echo $status
elif [ "$result" == "" ]
then
status=$result
# Don't print anything
else
testsuitename=$( echo "$result" | jq '.test_suite_name' )
configuration=$( echo "$result" | jq '.configuration' )
testcases=$( echo "$result" | jq '.test_cases' )
passed=$( echo "$result" | jq '.passed' )
failed=$( echo "$result" | jq '.failed' )
errors=$( echo "$result" | jq '.errors' )
#detailedlogs=$( echo "$result" | jq '.detailed_logs' )
#screenshotsandvideo=$( echo "$result" | jq '.screenshots_and_video' )
starttime=$( echo "$result" | jq '.start_time' )
endtime=$( echo "$result" | jq '.end_time' )
echo $testsuitename
echo $configuration
echo $testcases
echo $passed
echo $failed
echo $errors
echo $starttime
echo $endtime
echo "::set-output name=test_suite_name::$testsuitename"
echo "::set-output name=configuration::$configuration"
echo "::set-output name=test_cases::$testcases"
echo "::set-output name=passed::$passed"
echo "::set-output name=failed::$failed"
echo "::set-output name=errors::$errors"
echo "::set-output name=start_time::$starttime"
echo "::set-output name=end_time::$endtime"
#echo "::set-output name=detailed_logs::$detailedlogs"
#echo "::set-output name=screenshots_and_video::$screenshotsandvideo"
exit 0
fi
done
exit
我已经在 GitHub Marketplace 上发布了该操作,我正在尝试从另一个存储库中使用它/测试它,如下所示:
主要的.yml
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run a one-line script
run: echo Hello, world!
- name: Run Endtest functional tests
id: endtest_functional_tests
uses: endtest-technologies/github-run-tests-action@v1.3.0.0.3
with:
app_id: "85205402"
app_code: "79973826"
api_request: "https://endtest.io/api.php?action=runTestSuite&appId=85205402&appCode=79973826&testSuite=106877&selectedPlatform=windows&selectedOs=a&selectedBrowser=chrome&selectedResolution=d&selectedLocation=sanfrancisco&selectedCases=491130&writtenAdditionalNotes="
number_of_loops: 6
- name: Get the test suite name output
run: echo "${{ steps.endtest_functional_tests.outputs.test_suite_name }}"
- name: Get the configuration output
run: echo "${{ steps.endtest_functional_tests.outputs.configuration }}"
- name: Get multiple outputs
run: |
echo "${{ steps.endtest_functional_tests.outputs.test_suite_name }}"
echo "${{ steps.endtest_functional_tests.outputs.configuration }}"
查看构建中的日志。我可以看到我的操作被成功调用,API 请求开始,我可以看到输出,直到带有::set-output
.
我的 GitHub 操作生成的输出是空的。
我真的很感谢对此提供一些帮助,因为我在过去 2 天里一直在努力让它工作。
根据我的阅读,应该可以使用::set-output
来自 .sh 文件的文件,就像这个人在本文中所做的那样。