Validate task view #90
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
on: | |
push: | |
branches: | |
- main | |
- master | |
paths: | |
- '.github/workflows/validate-ctv.yml' | |
- 'Phylogenetics.md' | |
pull_request: | |
branches: | |
- main | |
- master | |
paths: | |
- '.github/workflows/validate-ctv.yml' | |
- 'Phylogenetics.md' | |
schedule: | |
- cron: '30 5 1 * *' | |
name: Validate task view | |
jobs: | |
validate-ctv: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-r@v2 | |
- name: Install apt packages (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get install libcurl4-openssl-dev | |
shell: bash | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- name: Cache R packages | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} | |
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- | |
- name: Install R packages | |
run: | | |
install.packages("ctv") | |
install.packages("knitr") | |
install.packages("rmarkdown") | |
install.packages("RCurl") | |
shell: Rscript {0} | |
- name: ctv2html | |
run: | | |
ctv::ctv2html(paste0(basename(getwd()), ".md")) | |
shell: Rscript {0} | |
- name: check_ctv_packages | |
run: | | |
result <- ctv::check_ctv_packages(paste0(basename(getwd()), ".md")) | |
exceptArchive <- result[-4] | |
failures <- lengths(exceptArchive) > 0 | |
if (any(failures)) { | |
print(result[failures]) | |
message("\n\n\n\n") # "Stop" command sometimes appears early | |
stop("See errors identified above") | |
} | |
archived <- result[[4]] | |
if (length(archived)) { | |
if ("${{ github.event_name }}" != "pull_request") { | |
stop( | |
"Archived packages in packagelist:\n - ", | |
paste0(archived, collapse = "\n - ") | |
) | |
} else { | |
previousArchive <- ctv::check_ctv_packages( | |
paste0("https://raw.githubusercontent.com/cran-task-views/", | |
basename(getwd()), "/main/", basename(getwd()), ".md" | |
))[["Packages in packagelist but archived on CRAN"]] | |
newArchives <- setdiff(archived, previousArchive) | |
if (length(newArchives)) { | |
stop( | |
"Adding archived packages:\n - ", | |
paste0(newArchives, collapse = "\n - ") | |
) | |
} | |
} | |
} | |
shell: Rscript {0} | |
- name: check other links | |
if: success() || failure() | |
run: | | |
links <- ctv::read.ctv(paste0(basename(getwd()), ".md"))$otherlinks | |
urls <- sub(".*href=\"(.*)\".*", "\\1", links) | |
ok <- RCurl::url.exists(urls) | |
if (any(!ok)) { | |
message(paste0("::warning file=", basename(getwd()), ".md::Inoperational links")) | |
stop("URLs did not return OK status:\n - ", | |
paste0(names(ok)[!ok], collapse = "\n - ") | |
) | |
} | |
shell: Rscript {0} |