-
Notifications
You must be signed in to change notification settings - Fork 0
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
Write tests for a dev container setup #18
Write tests for a dev container setup #18
Comments
It's also possible to send commands to a codespace via SSH using the GitHub CLI, which is another possible route to testing, and specifically could test the codespace. |
The other bespoke aspects of the container setup that might be worth testing are:
|
a slight snag with this is that the opensafely CLI is installed in a script which is in the research template not the dockerfile |
We can get the expected R package count like this $ curl -s https://raw.githubusercontent.com/opensafely-core/r-docker/main/renv.lock | jq '.Packages | length'
424 |
here's a better way of comparing opensafely_r_packages=$(curl -s https://raw.githubusercontent.com/opensafely-core/r-docker/main/renv.lock | jq '.Packages | keys')
r_installed=$(Rscript -e 'installed_packages <- as.data.frame(installed.packages()[,c(1,3:4)])' -e 'package_names<-unique(installed_packages[installed_packages$Priority!="base"|is.na(installed_packages$Priority),,drop=FALSE][["Package
"]])' -e 'cat(package_names[! package_names %in% c("docopt","spatial","littler")],sep="\n")')
|
> library('spatial')
Error in library("spatial") : there is no package called ‘spatial’ within |
OK the issues with unexpected packages in R was actually a bug in the Dockerfile, for which there's a PR to fix it |
NoteThe discussion in this comment discusses what would be needed for a Codespaces-based test, where a codespace is launched with the image to be tested, and then all newly created resources cleaned up afterwards. After discussion with Lucy, we decided that this probably wasn't required for now. GitHub are using the dev container setup to create the codespace. It might give us some extra assurance that everything runs in a codespace, but the differences between the two are assumed small enough that the extra work here is not worthwhile at this time. Trying out testing in CodespacesI think the dev container test setup is just about done, so I've been quickly trying out running in Codespaces a bit more. It's possible to run dev containers entirely self-contained within a GitHub Actions runner, making this simpler to test. With dev containers, it's fairly simple to set things up for testing; for example, ensuring the test dev container runs the Docker image that we're intending to test. Codespaces is primarily a feature with real user interaction in mind, making all this more difficult. Here are some of the issues I've thought of, or encountered. Authentication
SSH setupThe only way to run commands in a codespace is via SSH. This itself has a few problems:
Docker image
Billing
Do we still want a Codespaces-based test?Once opensafely-core/research-template-docker#13 is merged, we'll have automated testing of the dev container. The benefit of having a Codespaces-based test is a slightly stronger assurance that the dev container setup works not just generally, but in GitHub's environment where researchers will typically work. Whether that assurance is worth this extra complexity now is what we should decide. I think it's certainly possible to make this, but is this — slightly messier, and potentially less reliable — test worth adding right now to cover that? Or should we have some evidence of a problem that would be caught by it, but not by the existing dev container test first? |
Adding a Slack notification is covered by opensafely-core/research-template-docker#21. |
As far as I'm aware, we can't run CI tests in Codespaces somehow. However, it is possible to use dev containers in CI, so validating that a demonstration project at least runs with our configuration might be possible. (EDIT: Codespaces can be spun up using the GH CLI - see comment below - so it might be possible to use this in CI)
It would be good to be constantly assured that whatever dev container setup we go with continues to work, or we catch any problems as they arise.
This should be added into the new repo (see #46 ).
Tasks
opensafely run run_all -f
Assumptions
That a local dev container setup does work the same as in Codespaces (see #19).
Acceptance criteria
opensafely
cli tool and check it exists successfully. These tests should be run on a daily schedule.The text was updated successfully, but these errors were encountered: