Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datadog-ci junit upload linked job is not helpful with GitHub #1497

Open
eps1lon opened this issue Nov 25, 2024 · 4 comments
Open

datadog-ci junit upload linked job is not helpful with GitHub #1497

eps1lon opened this issue Nov 25, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@eps1lon
Copy link

eps1lon commented Nov 25, 2024

Bug description

@datadog/[email protected] junit upload associates a job URL with the test that is not helpful in our case.

The linked job URL will link to the generic "Checks" page of the merge commit in CI (e.g. https://github.com/vercel/next.js/commit/3dd3d19ba63c7ca790f3bf39e0e15152b597547c/checks)

Setting DD_CI_JOB_URL to something we find more useful does not work. In vercel/next.js#73180, we still get the default job name and job url e.g. https://github.com/vercel/next.js/commit/12adaf1a0b0cb362fedc65168c3a15828af2d4e8/checks instead of https://github.com/vercel/next.js/actions/runs/12015965067/attempts/1

Describe what you expected

Linking to the actual job e.g. https://github.com/vercel/next.js/actions/runs/12015964713/job/33495310395.

Since GitHub doesn't expose the job id but only workflow id, the link to the workflow is the next best thing e.g. DD_CI_JOB_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}

Steps to reproduce the issue

test.yml

steps: 
- name: Upload test report to datadog
  if: ${{ inputs.afterBuild && always() }}
  env:
    DD_ENV: 'ci'
    DD_CI_JOB_NAME: ${{ inputs.stepName }}
    # Better than Datadog's default (e.g. https://github.com/vercel/next.js/commit/3dd3d19ba63c7ca790f3bf39e0e15152b597547c/checks)
    # Job id is not provided by GitHub. Using workflow url as a fallback.
    # We could derived the job id from GH API response but this is just more network slowness.
    DD_CI_JOB_URL: https://github.com/${{  github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
    run: |
      echo "DD_CI_JOB_NAME: ${{ env.DD_CI_JOB_NAME }}"
      echo "DD_CI_JOB_URL: ${{ env.DD_CI_JOB_URL }}"
      if [ -d ./test/test-junit-report ]; then
        # Add a `test.type` tag to distinguish between turbopack and next.js runs
        npx @datadog/[email protected] junit upload --service nextjs --tags test.type:nextjs ./test/test-junit-report
      fi

Additional context

No response

Command

None

@juan-fernandez
Copy link
Contributor

hey @eps1lon , thanks for the report!

I think what you're looking for is the pipeline URL:

let pipelineURL = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`

This URL already has the shape you're expecting, I think:

https://github.com/${{  github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}

Since GitHub doesn't expose the job id but only workflow id

You're right and that's why we can't offer a deeper link.

Would using pipeline URL instead of job URL work for you? Or did I misunderstand your issue?

@eps1lon
Copy link
Author

eps1lon commented Nov 28, 2024

I'm looking for the Job URL e.g. https://github.com/vercel/next.js/actions/runs/12000501567/job/33449700959. If we'd be able to configure this, we'd have the choice of actually querying the workflow ID from GH Apis. Since it's not configurable, we don't have that choice.

I'll ignore the Job URL until then in favor of the Pipeline URL.

@juan-fernandez
Copy link
Contributor

I see, so you'd like to be able to manually set ci.* tags via DD_CI_* env vars, right?

@eps1lon eps1lon changed the title datadog-ci junit upload linked job is not helpful with GitHu datadog-ci junit upload linked job is not helpful with GitHub Dec 3, 2024
@eps1lon
Copy link
Author

eps1lon commented Dec 11, 2024

I see, so you'd like to be able to manually set ci.* tags via DD_CI_* env vars, right?

Yeah, basically #594. Specifying DD_GITHUB_JOB_NAME does not work either: vercel/next.js#73180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants