diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 383498c..af71c57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -80,6 +80,47 @@ jobs: exit 1 fi + traceurl: + runs-on: "ubuntu-latest" + steps: + - uses: actions/checkout@v4 + - name: "TraceURL with cloud-token" + id: traceurl-token + uses: ./ + with: + version: latest + verb: core + args: version + cloud-token: dag_dagger_sBIv6DsjNerWvTqt2bSFeigBUqWxp9bhh3ONSSgeFnw + - name: "Check traceURL output (should be set)" + run: | + url='${{ steps.traceurl-token.outputs.traceURL }}' + if [[ "$url" =~ ^https://dagger.cloud/.+/traces/.+ ]]; then + echo "traceURL found: $url" + exit 0 + else + echo "traceURL not found" + exit 1 + fi + - name: "TraceURL without cloud-token" + id: traceurl-nil + uses: ./ + with: + version: latest + verb: core + args: version + - name: "Check traceURL output (should NOT be set)" + run: | + url='${{ steps.traceurl-nil.outputs.traceURL }}' + if [[ "$url" =~ ^https://dagger.cloud/traces/setup ]]; then + echo "traceURL correctly not set" + exit 0 + else + echo "traceURL was set: $url" + exit 1 + fi + + version: runs-on: "ubuntu-latest" steps: @@ -156,6 +197,7 @@ jobs: echo "does not match" exit 1 fi + call: runs-on: "ubuntu-latest" steps: @@ -176,6 +218,7 @@ jobs: echo "does not match" exit 1 fi + nocall: runs-on: "ubuntu-latest" steps: @@ -185,3 +228,4 @@ jobs: - name: "Test Install" run: | dagger core version + diff --git a/action.yml b/action.yml index 8edf47b..03191cf 100644 --- a/action.yml +++ b/action.yml @@ -44,6 +44,9 @@ outputs: output: description: "Job output" value: ${{ steps.exec.outputs.stdout }} + traceURL: + description: "Dagger Cloud trace URL" + value: ${{ steps.exec.outputs.traceURL }} runs: using: "composite" steps: @@ -79,13 +82,14 @@ runs: INPUT_MODULE: ${{ inputs.module }} run: | tmpout=$(mktemp) + tmperr=$(mktemp) cd ${{ inputs.workdir }} && { \ DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \ dagger \ ${{ inputs.dagger-flags }} \ ${{ inputs.verb }} \ ${INPUT_MODULE:+-m $INPUT_MODULE} \ - ${{ inputs.args || inputs.call }}; } | tee "${tmpout}" + ${{ inputs.args || inputs.call }}; } 1> >(tee "${tmpout}") 2> >(tee "${tmperr}" >&2) { # we need a delim that doesn't appear in the output - a hash of the @@ -98,6 +102,12 @@ runs: echo "${delim}" } >> "$GITHUB_OUTPUT" + # Extract trace URL from stderr and set as traceURL output + trace_url=$((grep -Eo 'https://dagger.cloud(/[^ ]+/traces/[a-zA-Z0-9]+|/traces/setup)' "${tmperr}" || true) | head -n1) + if [[ -n "$trace_url" ]]; then + echo "traceURL=$trace_url" >> "$GITHUB_OUTPUT" + fi + - if: (inputs.call != '' || inputs.args != '') && inputs.engine-stop == 'true' shell: bash run: |