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

New feature: System diagnostics functions #98

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

rmbielby
Copy link
Contributor

@rmbielby rmbielby commented Nov 11, 2024

Brief overview of changes

I've added a master diagnostics_test() function to sit as a master diagnostics function to run any diagnostic scripts we add. So far it encompasses the following two functions that I've also added as part of this PR:

  • check_proxy_settings() - this looks for (and removes if clean=TRUE) any rogue proxy settings in the Git configuration
  • check_github_pat() - this looks for (and removes if clean=TRUE) the system variable GITHUB_PAT, which prevents analysts from installing packages from GitHub
  • check_renv_download_method() - checks if the renv_download_method has been set in the .Renviron file and flags if either a) it's not set, or b) it's set to something other than "curl". If run with clean=TRUE, then it removes any none-curl setting and adds a line to .Renviron setting the method to curl.

Why are these changes being made?

Analysts sometimes hit issues with settings on their laptop (usually that they've set themselves after following outdated guidance) and find it difficult to diagnose and fix these issues themselves. We need a way for them to do this in an automated way.

Detailed description of changes

All the extra code is self contained in the diagnostic_test.R script:

  • diagnostic_test()
  • check_proxy_settings()
  • check_github_pat()
  • check_renv_download_method()

The functions have some consistent params:

  • clean = TRUE / FALSE - this dictates whether the function should automatically clean up any issues it finds. Default behaviour is just to output messages to the console about the issues.
  • verbose = TRUE / FALSE - adds a little bit of extra info

I've also added an override parameter for each function, that mainly just helps with testing, but could conceivably be used by us to deal with unusual cases, e.g. you can set the config keys to search for and remove in clean_proxy_settings() if there's a key other than http.proxy and https.proxy that's causing problems.

I've added tests for the individual check_* functions. Except for check_github_pat() as I couldn't find a way to identify the contents of Sys.getenv("GITHUB_PAT") when running on GitHub Actions. It seems to return something that looks like a string "***", but doesn't act like one (i.e. I can't do logic on it and str_replace_all("*", "") doesn't reduce it to a blank string). Main thought is that it's acting as some sort of secret / encrypted variable, but couldn't find anything remotely equivalent from searching online. The test that I had worked fine locally, but just won't work equivalently on GitHub Actions.

Additional information for reviewers

Issue ticket number/s and link

#63

@rmbielby rmbielby added the enhancement New feature or request label Nov 11, 2024
@rmbielby rmbielby requested a review from cjrace November 11, 2024 16:34
@rmbielby rmbielby self-assigned this Nov 11, 2024
@rmbielby rmbielby linked an issue Nov 11, 2024 that may be closed by this pull request
@rmbielby rmbielby linked an issue Nov 12, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a dfe-specific diagnostics function Add a post proxy.R clean up function
1 participant