Skip to content

Commit

Permalink
[CERTTF-344] Return job ID as output from submit composite action (#…
Browse files Browse the repository at this point in the history
…309)

* feat(actions): return job ID as output from the `submit` action
* refactor(actions): Use `id` output from submission step in polling step
* docs(actions): Document the output of the `submit` action in README.md
  • Loading branch information
boukeas authored Jul 17, 2024
1 parent 8f8007b commit dd03ec1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .github/actions/submit/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ inputs:
description: The Testflinger server to use
required: false
default: testflinger.canonical.com
outputs:
id:
description: 'The ID of the submitted job'
value: ${{ steps.submit.outputs.id }}
runs:
using: composite
steps:
Expand Down Expand Up @@ -79,13 +83,14 @@ runs:
run: |
JOB_ID=$(testflinger --server $SERVER submit --quiet "$JOB")
echo "job id: $JOB_ID"
echo "JOB_ID=$JOB_ID" >> $GITHUB_ENV
echo "id=$JOB_ID" >> $GITHUB_OUTPUT
- 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 }}
JOB_ID: ${{ steps.submit.outputs.id }}
run: |
# poll
PYTHONUNBUFFERED=1 testflinger --server $SERVER poll $JOB_ID
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ If you need to submit a job to a testflinger server through a Github action (ins
The corresponding step in the workflow would look like this:
```
- name: Submit job
id: submit-job
uses: canonical/testflinger/.github/actions/submit@v1
with:
poll: true
Expand All @@ -54,10 +55,21 @@ This assumes that there is a previous `create-job` step in the workflow that cre
Alternatively, you can use the `job` argument (instead of `job-path`) to provide the contents of the job inline:
```
- name: Submit job
id: submit-job
uses: canonical/testflinger/.github/actions/submit@v1
with:
poll: true
job: |
... # inline YAML for Testflinger job
```
In the latter case, do remember to use escapes for environment variables in the inline text, e.g. `\$DEVICE_IP`.
In the latter case, do remember to use escapes for environment variables in the inline text, e.g. `\$DEVICE_IP`.

The `id` of the submitted job is returned as an output of the `submit` action, so you can use it (if you need it)
in any of the subsequent steps of the workflow:

```
- name: Display results
run: |
testflinger results ${{ steps.submit-job.outputs.id }}"
```
In this example, `submit-job` is the step where the `submit` action is used.

0 comments on commit dd03ec1

Please sign in to comment.