Skip to content

Commit 710906f

Browse files
jedevcjpadams
authored andcommitted
feat: add traceURL output
Signed-off-by: Justin Chadwell <[email protected]>
1 parent 71c85a5 commit 710906f

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

.github/workflows/test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,47 @@ jobs:
8080
exit 1
8181
fi
8282
83+
traceurl:
84+
runs-on: "ubuntu-latest"
85+
steps:
86+
- uses: actions/checkout@v4
87+
- name: "TraceURL with cloud-token"
88+
id: traceurl-token
89+
uses: ./
90+
with:
91+
version: latest
92+
verb: core
93+
args: version
94+
cloud-token: dag_dagger_sBIv6DsjNerWvTqt2bSFeigBUqWxp9bhh3ONSSgeFnw
95+
- name: "Check traceURL output (should be set)"
96+
run: |
97+
url='${{ steps.traceurl-token.outputs.traceURL }}'
98+
if [[ "$url" =~ ^https://dagger.cloud/.+/traces/.+ ]]; then
99+
echo "traceURL found: $url"
100+
exit 0
101+
else
102+
echo "traceURL not found"
103+
exit 1
104+
fi
105+
- name: "TraceURL without cloud-token"
106+
id: traceurl-nil
107+
uses: ./
108+
with:
109+
version: latest
110+
verb: core
111+
args: version
112+
- name: "Check traceURL output (should NOT be set)"
113+
run: |
114+
url='${{ steps.traceurl-nil.outputs.traceURL }}'
115+
if [[ "$url" =~ ^https://dagger.cloud/traces/setup ]]; then
116+
echo "traceURL correctly not set"
117+
exit 0
118+
else
119+
echo "traceURL was set: $url"
120+
exit 1
121+
fi
122+
123+
83124
version:
84125
runs-on: "ubuntu-latest"
85126
steps:
@@ -156,6 +197,7 @@ jobs:
156197
echo "does not match"
157198
exit 1
158199
fi
200+
159201
call:
160202
runs-on: "ubuntu-latest"
161203
steps:
@@ -176,6 +218,7 @@ jobs:
176218
echo "does not match"
177219
exit 1
178220
fi
221+
179222
nocall:
180223
runs-on: "ubuntu-latest"
181224
steps:
@@ -185,3 +228,4 @@ jobs:
185228
- name: "Test Install"
186229
run: |
187230
dagger core version
231+

action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ outputs:
4444
output:
4545
description: "Job output"
4646
value: ${{ steps.exec.outputs.stdout }}
47+
traceURL:
48+
description: "Dagger Cloud trace URL"
49+
value: ${{ steps.exec.outputs.traceURL }}
4750
runs:
4851
using: "composite"
4952
steps:
@@ -79,13 +82,14 @@ runs:
7982
INPUT_MODULE: ${{ inputs.module }}
8083
run: |
8184
tmpout=$(mktemp)
85+
tmperr=$(mktemp)
8286
cd ${{ inputs.workdir }} && { \
8387
DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \
8488
dagger \
8589
${{ inputs.dagger-flags }} \
8690
${{ inputs.verb }} \
8791
${INPUT_MODULE:+-m $INPUT_MODULE} \
88-
${{ inputs.args || inputs.call }}; } | tee "${tmpout}"
92+
${{ inputs.args || inputs.call }}; } 1> >(tee "${tmpout}") 2> >(tee "${tmperr}" >&2)
8993
9094
{
9195
# we need a delim that doesn't appear in the output - a hash of the
@@ -98,6 +102,12 @@ runs:
98102
echo "${delim}"
99103
} >> "$GITHUB_OUTPUT"
100104
105+
# Extract trace URL from stderr and set as traceURL output
106+
trace_url=$((grep -Eo 'https://dagger.cloud(/[^ ]+/traces/[a-zA-Z0-9]+|/traces/setup)' "${tmperr}" || true) | head -n1)
107+
if [[ -n "$trace_url" ]]; then
108+
echo "traceURL=$trace_url" >> "$GITHUB_OUTPUT"
109+
fi
110+
101111
- if: (inputs.call != '' || inputs.args != '') && inputs.engine-stop == 'true'
102112
shell: bash
103113
run: |

0 commit comments

Comments
 (0)