Skip to content

Commit

Permalink
Refine submit action check (#290)
Browse files Browse the repository at this point in the history
* feat(actions): replace `nc` check with a `curl` server ping
* feat(actions): display verbose `curl` output when Testflinger ping fails
* chore(actions): move diagnostic step to the very beginning
  • Loading branch information
boukeas authored Jun 25, 2024
1 parent 0dabd5f commit 37867d1
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions .github/actions/submit/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,25 @@ inputs:
default: testflinger.canonical.com
runs:
using: composite

steps:
- name: Test connection to Testflinger server
shell: bash {0} # allow curl to fail
env:
SERVER: https://${{ inputs.server }}
run: |
STATUS=$(curl --stderr error.log -Ivw "%{http_code}\n" -o /dev/null $SERVER/jobs)
ERROR=$?
if [ ! $ERROR -eq 0 ]; then
echo "Unable to ping Testflinger server at $SERVER"
cat error.log
exit $ERROR
elif [ ! $STATUS -eq 200 ]; then
echo "Failed server ping at $SERVER, error status: $STATUS"
cat error.log
exit $STATUS
else
echo "Successful server ping at $SERVER, status: $STATUS"
fi
- name: Create job file, if required
id: create-job-file
shell: bash
Expand Down Expand Up @@ -53,26 +70,26 @@ runs:
shell: bash
run: sudo snap install testflinger-cli jq

- name: Test connection to Testflinger server
shell: bash
run: nc -vz ${{ inputs.server }} 443

- name: Submit job to the Testflinger server
id: submit
if: inputs.dry-run != 'true'
shell: bash
env:
SERVER: https://${{ inputs.server }}
run: |
JOB_ID=$(testflinger --server https://${{ inputs.server }} submit --quiet "$JOB")
JOB_ID=$(testflinger --server $SERVER submit --quiet "$JOB")
echo "job id: $JOB_ID"
echo "JOB_ID=$JOB_ID" >> $GITHUB_ENV
- name: Track the status of the job and mirror its exit status
if: inputs.poll == 'true' && inputs.dry-run != 'true'
shell: bash
env:
SERVER: https://${{ inputs.server }}
run: |
# poll
PYTHONUNBUFFERED=1 testflinger --server https://${{ inputs.server }} poll $JOB_ID
PYTHONUNBUFFERED=1 testflinger --server $SERVER poll $JOB_ID
# retrieve results
STATUS=$(testflinger --server https://${{ inputs.server }} results $JOB_ID | jq -er .test_status)
STATUS=$(testflinger --server $SERVER results $JOB_ID | jq -er .test_status)
echo "Test exit status: $STATUS"
exit $STATUS

0 comments on commit 37867d1

Please sign in to comment.