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

allow for yaml config to always rebuild #497

Open
zkamvar opened this issue Aug 15, 2023 · 3 comments
Open

allow for yaml config to always rebuild #497

zkamvar opened this issue Aug 15, 2023 · 3 comments
Labels
enhancement New feature or request frequency: low indicator that a use-case has a low-frequency in lessons nice to have A new feature that would be nice to have, but is not currently a priority

Comments

@zkamvar
Copy link
Contributor

zkamvar commented Aug 15, 2023

This is something brought up in carpentries-incubator/managing-computational-projects#103

Problem

Child documents are not accounted for when triggering rebuilds

It seems the latest version is not deployed correctly, I suspect that an absence of change in the Rmd files makes sandpaper using the cached version, and that difference in the md files are not taken into account (that happens in the local build, but I thought the github action would reset the cache ??)

Reason

This is because files in files/ are not taken into account by the internal sandpaper:::build_status() function.

Potential Solution

We could possibly use {pegboard} to query the code blocks with child files and then use those as an indicator that a rebuild should happen in the parent file.

here is a function that should work for querying the child files:

library("pegboard")
get_child_files <- function(lsn) { 
  blocks <- lsn$get("code") 
  any_children <- purrr::map(blocks, function(nodes) xml2::xml_has_attr(nodes, "child")) 
  if (sum(lengths(any_children))) { 
    children <- purrr::map(blocks, function(nodes) xml2::xml_attr(nodes, "child")) 
    children <- gsub("[\"']", "", unlist(children, use.names = FALSE)) 
    parents <- unlist(names(any_children), lengths(any_children)) 
    res <- data.frame(parents = parents, children = children, stringsAsFactors = FALSE) 
  } else { 
    return(NULL) 
  } 
  return(res) 
}

# example
l <- get_lesson("carpentries-incubator/managing-computational-projects", jekyll = FALSE)
#> Loading required namespace: gert
get_child_files(l)
#>                            parents                         children
#> 1      22_contentAndMotivation.Rmd         files/01-introduction.md
#> 2  23_Ensuring-reproducibility.Rmd             files/03-overview.md
#> 3                 24_SettingUp.Rmd           files/02-motivation.md
#> 4                       25_RDM.Rmd      files/04-reproducibility.md
#> 5                    26_Coding.Rmd       files/05-versioncontrol.md
#> 6              27_publications.Rmd                files/07-setup.md
#> 7                28_conclusion.Rmd files/08-collaborativeworking.md
#> 8      22_contentAndMotivation.Rmd                  files/09-rdm.md
#> 9  23_Ensuring-reproducibility.Rmd             files/12-analysis.md
#> 10                24_SettingUp.Rmd       files/14-codemodularity.md
#> 11                      25_RDM.Rmd           files/13-codereview.md
#> 12                   26_Coding.Rmd          files/15-publication.md
#> 13             27_publications.Rmd                 files/16-open.md
#> 14               28_conclusion.Rmd             files/17-citation.md

Created on 2023-08-15 with reprex v2.0.2

@zkamvar zkamvar added enhancement New feature or request nice to have A new feature that would be nice to have, but is not currently a priority frequency: low indicator that a use-case has a low-frequency in lessons labels Aug 15, 2023
@jcolomb
Copy link
Contributor

jcolomb commented Aug 16, 2023

Could we just change the gitub action yaml with:
reset:
description: 'Reset cached markdown files'
required: false
default: true
type: boolean

I always prefer to build from scratch, otherwise you may introduce some breaking changes and not see them for a while
... (happened to me countless time with Hugo and blogdown)

@jcolomb
Copy link
Contributor

jcolomb commented Aug 16, 2023

also can we have the deploy triggered on pull request as default ?

@zkamvar
Copy link
Contributor Author

zkamvar commented Aug 18, 2023

Could we just change the gitub action yaml

I don't think that will actually work because those are the parameters for a manual build.

I think a better option would be to build in an optional config key that will indicate that your lesson should always rebuild markdown:

rebuild: true

also can we have the deploy triggered on pull request as default ?

This is a separate issue from triggering rebuilds and I am not sure I understand the question. Please open a PR with more details about what you are expecting.

@zkamvar zkamvar changed the title child documents do not trigger rebuild Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frequency: low indicator that a use-case has a low-frequency in lessons nice to have A new feature that would be nice to have, but is not currently a priority
2 participants