Skip to content

Commit

Permalink
feat: test without GITHUB_PAT
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilzyla committed Jun 14, 2024
0 parents commit b4af636
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/debug-flaky-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Debug Flaky E2E
on: [push]
permissions:
contents: read
jobs:
main:
name: ${{ matrix.id == 0 && 'ubuntu' || format('macOS {0}', matrix.id) }}
runs-on: ${{ matrix.id == 0 && 'ubuntu-latest' || 'macos-latest' }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
id: [0, 1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
dependencies: '"hard"'
packages: curl remotes renv withr
- run: Rscript test.R
# env:
# GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
48 changes: 48 additions & 0 deletions test.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
retry <- function(name, f, n = 5, delay = 3) {
for (i in 1:n) {
ok <- tryCatch(
{
f()
TRUE
},
error = function(e) {
message("error: ", conditionMessage(e))
FALSE
}
)
if (ok) break
else Sys.sleep(delay)
}
paste(name, i, ifelse(ok, "OKAY", "FAIL"), sep = "-")
}

PKG <- "r-lib/rlang"
URL <- "https://api.github.com/repos/r-lib/rlang/contents/DESCRIPTION"

results <- character(0)

cat("::group::download\n")
withr::with_tempdir({
results <- c(results, retry("download", function() download.file(URL, "DESCRIPTION")))
})
cat("::endgroup::\n")

cat("::group::curl\n")
withr::with_tempdir({
results <- c(results, retry("curl", function() curl::curl_download(URL, "DESCRIPTION")))
})
cat("::endgroup::\n")

cat("::group::remotes\n")
results <- c(results, retry("remotes", function() remotes::install_github(PKG)))
cat("::endgroup::\n")

# Run renv in the end as it modifies the library paths.
cat("::group::renv\n")
withr::with_tempdir({
renv::init()
results <- c(results, retry("renv", function() renv::install(PKG)))
})
cat("::endgroup::\n")

cat("::notice::", results, "\n")

0 comments on commit b4af636

Please sign in to comment.