Ensure custom URLs are allowed in use_github_action()#1065
Conversation
|
Actually the original intent was that you specify the full url, including the name if you are using a custom url. So I think the way to fix this is to put the custom name logic inside the |
|
@jennybc sure. @jimhester So, moving the naming logic in gives: if (is.null(url)) {
stopifnot(is_string(name))
if (!grepl("[.]yaml$", name)) {
name <- paste0(name, ".yaml")
}
url <- glue("https://raw.githubusercontent.com/r-lib/actions/master/examples/{name}")
}The function call for a custom action would then be: use_github_action(url = "https://raw.githubusercontent.com/r-lib/actions/master/examples/blah.yaml")Is there a reason for not wanting the URL to point to a generic location? |
|
I am not sure I understand your question, but yes the behavior you describe is the intended usage. |
|
@jimhester Rephrase: Given the current function call of: use_github_action(action)Wouldn't it make more sense to have it: use_github_action(action, url="generic")Instead of: use_github_action(url="specific/to/action.yaml") |
Merge remote-tracking branch 'upstream/master' into fix-gh-actions # Conflicts: # NEWS.md
|
@jimhester when you have a moment. |
Co-Authored-By: Jennifer (Jenny) Bryan <jenny.f.bryan@gmail.com>
…instead of placing in github-actions.
| } | ||
| # Append a `.yaml` extension if needed | ||
| name = gsub("[.]yml$", ".yaml", name) | ||
| if (!grepl("[.]yaml$", name)) { |
There was a problem hiding this comment.
If you keep it, please switch to name <- for assignment, instead of name =.
But it feels like it would be simpler to, instead, use regex of [.]ya?ml$ inside the if() (caveat: untested but I assume you see what I mean).
I don't see how we can just substitute .yaml for .yml if that is not the extension used by the workflow file. We can just allow both .yaml and .yml through, yeah?
There was a problem hiding this comment.
@jennybc with @jimhester's scoping, the file extension is a pretty specific case to what is listed here:
https://github.com/r-lib/actions/tree/master/examples
So, the following URL would work:
https://raw.githubusercontent.com/r-lib/actions/master/examples/pkgdown.yaml
But, this wouldn't:
https://raw.githubusercontent.com/r-lib/actions/master/examples/pkgdown.yml
As a result, I think a two-pass solution is only viable, where the first pass removes replaces .yml with .yaml if present and the second pass verifies the extension is present.
Sorry, about the = assignment.
There was a problem hiding this comment.
I don't think this extra logic is necessary, the examples in r-lib/actions (which is the only place that the 'name' parameter will be used) are always going be .yaml.
|
|
||
| }) | ||
|
|
||
| test_that("use_github_action() replaces yml with yaml in name", { |
There was a problem hiding this comment.
If I'm right above, I think this can be added as a second use_github_action() call in the test above, with .yml instead of .yaml.
There was a problem hiding this comment.
The .yml / .yaml components would only be enforced when there isn't a custom URL. So, I don't think this can be merged in with the above test as it is checking:
use_github_action("pkgdown.yml")whereas the first test is ensuring that a custom URL can be pulled and downloaded.
use_github_action(url="https://my-secret/gh/actions/master/examples/pkgdown.yaml")|
@jimhester can you take a quick look here? If you 👍 before Monday-ish, it will be in the release. |
Co-Authored-By: Jennifer (Jenny) Bryan <jenny.f.bryan@gmail.com>
|
@jennybc should be good to go now once the CI finishes :) |
|
@jennybc this passes cleanly. For whatever reason, the macOS-latest build was cancelled. |
|
Thanks all! |
This PR fixes how URLs are setup in
use_github_action()by moving the appending of the workflownameoutside of theurlcheck.Note: This is required as the
nameparameter must be given but isn't used with a customurl.