Skip to content

Commit

Permalink
Merge pull request #1077 from r-lib/add_check_link_rot
Browse files Browse the repository at this point in the history
Add GHA workflow to check for link rot
  • Loading branch information
IndrajeetPatil authored Dec 6, 2022
2 parents d137eb6 + 9d17b4b commit 3a72387
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/check-link-rot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
schedule:
# * is a special character in YAML so you have to quote this string
# Trigger once a month at 00:00 on the 1st day of the month.
- cron: "0 0 1 * *"

name: check-link-rot

jobs:
check-link-rot:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: "devel"
http-user-agent: "release"
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: devel
extra-packages: |
any::rcmdcheck
any::urlchecker
- name: Run URL checker
run: |
options(crayon.enabled = TRUE)
rotten_links <- urlchecker::url_check(progress = FALSE)
print(rotten_links)
if (length(rotten_links$URL) > 0L) {
stop("Some URLs are outdated and need to be updated.", call. = FALSE)
}
shell: Rscript {0}
6 changes: 2 additions & 4 deletions R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ has_crlf_as_first_line_sep <- function(message, initial_text) {
if (length(split) > 1L && split[1L] == "<text>") {
start_char <- as.numeric(split[3L])
offending_line <- initial_text[as.integer(split[2L])]
if (!is.na(offending_line)) {
if (substr(offending_line, start_char, start_char + 1L) == "\r\n") {
return(TRUE)
}
if (!is.na(offending_line) && substr(offending_line, start_char, start_char + 1L) == "\r\n") {
return(TRUE)
}
}
FALSE
Expand Down

0 comments on commit 3a72387

Please sign in to comment.