-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.qmd
117 lines (93 loc) · 3.32 KB
/
README.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
title: Reclaim The Bytes
format: gfm
---
```{r}
#| include: false
knitr::opts_chunk$set(fig.path = "resources/README_files/")
library(tidyverse)
action <- yaml::read_yaml("action.yml")
```
`r action$description`
The inspiration for this action:
- [easimon/maximize-build-space](https://github.com/easimon/maximize-build-space)
- [ThewApp/free-actions](https://github.com/ThewApp/free-actions)
- [Other GitHub actions](https://github.com/search?q=%22rm+-rf+%2Fusr%2Fshare%2Fdotnet%22&type=code)
- [This discussion](https://github.com/actions/runner-images/discussions/3242)
**Caveat:** Removal of unnecessary software is implemented by `rm -rf` on specific folders, not by using a package manager or anything sophisticated. While this is quick and easy, it might delete dependencies that are required by your job and so break your build (e.g. because your build job uses a .NET based tool and you removed the required runtime). Please verify which software may or may not be removed for your specific use case.
## Usage
```{r}
#| echo: false
entries <- map_chr(names(action$inputs), function(name) {
input <- action$inputs[[name]]
glue::glue(" {name}: {input$default}")
})
str <- glue::glue("```yaml
name: My build action requiring more space
on: push
jobs:
build:
name: Build my artifact
runs-on: ubuntu-latest
steps:
- name: Reclaim the bytes
uses: data-intuitive/reclaim-the-bytes@v2
with:
{paste(entries, collapse = \"\n\")}
- name: Checkout
uses: actions/checkout@v3
- name: Report free space
run: |
echo \"Free space:\"
df -h
```")
knitr::asis_output(str)
```
## Inputs
```{r}
#| echo: false
lines <- map_chr(names(action$inputs), function(name) {
input <- action$inputs[[name]]
glue::glue("* `{name}`: {input$description}")
})
knitr::asis_output(paste0(lines, collapse = "\n"))
```
## Measurements
In deciding which software to remove, you do not only need to take into account whether the software is needed or not, but also how long it takes to remove vs. the amount of disk space removing it frees up. Here is a visualisation of that information.
```{r}
#| echo: false
json_file <- "resources/measurements.json"
if (!file.exists(json_file)) {
# download latest artifact
zip_file <- tempfile(fileext = ".zip")
download.file("https://nightly.link/data-intuitive/reclaim-the-bytes/workflows/measure.yaml/main/output.zip", zip_file)
unzip(zip_file, exdir = "resources")
}
# read json
df <- jsonlite::read_json(json_file, simplifyVector = TRUE)
summdf <- df %>%
group_by(software = to_remove, os) %>%
summarise_at(c("duration_s", "freed_gb"), mean) %>%
ungroup()
```
```{r}
#| echo: false
knitr::kable(summdf, col.names = c("Software", "OS", "Duration (s)", "Space freed (GB)"))
```
```{r measurements-plot}
#| echo: false
#| fig-width: 8
#| fig-height: 4
bind_rows(
summdf %>% mutate(mean = TRUE),
df %>% mutate(mean = FALSE)
) %>%
ggplot() +
geom_point(aes(duration_s, freed_gb, alpha = mean, size = mean)) +
ggrepel::geom_text_repel(aes(duration_s, freed_gb, label = software), summdf) +
theme_bw() +
labs(x = "Duration (s)", y = "GB freed", alpha = "Is mean", size = "Is mean") +
scale_alpha_manual(values = c("TRUE" = 1, "FALSE" = .2)) +
scale_size_manual(values = c("TRUE" = 3, "FALSE" = 1)) +
facet_wrap(~os)
```