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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workload_run_attempt to analysis upload #1658

Merged
merged 5 commits into from Apr 26, 2023

Conversation

angelapwen
Copy link
Contributor

Previously we began sending the workflow_run_attempt field to our status reports. We also want to send it to the analysis upload API 馃槃

This PR does a bit of refactoring so that workflow_run_id and workflow_run_attempt are populated the same across the status report and analysis payloads.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

Previously we had duplicated the logic to check `GITHUB_RUN_ID`. We now call the `getWorkflowRunID()` method for the status report upload method, and move the logic for the run attempt to `getWorkflowRunAttempt()`
Because we already throw an error if the ID or attempt aren't numbers, we don't have to allow `undefined` values into the payload.
@angelapwen angelapwen marked this pull request as ready for review April 25, 2023 19:02
@angelapwen angelapwen requested a review from a team as a code owner April 25, 2023 19:02
src/workflow.ts Outdated
);
if (Number.isNaN(workflowRunAttempt)) {
throw new Error(
"GITHUB_RUN_ATTEMPT must define a non NaN workflow run attempt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include the original value here so we can see what the error was.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, (minor) maybe make sure that the value is > 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It wasn't clear to me if GITHUB_RUN_ID could possibly be 0, so I only checked for negative values 馃 GITHUB_RUN_ATTEMPT clearly states that the value should begin at 1: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables

@angelapwen angelapwen enabled auto-merge (squash) April 26, 2023 02:08
@angelapwen angelapwen merged commit da583b0 into github:main Apr 26, 2023
325 checks passed
@angelapwen angelapwen deleted the workflow-run-attempt-analysis branch April 26, 2023 04:21
@github-actions github-actions bot mentioned this pull request Apr 26, 2023
6 tasks
angelapwen added a commit that referenced this pull request Apr 26, 2023
* Update changelog and version after v2.3.0

* Update checked-in dependencies

* Throw full error for CLI bundle download (#1657)

* Add `workload_run_attempt` to analysis upload (#1658)

* Refactor status report upload logic

Previously we had duplicated the logic to check `GITHUB_RUN_ID`. We now call the `getWorkflowRunID()` method for the status report upload method, and move the logic for the run attempt to `getWorkflowRunAttempt()`

* Add `workflow_run_attempt` to analysis payload

* Stop allowing `undefined` run IDs and attempts

Because we already throw an error if the ID or attempt aren't numbers, we don't have to allow `undefined` values into the payload.

* Update changelog for v2.3.1

---------

Co-authored-by: github-actions[bot] <github-actions@github.com>
Co-authored-by: Chuan-kai Lin <cklin@github.com>
Co-authored-by: Angela P Wen <angelapwen@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants