Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/snapshot-nhsn-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: install R packages
run: |
Rscript -e "install.packages('remotes');
Rscript -e "install.packages(c('remotes', 'lubridate'));
remotes::install_github('Chicago/RSocrata')"

- name: Get file name
Expand All @@ -47,6 +47,8 @@ jobs:
nhsn_data <- nhsn_data[c('jurisdiction', 'weekendingdate', 'totalconfflunewadm', 'totalconfc19newadm')];
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

write.csv(nhsn_data, file = '$FILE_NAME', row.names = FALSE)"
env:
FILE_NAME: ${{ env.FILE_NAME }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/snapshot-nssp-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
};
nssp_data <- nssp_data[c('week_end', 'geography', 'county', 'fips', 'hsa_nci_id', 'percent_visits_covid', 'percent_visits_influenza', 'percent_visits_rsv')];
nssp_data[['week_end']] <- substr(nssp_data[['week_end']], 1, 10);
max_date <- lubridate::ymd(max(nssp_data[['week_end']]));
if (max_date < lubridate::floor_date(Sys.Date(), 'week') - 1L) stop(paste0('Target data is out of date \nLatest date ', max_date));
write.csv(nssp_data, file = '$FILE_NAME', row.names = FALSE)"
env:
FILE_NAME: ${{ env.FILE_NAME }}
Expand Down
Loading