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-devel.yaml b/.github/workflows/R-CMD-check-devel.yaml new file mode 100644 index 0000000..c8c5e69 --- /dev/null +++ b/.github/workflows/R-CMD-check-devel.yaml @@ -0,0 +1,76 @@ +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - main + - master + - production-cran + pull_request: + branches: + - main + - master + - production-cran + +name: R-CMD-check-devel + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + + 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: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + upgrade: 'TRUE' + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE, upgrade = "always") + # remotes::install_cran("rcmdcheck") + remotes::install_github("ThinkR-open/lightparser", upgrade = "always") + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_REMOTE_: false + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} # Works on 'main' only + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..d997c12 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,51 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master, production-cran] + pull_request: + branches: [main, master, production-cran] + +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: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + # - {os: ubuntu-20.04, r: '3.6'} + # - {os: ubuntu-20.04, r: '3.5'} # with usethis >2.2 + + 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: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..db1fb18 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,46 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master, production-cran] + pull_request: + branches: [main, master, production-cran] + release: + types: [published] + workflow_dispatch: + +name: pkgdown + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.4.1 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 0000000..74ec7b0 --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,95 @@ +# R-hub's generic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml +# You can update this file to a newer version using the rhub2 package: +# +# rhub::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub +run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + name: + description: 'Run name. You can leave this empty now.' + type: string + id: + description: 'Unique ID. You can leave this empty now.' + type: string + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/actions/setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/run-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/run-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..151bd8f --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,51 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master, production-cran] + pull_request: + branches: [main, master, production-cran] + +name: test-coverage + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr + needs: coverage + + - name: Test coverage + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") + ) + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index ed1252e..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,158 +0,0 @@ -image: rocker/verse - -variables: - GIT_DEPTH: 10 - REPO_NAME: "https://packagemanager.rstudio.com/all/__linux__/focal/latest" - R_LIBS_USER: "ci/lib" - -cache: - key: global-cache - paths: - - ${R_LIBS_USER} - -stages: - - build - - test - - pkgdown - - pkgdown-move - - deploy - -building: - stage: build - script: - - lsb_release -c - - R -e "sessionInfo()" - - if [[ $CI_DEFAULT_BRANCH == "master" || $CI_DEFAULT_BRANCH = "main" ]]; then echo "OK - Default branch is master or main"; else echo "Default branch is not master or main; please add yours ($CI_DEFAULT_BRANCH) where needed, as well as in the present line of code" ; exit 1; fi - - apt-get update -qq && apt-get install -y libharfbuzz-dev libfribidi-dev - - echo "Library path for packages :" $R_LIBS_USER - - mkdir -p $R_LIBS_USER - - Rscript -e 'install.packages("remotes")' - - Rscript -e 'install.packages("rcmdcheck")' - - Rscript -e 'remotes::install_local(upgrade = "always", dependencies = TRUE)' - - R -e 'rcmdcheck::rcmdcheck(args = c("--no-manual"), error_on = "warning", check_dir = "check")' - artifacts: - paths: - - check - expire_in: 30 days - -# For gitlab versions below 15.0, -# in order to have the coverage percentage appear as a gitlab badge, -# you will need to: -# - Go to your project Settings > CI/CD -# - Set the coverage parsing string to: Coverage: \d+\.\d+ - -coverage: - stage: test - allow_failure: true - when: on_success - only: - - main - - master - - production - script: - - Rscript -e 'remotes::install_local(upgrade = "never")' - - Rscript -e 'remotes::install_cran(c("covr", "DT"), upgrade = "never")' - - Rscript -e 'covr::gitlab(quiet = FALSE)' - coverage: '/Coverage: \d+\.\d+/' - artifacts: - paths: - - public - expire_in: 30 days - -# To produce a code coverage report as a GitLab page see -# https://about.gitlab.com/2016/11/03/publish-code-coverage-report-with-gitlab-pages/ - -integration: - stage: pkgdown - allow_failure: true - when: on_success - only: - - main - - master - - production - - test-ci - script: - - Rscript -e 'install.packages("thinkrtemplate", repos = c("thinkropen" = "https://thinkr-open.r-universe.dev"))' - - Rscript -e 'remotes::install_cran(c("pkgdown"), upgrade = "never")' - - Rscript -e 'remotes::install_local(upgrade = "never")' - - Rscript -e 'pkgdown::build_site()' - artifacts: - paths: - - docs - expire_in: 30 days - -integration-test: - stage: pkgdown-move - dependencies: - - integration - only: - - test-ci - script: - - mkdir -p public/test - - 'curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_DEFAULT_BRANCH/download?job=pages" && - unzip artifacts.zip && - rm artifacts.zip && - echo "copied $CI_DEFAULT_BRANCH artifacts" || - echo "copied $CI_DEFAULT_BRANCH artifacts failed"' - - 'curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/production/download?job=pages" && - unzip artifacts.zip && - rm artifacts.zip && - echo "copied production artifacts" || - echo "copied production artifacts failed"' - - cp -r docs/* public/test - artifacts: - paths: - - public - expire_in: 30 days - -integration-production: - stage: pkgdown-move - dependencies: - - integration - only: - - production - script: - - mkdir -p public/production - - 'curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_DEFAULT_BRANCH/download?job=pages" && - unzip artifacts.zip && - rm artifacts.zip && - echo "copied $CI_DEFAULT_BRANCH artifacts" || - echo "copied $CI_DEFAULT_BRANCH artifacts failed"' - - cp -r docs/* public/production - artifacts: - paths: - - public - expire_in: 30 days - -integration-main: - stage: pkgdown-move - dependencies: - - integration - only: - - main - - master - script: - - mkdir -p public - - 'curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/production/download?job=pages" && - unzip artifacts.zip && - rm artifacts.zip && - echo "copied production artifacts" || - echo "copied production artifacts failed"' - - cp -r docs/* public - artifacts: - paths: - - public - expire_in: 30 days - -pages: - stage: deploy - script: - - echo "deployment with cache" - artifacts: - paths: - - public - only: - - main - - master - - production - - test-ci diff --git a/README.Rmd b/README.Rmd index 1407a24..168a319 100644 --- a/README.Rmd +++ b/README.Rmd @@ -28,20 +28,7 @@ The resulting html file can be themed via quarto extensions. ## Installation ```{r eval=FALSE} -if (!requireNamespace("remotes")) {install.packages("remotes")} -if (!requireNamespace("git2r")) {install.packages("git2r")} -options( - remotes.git_credentials = git2r::cred_user_pass( - "gitlab-ci-token", - Sys.getenv("FORGE_PAT") - ) -) - -remotes::install_git( - "https://forge.thinkr.fr/thinkr/thinkrverse/squash", - upgrade = "never" -) ``` diff --git a/README.md b/README.md index bac8660..23377d9 100644 --- a/README.md +++ b/README.md @@ -21,23 +21,6 @@ The resulting html file can be themed via quarto extensions. ## Installation -``` r -if (!requireNamespace("remotes")) {install.packages("remotes")} -if (!requireNamespace("git2r")) {install.packages("git2r")} - -options( - remotes.git_credentials = git2r::cred_user_pass( - "gitlab-ci-token", - Sys.getenv("FORGE_PAT") - ) -) - -remotes::install_git( - "https://forge.thinkr.fr/thinkr/thinkrverse/squash", - upgrade = "never" -) -``` - ## External dependencies This package relies on quarto \> 1.3. @@ -79,9 +62,9 @@ qmds <- list.files( ) qmds -#> [1] "/tmp/Rtmp4CGWT1/course38cdd106ae27d/M01/M01S01/C01-qmd1_for_test.qmd" -#> [2] "/tmp/Rtmp4CGWT1/course38cdd106ae27d/M01/M01S01/C02-qmd2_for_test.qmd" -#> [3] "/tmp/Rtmp4CGWT1/course38cdd106ae27d/M01/M01S02/C01-qmd3_for_test.qmd" +#> [1] "/tmp/RtmpqnCEPl/course3ae567a45a7de/M01/M01S01/C01-qmd1_for_test.qmd" +#> [2] "/tmp/RtmpqnCEPl/course3ae567a45a7de/M01/M01S01/C02-qmd2_for_test.qmd" +#> [3] "/tmp/RtmpqnCEPl/course3ae567a45a7de/M01/M01S02/C01-qmd3_for_test.qmd" ``` And a directory where you want your course to be generated.