Skip to content

Update snapshot actions to fail if data doesn't update#39

Merged
lshandross merged 1 commit into
mainfrom
ls/snapshot-actions-fail-for-outdated-data
Jan 15, 2026
Merged

Update snapshot actions to fail if data doesn't update#39
lshandross merged 1 commit into
mainfrom
ls/snapshot-actions-fail-for-outdated-data

Conversation

@lshandross
Copy link
Copy Markdown
Contributor

No description provided.

@lshandross
Copy link
Copy Markdown
Contributor Author

Snapshot checks fail as expected:

  • NHSN fails because it doesn't have permissions to push data from a branch
  • NSSP fails because the latest observation in the official data source is 2026-01-03. We expect this since target data is updated on Friday for that source, with the latest date being the previous Saturday

Copy link
Copy Markdown
Member

@nickreich nickreich left a comment

Choose a reason for hiding this comment

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

overall it looks good. one small question.

nhsn_data[['weekendingdate']] <- substr(nhsn_data[['weekendingdate']], 1, 10);
colnames(nhsn_data) <- c('Geographic aggregation', 'Week Ending Date', 'Total Influenza Admissions', 'Total COVID-19 Admissions');
max_date <- lubridate::ymd(max(nhsn_data[['Week Ending Date']]));
if (max_date < lubridate::floor_date(Sys.Date(), 'week') - 1L) stop(paste0('Target data is out of date \nLatest date ', max_date));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is stop() enough to have the workflow fail with an error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Given that the NSSP workflow failed at that step on this PR, I would say so

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is there a specific workflow run that you could point to for this? I'm wondering if using stop() could make the action fail silently - like, do we know that it would get a ❌ and be considered a "failing check". is there a difference in doing this and error()?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

An AI overview reports to me:

In R, both stop() and error() will cause a GitHub Actions step to fail because they both cause the R script to exit with a non-zero status code, which GitHub Actions interprets as a failure. There is no functional difference between the two in the context of determining the GitHub Actions step outcome.
Key Points
Exit Code: GitHub Actions determines the success or failure of a run step by its exit code. An exit code of 0 means success, while any non-zero exit code means failure.
stop() in R: This function raises an immediate error condition, which, by default, stops the execution of the R script and returns a non-zero exit code to the operating system.
error() in R: Similar to stop(), this function is used to signal a terminating error and will cause the script to exit with a non-zero status.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For reference, I was talking about this run, which failed with a x

Copy link
Copy Markdown
Member

@nickreich nickreich left a comment

Choose a reason for hiding this comment

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

Let's try it out. It likely won't make things worse than they are, right?

Copy link
Copy Markdown
Member

@nickreich nickreich left a comment

Choose a reason for hiding this comment

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

sorry meant for that last review to be an approval

@lshandross lshandross merged commit d049cd2 into main Jan 15, 2026
1 of 3 checks passed
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.

2 participants