From 36576bd22edd7147e3697d60b56b365a6dd5d8fc Mon Sep 17 00:00:00 2001 From: mrustl Date: Mon, 23 Nov 2020 14:00:46 +0100 Subject: [PATCH 1/3] Move to github actions (#78) and also add workflow files as template --- .github/.gitignore | 1 + .github/workflows/R-CMD-check.yaml | 81 +++++++++++++++++++ .github/workflows/pkgdown.yaml | 49 +++++++++++ .github/workflows/pr-commands.yaml | 51 ++++++++++++ .github/workflows/test-coverage.yaml | 48 +++++++++++ .travis.yml | 44 ---------- README.md | 4 +- appveyor.yml | 51 ------------ .../ci_github-actions/R-CMD-check.yaml | 81 +++++++++++++++++++ inst/templates/ci_github-actions/pkgdown.yaml | 49 +++++++++++ .../ci_github-actions/pr-commands.yaml | 51 ++++++++++++ .../ci_github-actions/test-coverage.yaml | 48 +++++++++++ 12 files changed, 461 insertions(+), 97 deletions(-) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/R-CMD-check.yaml create mode 100644 .github/workflows/pkgdown.yaml create mode 100644 .github/workflows/pr-commands.yaml create mode 100644 .github/workflows/test-coverage.yaml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 inst/templates/ci_github-actions/R-CMD-check.yaml create mode 100644 inst/templates/ci_github-actions/pkgdown.yaml create mode 100644 inst/templates/ci_github-actions/pr-commands.yaml create mode 100644 inst/templates/ci_github-actions/test-coverage.yaml diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..909fbdf --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,81 @@ +on: + push: + branches: + - master + - main + - dev + pull_request: + branches: + - master + - main + - dev + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macOS-latest, r: 'release'} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: windows-latest, r: 'devel'} + - {os: windows-latest, r: 'oldrel'} + - {os: windows-latest, r: 'release'} + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + with: + r-version: ${{ matrix.config.r }} + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2) + shell: Rscript {0} + + - name: Cache R packages + if: runner.os != 'Windows' + uses: actions/cache@v1 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-r-${{ matrix.config.r }}-3-${{ hashFiles('depends.Rds') }} + restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-3- + + - name: Install system dependencies + if: runner.os == 'Linux' + env: + RHUB_PLATFORM: linux-x86_64-ubuntu-gcc + run: | + Rscript -e "remotes::install_github('r-hub/sysreqs')" + sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") + sudo -s eval "$sysreqs" + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("rcmdcheck") + shell: Rscript {0} + + - name: Check + run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@master + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..58a9d79 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,49 @@ +on: + push: + branches: + - main + - master + - dev + +name: pkgdown + +jobs: + pkgdown: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + uses: actions/cache@v2 + 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 dependencies + run: | + remotes::install_deps(dependencies = TRUE) + install.packages("pkgdown", type = "binary") + shell: Rscript {0} + + - name: Install package + run: R CMD INSTALL . + + - name: Deploy package + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 0000000..0d3cb71 --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -0,0 +1,51 @@ +on: + issue_comment: + types: [created] +name: Commands +jobs: + document: + if: startsWith(github.event.comment.body, '/document') + name: document + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/pr-fetch@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@master + - name: Install dependencies + run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)' + - name: Document + run: Rscript -e 'roxygen2::roxygenise()' + - name: commit + run: | + git add man/\* NAMESPACE + git commit -m 'Document' + - uses: r-lib/actions/pr-push@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + style: + if: startsWith(github.event.comment.body, '/style') + name: style + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/pr-fetch@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@master + - name: Install dependencies + run: Rscript -e 'install.packages("styler")' + - name: Style + run: Rscript -e 'styler::style_pkg()' + - name: commit + run: | + git add \*.R + git commit -m 'Style' + - uses: r-lib/actions/pr-push@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..4efc7ab --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,48 @@ +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + +name: test-coverage + +jobs: + test-coverage: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + uses: actions/cache@v1 + 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 dependencies + run: | + install.packages(c("remotes")) + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("covr") + shell: Rscript {0} + + - name: Test coverage + run: covr::codecov() + shell: Rscript {0} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2912263..0000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -################################################################################ -### generated-with: -### type: R-package -### name: kwb.pkgbuild -### version: 0.1.5 -### installed-from: Github (kwb-r/kwb.pkgbuild@d34caef) -### installed-on: '2020-10-09' -### generated-by: -### user: mrustl -### function-call: kwb.pkgbuild::use_travis() -### generated-on: 2020-10-09 08:24:34 -################################################################################ - - -language: r -pandoc_version: 2.7.3 -sudo: required -addons: - apt: - packages: - - libharfbuzz-dev - - libfribidi-dev -cache: packages -r_packages: -- remotes -- covr -matrix: - include: - - r: devel - - r: release - after_success: - - Rscript -e 'covr::codecov()' - before_deploy: - - Rscript -e 'remotes::install_cran("pkgdown")' - deploy: - provider: script - script: Rscript -e 'pkgdown::deploy_site_github(verbose = TRUE)' - skip_cleanup: 'true' - on: - branch: - - main - - master - - dev - - r: oldrel diff --git a/README.md b/README.md index 7f422f7..a5cbe3d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![Appveyor build Status](https://ci.appveyor.com/api/projects/status/github/KWB-R/kwb.pkgbuild?branch=master&svg=true)](https://ci.appveyor.com/project/KWB-R/kwb-pkgbuild/branch/master) -[![Travis build Status](https://travis-ci.com/KWB-R/kwb.pkgbuild.svg?branch=master)](https://travis-ci.com/KWB-R/kwb.pkgbuild) +[![R-CMD-check](https://github.com/KWB-R/kwb.pkgbuild/workflows/R-CMD-check/badge.svg)](https://github.com/KWB-R/kwb.pkgbuild/actions?query=workflow%3AR-CMD-check) +[![pkgdown](https://github.com/KWB-R/kwb.pkgbuild/workflows/pkgdown/badge.svg)](https://github.com/KWB-R/kwb.pkgbuild/actions?query=workflow%3Apkgdown) [![codecov](https://codecov.io/github/KWB-R/kwb.pkgbuild/branch/master/graphs/badge.svg)](https://codecov.io/github/KWB-R/kwb.pkgbuild) [![Project Status](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/kwb.pkgbuild)]() diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 2ff622e..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,51 +0,0 @@ -# DO NOT CHANGE the "init" and "install" sections below - -# Download script file from GitHub -init: - ps: | - $ErrorActionPreference = "Stop" - Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" - Import-Module '..\appveyor-tool.ps1' - -install: - ps: Bootstrap - -cache: - - C:\RLibrary - -# Adapt as necessary starting from here - -environment: - USE_RTOOLS: true -### Add R_REMOTES_STANDALONE(for details see: https://github.com/krlmlr/r-appveyor/issues/135 -### or https://github.com/r-lib/remotes#standalone-mode) - R_REMOTES_STANDALONE: true - -build_script: - - travis-tool.sh install_deps - -test_script: - - travis-tool.sh run_tests - -on_failure: - - 7z a failure.zip *.Rcheck\* - - appveyor PushArtifact failure.zip - -artifacts: - - path: '*.Rcheck\**\*.log' - name: Logs - - - path: '*.Rcheck\**\*.out' - name: Logs - - - path: '*.Rcheck\**\*.fail' - name: Logs - - - path: '*.Rcheck\**\*.Rout' - name: Logs - - - path: '\*_*.tar.gz' - name: Bits - - - path: '\*_*.zip' - name: Bits diff --git a/inst/templates/ci_github-actions/R-CMD-check.yaml b/inst/templates/ci_github-actions/R-CMD-check.yaml new file mode 100644 index 0000000..909fbdf --- /dev/null +++ b/inst/templates/ci_github-actions/R-CMD-check.yaml @@ -0,0 +1,81 @@ +on: + push: + branches: + - master + - main + - dev + pull_request: + branches: + - master + - main + - dev + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macOS-latest, r: 'release'} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: windows-latest, r: 'devel'} + - {os: windows-latest, r: 'oldrel'} + - {os: windows-latest, r: 'release'} + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + with: + r-version: ${{ matrix.config.r }} + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2) + shell: Rscript {0} + + - name: Cache R packages + if: runner.os != 'Windows' + uses: actions/cache@v1 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-r-${{ matrix.config.r }}-3-${{ hashFiles('depends.Rds') }} + restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-3- + + - name: Install system dependencies + if: runner.os == 'Linux' + env: + RHUB_PLATFORM: linux-x86_64-ubuntu-gcc + run: | + Rscript -e "remotes::install_github('r-hub/sysreqs')" + sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") + sudo -s eval "$sysreqs" + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("rcmdcheck") + shell: Rscript {0} + + - name: Check + run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@master + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/inst/templates/ci_github-actions/pkgdown.yaml b/inst/templates/ci_github-actions/pkgdown.yaml new file mode 100644 index 0000000..58a9d79 --- /dev/null +++ b/inst/templates/ci_github-actions/pkgdown.yaml @@ -0,0 +1,49 @@ +on: + push: + branches: + - main + - master + - dev + +name: pkgdown + +jobs: + pkgdown: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + uses: actions/cache@v2 + 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 dependencies + run: | + remotes::install_deps(dependencies = TRUE) + install.packages("pkgdown", type = "binary") + shell: Rscript {0} + + - name: Install package + run: R CMD INSTALL . + + - name: Deploy package + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' diff --git a/inst/templates/ci_github-actions/pr-commands.yaml b/inst/templates/ci_github-actions/pr-commands.yaml new file mode 100644 index 0000000..0d3cb71 --- /dev/null +++ b/inst/templates/ci_github-actions/pr-commands.yaml @@ -0,0 +1,51 @@ +on: + issue_comment: + types: [created] +name: Commands +jobs: + document: + if: startsWith(github.event.comment.body, '/document') + name: document + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/pr-fetch@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@master + - name: Install dependencies + run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)' + - name: Document + run: Rscript -e 'roxygen2::roxygenise()' + - name: commit + run: | + git add man/\* NAMESPACE + git commit -m 'Document' + - uses: r-lib/actions/pr-push@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + style: + if: startsWith(github.event.comment.body, '/style') + name: style + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/pr-fetch@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@master + - name: Install dependencies + run: Rscript -e 'install.packages("styler")' + - name: Style + run: Rscript -e 'styler::style_pkg()' + - name: commit + run: | + git add \*.R + git commit -m 'Style' + - uses: r-lib/actions/pr-push@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/inst/templates/ci_github-actions/test-coverage.yaml b/inst/templates/ci_github-actions/test-coverage.yaml new file mode 100644 index 0000000..4efc7ab --- /dev/null +++ b/inst/templates/ci_github-actions/test-coverage.yaml @@ -0,0 +1,48 @@ +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + +name: test-coverage + +jobs: + test-coverage: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@master + + - uses: r-lib/actions/setup-pandoc@master + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + uses: actions/cache@v1 + 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 dependencies + run: | + install.packages(c("remotes")) + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("covr") + shell: Rscript {0} + + - name: Test coverage + run: covr::codecov() + shell: Rscript {0} From ff44e0894e57904b9914470dfbd00bce75d5abff Mon Sep 17 00:00:00 2001 From: mrustl Date: Mon, 23 Nov 2020 14:42:38 +0100 Subject: [PATCH 2/3] CI: set github actions as default (#78) remove support for Travis and Appveyor --- DESCRIPTION | 2 +- NAMESPACE | 2 ++ NEWS.md | 4 ++++ R/grammars.R | 14 ++++++++++++++ R/use_autopkgdown.R | 6 ++---- R/use_badges.R | 30 ++++++++++++++++++++++++++++++ R/use_github_ci.R | 16 ++++++++++++++++ R/use_index_md.R | 3 +-- R/use_readme_md.R | 3 +-- R/use_travis.R | 4 +--- man/use_badge_ghactions.Rd | 20 ++++++++++++++++++++ man/use_ghactions.Rd | 14 ++++++++++++++ man/use_travis.Rd | 9 +-------- vignettes/tutorial.Rmd | 5 ++--- 14 files changed, 109 insertions(+), 23 deletions(-) create mode 100644 R/use_github_ci.R create mode 100644 man/use_badge_ghactions.Rd create mode 100644 man/use_ghactions.Rd diff --git a/DESCRIPTION b/DESCRIPTION index b7fba3b..bf14772 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -53,4 +53,4 @@ Remotes: ByteCompile: true Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.0 +RoxygenNote: 7.1.1 diff --git a/NAMESPACE b/NAMESPACE index 20fde83..b90eb2a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,10 +16,12 @@ export(use_autopkgdown) export(use_badge_appveyor) export(use_badge_codecov) export(use_badge_cran) +export(use_badge_ghactions) export(use_badge_lifecycle) export(use_badge_travis) export(use_codecov) export(use_description) +export(use_ghactions) export(use_gitlab_ci_blogdown) export(use_gitlab_ci_docs) export(use_gitlab_ci_ghpages) diff --git a/NEWS.md b/NEWS.md index bf0d4a4..cf8a97e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# [kwb.pkgbuild 0.1.6](https://github.com/KWB-R/kwb.pkgbuild/releases/tag/v0.1.6) 2020-11-23 + +* Use GitHub Actions as default CI (#78) and removed support for Travis and Appveyor + # [kwb.pkgbuild 0.1.5](https://github.com/KWB-R/kwb.pkgbuild/releases/tag/v0.1.5) 2020-10-09 * Update default GitHub branch to `main` since 2020-10-01 (see: [Article](https://www.zdnet.com/article/github-to-replace-master-with-main-starting-next-month/)) diff --git a/R/grammars.R b/R/grammars.R index b79c4b0..483a354 100644 --- a/R/grammars.R +++ b/R/grammars.R @@ -21,6 +21,20 @@ grammars <- list( path_2 = "/", params = "" ), + ghactions_rcmdcheck = list( + title = "R-CMD-check", + address = "https://github.com", + path_1 = "/workflows/R-CMD-check/badge.svg", + path_2 = "//actions?query=workflow%3A", + params = "" + ), + ghactions_pkgdown = list( + title = "pkgdown", + address = "https://github.com", + path_1 = "<path_2>/workflows/R-CMD-check/badge.svg", + path_2 = "<user>/<pkgname>/actions?query=workflow%3A<title>", + params = "" + ), codecov = list( title = "codecov", address = "https://codecov.io", diff --git a/R/use_autopkgdown.R b/R/use_autopkgdown.R index 71cb50c..7fb5b39 100644 --- a/R/use_autopkgdown.R +++ b/R/use_autopkgdown.R @@ -24,8 +24,6 @@ use_autopkgdown <- function( # Add "docs" folder to .gitignore ignore_docs_folder(dbg = dbg) - # Add deploy key for Travis - travis::use_travis_deploy(key_name_private = "id_rsa") # Create empty gh-pages branch create_empty_branch_ghpages(repo, @@ -41,8 +39,8 @@ use_autopkgdown <- function( # Create .gitlab-ci.yml for "main" branch with "docs" folder use_gitlab_ci_docs(dest_dir = file.path(dest_dir, repo)) - # Update .travis.yml - use_travis(auto_build_pkgdown = TRUE, dbg) + # Update Github Actions + use_ghactions() # Delete .gitlab-ci.yml (if existing in "main" branch) fs::file_delete(".gitlab-ci.yml") diff --git a/R/use_badges.R b/R/use_badges.R index 915182f..22e741a 100644 --- a/R/use_badges.R +++ b/R/use_badges.R @@ -42,6 +42,36 @@ use_badge_travis <- function(repo = NULL, user = "KWB-R") ) } +# use_badge_ghactions ---------------------------------------------------------- + +#' Badge Github Actions +#' @param repo name of repository (default: NULL) +#' @param user user name or organisation under which repository defined in +#' parameter "repo" is hosted (default: KWB-R") +#' @return generates travis badge link +#' @export +use_badge_ghactions <- function(repo = NULL, user = "KWB-R") +{ + sprintf("%s\n%s", + + kwb.utils::resolve( + "url", + grammars$general, + grammars$ghactions_rcmdcheck, + user = user, + pkgname = get_pkgname(repo) + ), + kwb.utils::resolve( + "url", + grammars$general, + grammars$ghactions_pkgdown, + user = user, + pkgname = get_pkgname(repo) + ) + ) + +} + # use_badge_codecov ------------------------------------------------------------ #' Badge codecov diff --git a/R/use_github_ci.R b/R/use_github_ci.R new file mode 100644 index 0000000..65ecf75 --- /dev/null +++ b/R/use_github_ci.R @@ -0,0 +1,16 @@ +# use_ghactions----------------------------------------------------------------- + +#' Adds default .github/workflows/ +#' @return writes .github/workflows/ and adds it .Rbuildignore +#' @importFrom fs file_copy +#' @export + +use_ghactions <- function() +{ + +fs::file_copy(path = "templates/ci_github-actions/", + new_path = ".github/workflows", + overwrite = TRUE) + +write_to_rbuildignore(ignore_pattern = "^\\.github$") +} diff --git a/R/use_index_md.R b/R/use_index_md.R index 19cbea1..50b3d9e 100644 --- a/R/use_index_md.R +++ b/R/use_index_md.R @@ -19,8 +19,7 @@ use_index_md <- function( pkg <- read_description() index_md <- c( - use_badge_appveyor(pkg$name, user,domain), - use_badge_travis(pkg$name, user), + use_badge_ghactions(pkg$name, user), use_badge_codecov(pkg$name, user, domain ), use_badge_lifecycle(stage), use_badge_cran(pkg$name), diff --git a/R/use_readme_md.R b/R/use_readme_md.R index cd18f5a..55ff9fc 100644 --- a/R/use_readme_md.R +++ b/R/use_readme_md.R @@ -28,8 +28,7 @@ use_readme_md <- function( docu_dev <- sprintf("%s/dev", docu_release) readme_md <- c( - use_badge_appveyor(pkg$name, user,domain), - use_badge_travis(pkg$name, user), + use_badge_ghactions(pkg$name, user), use_badge_codecov(pkg$name, user, domain ), use_badge_lifecycle(stage), use_badge_cran(pkg$name), diff --git a/R/use_travis.R b/R/use_travis.R index c987cbc..eaea9e8 100644 --- a/R/use_travis.R +++ b/R/use_travis.R @@ -30,8 +30,6 @@ write_ci_travis <- function(yml_vector, dest_dir = getwd(), ignore) # use_travis ------------------------------------------------------------------- #' Adds default .travis.yml -#' @param auto_build_pkgdown prepare Travis for pkgdown::build_site() -#' (default: FALSE) #' @param dbg print debug messages (default: TRUE) #' @param yml_vector a yml imported as string vector (default: #' ci_travis_template()) @@ -39,7 +37,7 @@ write_ci_travis <- function(yml_vector, dest_dir = getwd(), ignore) #' @importFrom yaml as.yaml write_yaml #' @export -use_travis <- function(auto_build_pkgdown = FALSE, dbg = TRUE, +use_travis <- function(dbg = TRUE, yml_vector = ci_travis_template()) { travis_yml <- ".travis.yml" diff --git a/man/use_badge_ghactions.Rd b/man/use_badge_ghactions.Rd new file mode 100644 index 0000000..12d1a5e --- /dev/null +++ b/man/use_badge_ghactions.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/use_badges.R +\name{use_badge_ghactions} +\alias{use_badge_ghactions} +\title{Badge Github Actions} +\usage{ +use_badge_ghactions(repo = NULL, user = "KWB-R") +} +\arguments{ +\item{repo}{name of repository (default: NULL)} + +\item{user}{user name or organisation under which repository defined in +parameter "repo" is hosted (default: KWB-R")} +} +\value{ +generates travis badge link +} +\description{ +Badge Github Actions +} diff --git a/man/use_ghactions.Rd b/man/use_ghactions.Rd new file mode 100644 index 0000000..c1930a8 --- /dev/null +++ b/man/use_ghactions.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/use_github_ci.R +\name{use_ghactions} +\alias{use_ghactions} +\title{Adds default .github/workflows/} +\usage{ +use_ghactions() +} +\value{ +writes .github/workflows/ and adds it .Rbuildignore +} +\description{ +Adds default .github/workflows/ +} diff --git a/man/use_travis.Rd b/man/use_travis.Rd index 27066cd..b730861 100644 --- a/man/use_travis.Rd +++ b/man/use_travis.Rd @@ -4,16 +4,9 @@ \alias{use_travis} \title{Adds default .travis.yml} \usage{ -use_travis( - auto_build_pkgdown = FALSE, - dbg = TRUE, - yml_vector = ci_travis_template() -) +use_travis(dbg = TRUE, yml_vector = ci_travis_template()) } \arguments{ -\item{auto_build_pkgdown}{prepare Travis for pkgdown::build_site() -(default: FALSE)} - \item{dbg}{print debug messages (default: TRUE)} \item{yml_vector}{a yml imported as string vector (default: diff --git a/vignettes/tutorial.Rmd b/vignettes/tutorial.Rmd index 588217d..02bddeb 100644 --- a/vignettes/tutorial.Rmd +++ b/vignettes/tutorial.Rmd @@ -393,11 +393,10 @@ wrapper function `kwb.pkgbuild::use_autopkgdown()`, which: - sets "docs" folder to ".gitignore" (as these files are now build on Travis) -- prepares Travis-CI by: +- prepares Github Actions by: - + adding secret key with `travis::use_travis_deploy(key_name_private = "id_rsa")` - + creating ".travis.yml" with `kwb.pkgbuild::use_travis(auto_build_pkgdown = TRUE)` + + creating ".github/workflows/" with `kwb.pkgbuild::use_ghactions()` + creating an empty "gh-pages" branch with `kwb.pkgbuild::create_empty_branch_ghpages()` From 3f6e08d6831d1f151eacbbe332f034f1f6839dd6 Mon Sep 17 00:00:00 2001 From: mrustl <michael.rustler@kompetenz-wasser.de> Date: Mon, 23 Nov 2020 14:49:20 +0100 Subject: [PATCH 3/3] fix ghactions and prepare v0.1.6 release --- .Rbuildignore | 1 + DESCRIPTION | 2 +- R/use_github_ci.R | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index b2d308d..07e4c24 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,3 +13,4 @@ secrets.csv ^R\\.add_author.R$ ^\.travis\.yml$ +^\.github$ diff --git a/DESCRIPTION b/DESCRIPTION index bf14772..d159aa7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: kwb.pkgbuild Title: R package for standardised development at KWB -Version: 0.1.5 +Version: 0.1.6 Authors@R: c(person(given = "Michael", family = "Rustler", diff --git a/R/use_github_ci.R b/R/use_github_ci.R index 65ecf75..8c65ce6 100644 --- a/R/use_github_ci.R +++ b/R/use_github_ci.R @@ -2,13 +2,14 @@ #' Adds default .github/workflows/ #' @return writes .github/workflows/ and adds it .Rbuildignore -#' @importFrom fs file_copy +#' @importFrom fs dir_copy #' @export use_ghactions <- function() { -fs::file_copy(path = "templates/ci_github-actions/", +fs::dir_copy(path = system.file("templates/ci_github-actions/", + package = "kwb.pkgbuild"), new_path = ".github/workflows", overwrite = TRUE)