-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #196 add function to check post tags * #196 add check post tags workflow * #196 update to workflow * #196 testing changes * #196 updates * #196 updates * #196 test * #196 test * #196 test * #196 test * #196 update * #196 update * #196 updates following review * #196 update * #196 updates * #196 updates * #196 styler * #196 styler * #196 wording * #196 styler again lol * #196 remove superassignment and linebreak in PR guidance * #196 correct submission tags
- Loading branch information
1 parent
20e487a
commit d2d7dc2
Showing
9 changed files
with
61 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Check post tags | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
Check-post-tags: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: "rocker/tidyverse:4.2.1" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run check_post_tags | ||
run: source("R/check_post_tags.R") | ||
shell: Rscript {0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#' This is a vector of all the allowed blog post tags. It is stored in a separate file so that it can be referenced | ||
#' by `create_blogpost.R` and `check_post_tags.R`. | ||
|
||
allowed_tags <- c("Metadata", "SDTM", "ADaM", "TLG", "Shiny", "Community", "Conferences", "Submissions", "Technical") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Get list of blog posts ---- | ||
posts <- list.files("posts", recursive = TRUE, pattern = "*.qmd") | ||
|
||
# Get vector of allowed tags ---- | ||
source("R/allowed_tags.R") | ||
|
||
# Function to extract tags from a post and check them against the allowed list ---- | ||
check_post_tags <- function(post, allowed_post_tags = allowed_tags) { | ||
post_tags <- rmarkdown::yaml_front_matter(file.path("posts", post))$categories | ||
cross_check <- post_tags %in% allowed_post_tags | ||
problematic_tags <- post_tags[!cross_check] | ||
|
||
if (!all(cross_check)) { | ||
cli::format_message("The tag(s) {.val {problematic_tags}} in the post {.val {post}} are not from the allowed list of tags.") | ||
} | ||
} | ||
|
||
# Apply check_post_tags to all blog posts and find problem posts ---- | ||
check_results <- lapply(posts, check_post_tags) | ||
error_messages <- unlist(Filter(Negate(is.null), check_results)) | ||
|
||
# Construct error message if one or more posts have problematic tags ---- | ||
if (length(error_messages) > 0) { | ||
error_messages <- c(error_messages, "Please select from the following tags: {.val {allowed_tags}}, or contact one of the maintainers.") | ||
names(error_messages) <- rep("x", length(error_messages) - 1) | ||
|
||
concatenated_error_messages <- cli::cli_bullets(error_messages) | ||
|
||
cli::cli_abort(concatenated_error_messages) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters