You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/README.md
+78-30Lines changed: 78 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,7 @@
1
-
# Workflow Documentation
1
+
# Workbench Workflows Documentation
2
+
3
+
These GitHub Actions workflows manage and maintain the build processes for lessons using the Carpentries Workbench on GitHub.
4
+
2
5
3
6
## Managing Workflow Updates
4
7
@@ -9,7 +12,11 @@ You can do this locally using your own R and Workbench installation, or via the
9
12
10
13
### Updating locally
11
14
12
-
In a terminal/git bash, navigate to the lesson folder where you want to update the workflows.
15
+
In a terminal/git bash, navigate to the lesson folder where you want to update the workflows, e.g.:
16
+
17
+
```bash
18
+
cd~/lessons/shell-novice
19
+
```
13
20
14
21
Then, start an R session and:
15
22
@@ -39,7 +46,22 @@ $ git push origin main
39
46
> - Cancel any "01 Maintain: Build and Deploy Site" workflow currently running
40
47
> - Run the "02 Maintain: Check for Updated Packages" workflow and merge any PR opened to update the renv lockfile
41
48
> - This should automatically run the "03 Maintain: Apply Package Cache" workflow to install packages and build the cache
42
-
> - A successful cache buid should then trigger the "01 Maintain: Build and Deploy Site" workflow
49
+
> - A successful cache build should then trigger the "01 Maintain: Build and Deploy Site" workflow
50
+
51
+
#### Updating to a specific workflow release or branch
52
+
53
+
To test new Workbench workflow features or branches, or to pin to a specific release, the `branch` option can be supplied to `update_github_workflows()`.
@@ -71,63 +93,90 @@ This will raise a PR with any changes to the workflows that are needed.
71
93
If you are happy with the changes made, you can merge the PR into your lesson repository.
72
94
73
95
74
-
## Package Caches for RMarkdown Lessons
96
+
## Dependency Images for RMarkdown Lessons
97
+
98
+
Lessons that use R packages and RMarkdown are built on GitHub using Docker images within these workflows.
99
+
These images are based on the [workbench-docker](https://github.com/carpentries/workbench-docker) image.
100
+
This base image only contains the Workbench packages to build lessons and not any extra R packages your lesson might need.
75
101
76
-
In summary, generating a reusable package cache is achieved by running the "02 Maintain: Check for Updated Packages" workflow, and then the "03 Maintain: Apply Package Cache" workflow.
102
+
Therefore, there are two steps to perform to resolve the required R packages in a lesson, and then generate a Docker image layer comprising those packages.
103
+
104
+
The "02 Maintain: Check for Updated Packages" workflow checks for any used R packages and their versions, and if successful, opens a Pull Request to update your lesson's renv lockfile (`renv.lock`).
105
+
Once the PR is merged, the "03 Maintain: Apply Package Cache" workflow builds the dependency image layer with `docker build` and publishes it in your user or organisation account Packages area.
77
106
78
107
> [!NOTE]
79
108
> Caching is only relevant for lessons that use Rmd files and renv to manage R packages.
80
109
> If you are building basic markdown documents, caching will not apply to you, and the only
81
110
> workflow that needs to be run is "01 Maintain: Build and Deploy Site".
82
111
83
-
### Caching
112
+
### Publishing dependency images
84
113
85
-
The two cache management workflows are separated to ensure that once you have a successful build with a working renv cache, this cache is stored and will be reused by the Workbench Docker container.
86
-
This means that lesson builds will be faster once an renv cache is created and reused by the Docker container.
114
+
The two dependency workflows are separated to ensure that once you have a successful build with a working renv environment, the resulting dependency image is stored and will be reused by the Workbench Docker container.
115
+
This means that lesson builds will be faster and more consistent once a dependency image is created and reused. This is doubly important if you need very specific versions of R packages, i.e. "pinning".
87
116
88
-
Another major bonus of this setup is that you can keep using this cache indefinitely to build your lesson.
89
-
This is important if you need very specific versions of R packages ("pinning").
117
+
This setup means that this dependency image layer is available indefinitely:
118
+
- to build your lesson, improving robustness and reproducibility
119
+
- for others to use as a complete environment in their local builds, teaching environments, or Codespaces
90
120
91
-
If and when you want to perform an update to the cache, you can re-run the "02 Maintain: Check for Updated Packages" and verify that your lesson still builds with the new packages.
92
-
If all looks good, re-run the "03 Maintain: Apply Package Cache" workflow, and this will write a new renv cache file to GitHub.
121
+
If and when you want to perform an update to the dependency image, you can re-run the "02 Maintain: Check for Updated Packages" workflow and verify that your lesson still builds with any new packages or changes.
122
+
The "03 Maintain: Apply Package Cache" workflowwill publish a new repository- or organisation-local GHCR image for the lesson.
93
123
94
-
In any case, the renv cache is invalidated by new versions of the `renv.lock` file.
124
+
As such, the dependency image is invalidated by new versions of the `renv.lock` file.
95
125
This happens:
96
-
- if you update your lockfile locally by using the `sandpaper::update_cache()`function, and then push it to the lesson repository
126
+
- if you update your lockfile locally by using the `sandpaper::update_cache()`and `sandpaper::manage_deps()` functions, and then push it to the lesson repository
97
127
- when you run the "02 Maintain: Check for Updated Packages" and there are new packages to install
98
128
99
-
More information on managing local renv caches for lessons can be found in the [Sandpaper packages vignettes](https://carpentries.github.io/sandpaper/articles/building-with-renv.html).
129
+
More information on managing local renv-based lesson dependencies can be found in the [Sandpaper packages vignettes](https://carpentries.github.io/sandpaper/articles/building-with-renv.html).
100
130
101
-
#### Using different package cache versions
131
+
#### Using different dependency image versions
102
132
103
-
There are times when you may want to go back to a previous renv package cache file:
133
+
There are times when you may want to go back to a previous dependency image:
104
134
- if you run "02 Maintain: Check for Updated Packages" and "03 Maintain: Apply Package Cache" and the cache generation fails for some reason
105
135
- if there is a new R package that produces incorrect or broken lesson output
136
+
- a new R version is released and downstream packages fail to build and install, and need updating by the package maintainer(s)
106
137
107
-
Cache files will have the following name format, where IMAGE is the workbench-docker image version, and HASHSUM is the `renv.lock` lockfile MD5 hash:
138
+
Dependency images will have the following name format, where IMAGE is the workbench-docker image version, and HASHSUM is the `renv.lock` lockfile hash:
Copy the hashsum part of the desired cache file you want to use, e.g. `2e499eb706112971b2cffceb49b55a6efe49f3ed75cd6579b10ff224489daca4`.
146
+
Copy the hashsum part of the desired image tag you want to use, e.g. `2e499eb706112971b2cffceb49b55a6efe49f3ed75cd6579b10ff224489daca4`.
116
147
117
148
Then either:
118
149
1. Add a repository variable called CACHE_VERSION, and paste in the hash
119
-
- Go to ...
120
-
2. Run the "01 Maintain: Build and Deploy Site" manually, supplying the CACHE_VERSION input
121
-
- Go to ...
150
+
2. Run the "01 Maintain: Build and Deploy Site" manually, supplying the `Optional renv cache version override` input
122
151
123
-
If you have no caches listed, make sure to run the "02 Maintain: Check for Updated Packages" and "03 Maintain: Apply Package Cache" to create a new renv cache file.
152
+
If you have no images listed, make sure to run the "02 Maintain: Check for Updated Packages" and "03 Maintain: Apply Package Cache" workflows to publish a new dependency image.
124
153
125
154
> [!NOTE]
126
-
> If you are maintaining an official lesson, caches are saved in an AWS S3 bucket owned by the Carpentries.
127
-
> Once a successful cache has been saved, these will be listed in the outputs of the "01 Maintain: Build and Deploy Site" workflow.
155
+
> If you are maintaining an official lesson, dependency images are saved to the Carpentries lesson program organisation, e.g. `datacarpentry`, GHCR package namespace.
156
+
> Once a successful dependency image has been published, the build workflows will use it automatically when the matching Docker version tag exists, e.g. 'latest' or a specific version.
128
157
>
129
-
> If you are developing a lesson in your own repository, caches are saved on GitHub.
130
-
> You can see available caches by going to the Actions tab, and clicking Caches on the left hand side.
158
+
> If you are developing a lesson in your own repository, the dependency images are stored in your repository's GHCR package namespace.
159
+
> You can see available images by going to your user or organisation's Packages tab, e.g. `https://github.com/<your_github_username>?tab=packages`.
160
+
161
+
#### Pruning dependency image layers
162
+
163
+
Through the lifetime of a lesson, an increasing number of dependency images will be generated.
164
+
As the images are public, GitHub currently charges no storage, or network ingress or egress fees to upload or download them.
165
+
166
+
The "03 Maintain: Apply Package Cache" workflow will automatically check the number of published dependency images and keep each version published plus one underlying untagged digest (if any) for each version.
167
+
This means it is possible to roll back easily to a previous version or digest, but not end up with a huge number of dependency images to manage.
168
+
169
+
In any case, you can manually delete any versions you wish by:
170
+
- going to your user or organisation's Packages tab, e.g. `https://github.com/<your_github_username>?tab=packages`.
171
+
- selecting the dependency image you want to manage, e.g. `<lesson_repo_name>-deps`
172
+
- selecting `Package settings` on the right hand side
173
+
- deleting any images
174
+
175
+
> [!NOTE]
176
+
> Deleting these images manually may break your builds.
177
+
> Only perform this action if you are sure you want to delete the generated dependency images.
178
+
>
179
+
> If you mistakenly delete an image, you can rebuild it by rerunning the "03 Maintain: Apply Package Cache" workflow.
131
180
132
181
133
182
## User Settings
@@ -186,15 +235,14 @@ Repository-level variables for this workflow are:
186
235
- This can be set to a specific version number to force all builds to use a given container version
0 commit comments