Skip to content

Commit 63f79b6

Browse files
committed
create PRs automatically when new LaTeX packages need to be added to TinyTeX bundles
1 parent 7767e4c commit 63f79b6

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

.github/workflows/required-latex-pkgs.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
2-
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
31
on:
42
push:
53
branches: [main]
@@ -20,7 +18,6 @@ jobs:
2018

2119
env:
2220
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
23-
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
2421

2522
steps:
2623
- uses: actions/checkout@v4
@@ -42,3 +39,11 @@ jobs:
4239

4340
- name: Find required LateX packages
4441
run: Rscript tools/test-packages.R
42+
43+
- name: Create Pull Request
44+
uses: peter-evans/create-pull-request@v5
45+
with:
46+
add-paths: |
47+
R/platforms.R
48+
tools/pkgs-custom.txt
49+
tools/pkgs-yihui.txt

R/platforms.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# a copy of the returned result from tl_platform() is saved here because
2+
# tl_platforms() is a little slow and requires Internet connection
3+
.tl_platforms = c('aarch64-linux', 'amd64-freebsd', 'amd64-netbsd',
4+
'armhf-linux', 'i386-freebsd', 'i386-linux', 'i386-netbsd', 'i386-solaris',
5+
'universal-darwin', 'windows', 'x86_64-cygwin', 'x86_64-darwinlegacy',
6+
'x86_64-linux', 'x86_64-linuxmusl', 'x86_64-solaris')

R/tlmgr.R

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,6 @@ tl_platforms = function(print = FALSE) {
376376
} else x
377377
}
378378

379-
# a copy of the returned result from tl_platform() is saved here because
380-
# tl_platform() is a little slow and requires Internet connection
381-
.tl_platforms = c(
382-
'aarch64-linux', 'amd64-freebsd', 'amd64-netbsd', 'armhf-linux',
383-
'i386-freebsd', 'i386-linux', 'i386-netbsd', 'i386-solaris', 'universal-darwin',
384-
'windows', 'x86_64-cygwin', 'x86_64-darwinlegacy', 'x86_64-linux',
385-
'x86_64-linuxmusl', 'x86_64-solaris'
386-
)
387-
388379
# remove the platform suffixes from texlive package names, and optionally keep
389380
# the suffixes for certain platforms
390381
tl_names = function(x, platform = tl_platform()) {

tools/test-packages.R

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
xfun::in_dir('..', xfun::install_dir('tinytex'))
55
if (!tinytex:::tlmgr_available()) stop("tlmgr not available")
66

7+
system2('git', c('checkout', '--', '.')) # drop changes if exist
8+
79
owd = setwd('tools')
810

911
x0 = tinytex::tl_pkgs() # packages from the minimal installation
@@ -35,30 +37,24 @@ x1 = sort(unique(c(
3537
'ec', 'inconsolata', 'times', 'tex', 'helvetic', 'dvips', 'metafont', 'mfware', 'xkeyval'
3638
)))
3739
tinytex::tlmgr_install(x1)
38-
x2 = sort(readLines('pkgs-custom.txt'))
39-
if (!identical(x1, x2)) stop(
40-
'pkgs-custom.txt needs to be updated.\n\nPackages required are:\n',
41-
paste(x1, collapse = '\n')
42-
)
40+
writeLines(x1, 'pkgs-custom.txt')
4341

4442
# any new packages need to be added to pkgs-yihui.txt?
4543
tinytex::tlmgr_install(readLines('pkgs-yihui.txt'))
46-
x3 = tinytex::tl_pkgs()
4744
build_more = function() {
4845
render('test-basic.Rmd', 'beamer_presentation', quiet = TRUE)
4946
render('test-kableExtra.Rmd', quiet = TRUE)
5047
}
5148
build_more()
5249
# were there any new packages installed?
53-
x4 = tinytex::tl_pkgs()
54-
if (length(x5 <- setdiff(x4, x3))) stop(
55-
'pkgs-yihui.txt needs to include:\n', paste(x5, collapse = '\n')
56-
)
50+
x2 = tinytex::tl_pkgs()
51+
writeLines(x2, 'pkgs-yihui.txt')
5752

5853
setwd(owd)
5954

60-
if (!identical(p1 <- tinytex:::tl_platforms(), p2 <- tinytex:::.tl_platforms)) stop(
61-
'tl_platforms() returned: ', paste(p1, collapse = ', '),
62-
'\n.tl_platforms returned ', paste(p2, collapse = ', '),
63-
'\nThe latter needs to be updated in the tinytex package.'
64-
)
55+
p = tinytex:::tl_platforms()
56+
writeLines(c(
57+
'# a copy of the returned result from tl_platform() is saved here because',
58+
'# tl_platforms() is a little slow and requires Internet connection',
59+
strwrap(sprintf('.tl_platforms = c(%s)', paste0("'", p, "'", collapse = ', ')), 80, exdent = 2)
60+
), 'R/platforms.R')

0 commit comments

Comments
 (0)