diff --git a/.github/.gitignore b/.github/.gitignore index 2d19fc766d..0845489fee 100644 --- a/.github/.gitignore +++ b/.github/.gitignore @@ -1 +1,2 @@ *.html +/pkg.lock diff --git a/.github/workflows/R-CMD-check-dev.yaml b/.github/workflows/R-CMD-check-dev.yaml new file mode 100644 index 0000000000..bb87451a9b --- /dev/null +++ b/.github/workflows/R-CMD-check-dev.yaml @@ -0,0 +1,146 @@ +# This workflow calls the GitHub API very frequently. +# Can't be run as part of commits +on: + schedule: + - cron: "5 0 * * *" # 05:00 UTC every day only run on main branch + push: + branches: + - "cran-*" + tags: + - "v*" + +name: rcc dev + +jobs: + matrix: + runs-on: ubuntu-22.04 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + + name: Collect deps + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/rate-limit + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + + - id: set-matrix + uses: ./.github/workflows/dep-matrix + + check-matrix: + runs-on: ubuntu-22.04 + needs: matrix + + name: Check deps + + steps: + - name: Install json2yaml + run: | + sudo npm install -g json2yaml + + - name: Check matrix definition + run: | + matrix='${{ needs.matrix.outputs.matrix }}' + echo $matrix + echo $matrix | jq . + echo $matrix | json2yaml + + R-CMD-check-base: + runs-on: ubuntu-22.04 + + name: base + + # Begin custom: services + # End custom: services + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/custom/before-install + if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' + + - uses: ./.github/workflows/install + with: + cache-version: rcc-dev-base-1 + needs: check + extra-packages: "any::rcmdcheck any::remotes ." + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Session info + run: | + options(width = 100) + if (!requireNamespace("sessioninfo", quietly = TRUE)) install.packages("sessioninfo") + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + - uses: ./.github/workflows/custom/after-install + if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' + + - uses: ./.github/workflows/update-snapshots + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + + - uses: ./.github/workflows/check + with: + results: ${{ matrix.package }} + + R-CMD-check-dev: + needs: + - matrix + - R-CMD-check-base + + runs-on: ubuntu-22.04 + + name: 'rcc-dev: ${{ matrix.package }}' + + # Begin custom: services + # End custom: services + + strategy: + fail-fast: false + matrix: ${{fromJson(needs.matrix.outputs.matrix)}} + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/custom/before-install + if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' + + - uses: ./.github/workflows/install + with: + cache-version: rcc-dev-${{ matrix.package }}-1 + needs: check + extra-packages: "any::rcmdcheck any::remotes ." + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dev version of ${{ matrix.package }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + run: | + remotes::install_dev("${{ matrix.package }}", "https://cloud.r-project.org", upgrade = "always") + shell: Rscript {0} + + - name: Session info + run: | + options(width = 100) + if (!requireNamespace("sessioninfo", quietly = TRUE)) install.packages("sessioninfo") + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + - uses: ./.github/workflows/custom/after-install + if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' + + - uses: ./.github/workflows/update-snapshots + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + + - uses: ./.github/workflows/check + with: + results: ${{ matrix.package }} diff --git a/.github/workflows/R-CMD-check-status.yaml b/.github/workflows/R-CMD-check-status.yaml new file mode 100644 index 0000000000..7a4ea62f05 --- /dev/null +++ b/.github/workflows/R-CMD-check-status.yaml @@ -0,0 +1,75 @@ +# Workflow to update the status of a commit for the R-CMD-check workflow +# Necessary because remote PRs cannot update the status of the commit +on: + workflow_run: + workflows: + - rcc + types: + - requested + - completed + +name: rcc-status + +jobs: + rcc-status: + runs-on: ubuntu-24.04 + + name: "Update commit status" + + steps: + - name: "Update commit status" + # Only run if triggered by rcc workflow + if: github.event.workflow_run.name == 'rcc' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -x + + if [ "${{ github.event.workflow_run.status }}" == "completed" ]; then + if [ "${{ github.event.workflow_run.conclusion }}" == "success" ]; then + state="success" + else + state="failure" + fi + + # Read artifact ID + artifact_id=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/artifacts | jq -r '.artifacts[] | select(.name == "rcc-smoke-sha") | .id') + + if [ -n "${artifact_id}" ]; then + # Download artifact + curl -L -o rcc-smoke-sha.zip \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GH_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${artifact_id}/zip + + # Unzip artifact + unzip rcc-smoke-sha.zip + + # Read artifact + sha=$(cat rcc-smoke-sha.txt) + + # Clean up + rm rcc-smoke-sha.zip rcc-smoke-sha.txt + fi + else + state="pending" + fi + + if [ -z "${sha}" ]; then + sha=${{ github.event.workflow_run.head_sha }} + fi + + html_url=${{ github.event.workflow_run.html_url }} + description=${{ github.event.workflow_run.name }} + + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + repos/${{ github.repository }}/statuses/${sha} \ + -f "state=${state}" -f "target_url=${html_url}" -f "description=${description}" -f "context=rcc" + shell: bash diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000000..41ae8a5b56 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,345 @@ +# 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 +# +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. +on: + push: + branches: + - main + - master + - release + - cran-* + pull_request: + branches: + - main + - master + workflow_dispatch: + inputs: + ref: + description: "Branch, tag, or commit to check out" + required: false + default: "main" + versions-matrix: + description: "Create a matrix of R versions" + type: boolean + default: false + dep-suggests-matrix: + description: "Create a matrix of suggested dependencies" + type: boolean + default: false + merge_group: + types: + - checks_requested + schedule: + - cron: "10 0 * * *" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.ref || github.head_ref || github.sha }}-${{ github.base_ref || '' }} + cancel-in-progress: true + +name: rcc + +jobs: + rcc-smoke: + runs-on: ubuntu-24.04 + outputs: + sha: ${{ steps.commit.outputs.sha }} + versions-matrix: ${{ steps.versions-matrix.outputs.matrix }} + dep-suggests-matrix: ${{ steps.dep-suggests-matrix.outputs.matrix }} + + name: "Smoke test: stock R" + + # Begin custom: services + # End custom: services + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + + - name: Update status for rcc + # FIXME: Wrap into action + if: github.event_name == 'workflow_dispatch' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Check status of this workflow + state="pending" + sha=${{ inputs.ref }} + if [ -z "${sha}" ]; then + sha=${{ github.head_ref }} + fi + if [ -z "${sha}" ]; then + sha=${{ github.sha }} + fi + sha=$(git rev-parse ${sha}) + + html_url=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + repos/${{ github.repository }}/actions/runs/${{ github.run_id }} | jq -r .html_url) + + description="${{ github.workflow }} / ${{ github.job }}" + + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + repos/${{ github.repository }}/statuses/${sha} \ + -f "state=${state}" -f "target_url=${html_url}" -f "description=${description}" -f "context=rcc" + shell: bash + + - uses: ./.github/workflows/rate-limit + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: ./.github/workflows/git-identity + + - uses: ./.github/workflows/custom/before-install + if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' + + - uses: ./.github/workflows/install + with: + token: ${{ secrets.GITHUB_TOKEN }} + cache-version: rcc-smoke-2 + needs: check, website + # Beware of using dev pkgdown here, has brought in dev dependencies in the past + extra-packages: any::rcmdcheck r-lib/roxygen2 any::decor r-lib/styler r-lib/pkgdown deps::. + + - name: Install package + run: | + _R_SHLIB_STRIP_=true R CMD INSTALL . + shell: bash + + - uses: ./.github/workflows/custom/after-install + if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' + + - id: versions-matrix + # Only run for pull requests if the base repo is different from the head repo, not for workflow_dispatch if not requested, always run for other events + if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository) && (github.event_name != 'workflow_dispatch' || inputs.versions-matrix) + uses: ./.github/workflows/versions-matrix + + - id: dep-suggests-matrix + # Not for workflow_dispatch if not requested, always run for other events + if: github.event_name != 'workflow_dispatch' || inputs.dep-suggests-matrix + uses: ./.github/workflows/dep-suggests-matrix + + - uses: ./.github/workflows/update-snapshots + with: + base: ${{ inputs.ref || github.head_ref }} + + - uses: ./.github/workflows/style + + - uses: ./.github/workflows/roxygenize + + - name: Remove config files from previous iteration + run: | + rm -f .github/dep-suggests-matrix.json .github/versions-matrix.json + shell: bash + + - id: commit + uses: ./.github/workflows/commit + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: ./.github/workflows/check + with: + results: ${{ runner.os }}-smoke-test + + - uses: ./.github/workflows/pkgdown-build + if: github.event_name != 'push' + + - uses: ./.github/workflows/pkgdown-deploy + if: github.event_name == 'push' + + # Upload sha as artifact + - run: | + echo -n "${{ steps.commit.outputs.sha }}" > rcc-smoke-sha.txt + shell: bash + + - uses: actions/upload-artifact@v4 + with: + name: rcc-smoke-sha + path: rcc-smoke-sha.txt + + - name: Update status for rcc + # FIXME: Wrap into action + if: always() && github.event_name == 'workflow_dispatch' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Check status of this workflow + if [ "${{ job.status }}" == "success" ]; then + state="success" + else + state="failure" + fi + + sha=${{ steps.commit.outputs.sha }} + if [ -z "${sha}" ]; then + sha=${{ inputs.ref }} + fi + if [ -z "${sha}" ]; then + sha=${{ github.head_ref }} + fi + if [ -z "${sha}" ]; then + sha=${{ github.sha }} + fi + sha=$(git rev-parse ${sha}) + + html_url=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + repos/${{ github.repository }}/actions/runs/${{ github.run_id }} | jq -r .html_url) + + description="${{ github.workflow }} / ${{ github.job }}" + + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + repos/${{ github.repository }}/statuses/${sha} \ + -f "state=${state}" -f "target_url=${html_url}" -f "description=${description}" -f "context=rcc" + shell: bash + + rcc-smoke-check-matrix: + runs-on: ubuntu-24.04 + + name: "Check matrix" + + needs: + - rcc-smoke + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.rcc-smoke.outputs.sha }} + + - uses: ./.github/workflows/matrix-check + with: + matrix: ${{ needs.rcc-smoke.outputs.versions-matrix }} + + - uses: ./.github/workflows/matrix-check + with: + matrix: ${{ needs.rcc-smoke.outputs.dep-suggests-matrix }} + + rcc-full: + needs: + - rcc-smoke + + runs-on: ${{ matrix.os }} + + if: ${{ needs.rcc-smoke.outputs.versions-matrix != '' }} + + name: 'rcc: ${{ matrix.os }} (${{ matrix.r }}) ${{ matrix.desc }}' + + # Begin custom: services + # End custom: services + + strategy: + fail-fast: false + matrix: ${{fromJson(needs.rcc-smoke.outputs.versions-matrix)}} + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.rcc-smoke.outputs.sha }} + + - uses: ./.github/workflows/custom/before-install + if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' + + - uses: ./.github/workflows/install + with: + r-version: ${{ matrix.r }} + cache-version: rcc-full-1 + token: ${{ secrets.GITHUB_TOKEN }} + needs: check + + - uses: ./.github/workflows/custom/after-install + if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' + + - uses: ./.github/workflows/update-snapshots + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + + - uses: ./.github/workflows/check + with: + results: ${{ runner.os }}-r${{ matrix.r }} + +# The status update is taken care of by R-CMD-check-status.yaml + + rcc-suggests: + needs: + - rcc-smoke + + runs-on: ubuntu-22.04 + + if: ${{ needs.rcc-smoke.outputs.dep-suggests-matrix != '' }} + + name: Without ${{ matrix.package }} + + # Begin custom: services + # End custom: services + + strategy: + fail-fast: false + matrix: ${{fromJson(needs.rcc-smoke.outputs.dep-suggests-matrix)}} + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/custom/before-install + if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' + + - uses: ./.github/workflows/install + with: + cache-version: rcc-dev-${{ matrix.package }}-1 + needs: check + extra-packages: "any::rcmdcheck any::remotes ." + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Remove ${{ matrix.package }} and all strong dependencies + run: | + pkg <- "${{ matrix.package }}" + pkgs <- tools::package_dependencies(pkg, reverse = TRUE)[[1]] + installed <- rownames(utils::installed.packages()) + to_remove <- c(pkg, intersect(pkgs, installed)) + print(to_remove) + remove.packages(to_remove) + shell: Rscript {0} + + - name: Session info + run: | + options(width = 100) + if (!requireNamespace("sessioninfo", quietly = TRUE)) install.packages("sessioninfo") + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + - uses: ./.github/workflows/custom/after-install + if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' + + - name: Define _R_CHECK_FORCE_SUGGESTS_ + run: | + cat('_R_CHECK_FORCE_SUGGESTS_=false\n', file = Sys.getenv("GITHUB_ENV"), append = TRUE) + shell: Rscript {0} + + - name: Must allow NOTEs, even with _R_CHECK_FORCE_SUGGESTS_ + run: | + if (Sys.getenv("RCMDCHECK_ERROR_ON") %in% c("", "note")) { + cat('RCMDCHECK_ERROR_ON="warning"\n', file = Sys.getenv("GITHUB_ENV"), append = TRUE) + } + shell: Rscript {0} + + - name: Check env vars + run: | + print(Sys.getenv('_R_CHECK_FORCE_SUGGESTS_')) + print(Sys.getenv('RCMDCHECK_ERROR_ON')) + shell: Rscript {0} + + - uses: ./.github/workflows/check + with: + results: ${{ matrix.package }} + +# The status update is taken care of by R-CMD-check-status.yaml diff --git a/.github/workflows/after-install/action.yml b/.github/workflows/after-install/action.yml deleted file mode 100644 index 8d1de17aff..0000000000 --- a/.github/workflows/after-install/action.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: 'Custom steps to run after R packages are installed' - -runs: - using: "composite" - steps: - - uses: ankane/setup-postgres@v1 - if: env.DM_TEST_SRC == 'test-postgres' - - - name: Create database - if: env.DM_TEST_SRC == 'test-postgres' - run: | - createdb ${USER} - shell: bash - - # Must happen after installing system dependencies, - # https://github.com/ankane/setup-mariadb/issues/2 - - uses: ankane/setup-mariadb@v1 - if: env.DM_TEST_SRC == 'test-maria' - with: - mariadb-version: 10.11 - - - uses: ankane/setup-mysql@v1 - if: env.DM_TEST_SRC == 'test-mysql-maria' - with: - mysql-version: "8.0" - - - name: Create database (MariaDB), set it to UTF-8, add time zone info - if: env.DM_TEST_SRC == 'test-maria' || env.DM_TEST_SRC == 'test-mysql-maria' - run: | - mysql -e "CREATE DATABASE IF NOT EXISTS test; ALTER DATABASE test CHARACTER SET 'utf8'; FLUSH PRIVILEGES;" - shell: bash - - - uses: ankane/setup-sqlserver@v1 - if: env.DM_TEST_SRC == 'test-mssql' - with: - accept-eula: true - - - name: Create database (SQL Server) - if: env.DM_TEST_SRC == 'test-mssql' - run: | - sqlcmd -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE test;' - shell: bash - - - name: Set ODBCSYSINI (SQL Server) - if: env.DM_TEST_SRC == 'test-mssql' - run: | - ln -s /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.*.so.* /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.so - echo "ODBCSYSINI=${{ github.workspace }}/.github/odbc" | tee -a $GITHUB_ENV - shell: bash - - - name: Allow slower examples - run: | - # FIXME: Slow examples in dm? - echo "_R_CHECK_EXAMPLE_TIMING_THRESHOLD_=15" | tee -a $GITHUB_ENV - shell: bash diff --git a/.github/workflows/before-install/action.yml b/.github/workflows/before-install/action.yml deleted file mode 100644 index d07a8f6b5c..0000000000 --- a/.github/workflows/before-install/action.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: 'Custom steps to run before R packages are installed' - -runs: - using: "composite" - steps: - - name: Define R CMD check error condition - # Rscript not available on Mac - if: runner.os != 'macOS' - run: | - if (getRversion() < "4.0") { - message("Setting RCMDCHECK_ERROR_ON") - cat('RCMDCHECK_ERROR_ON="warning"\n', file = Sys.getenv("GITHUB_ENV"), append = TRUE) - } - shell: Rscript {0} - - - name: Define _R_CHECK_PKG_SIZES_THRESHOLD_ - run: | - echo '_R_CHECK_PKG_SIZES_THRESHOLD_=10' | tee -a $GITHUB_ENV - shell: bash - - - name: Define _R_CHECK_FORCE_SUGGESTS_ - # Rscript not available on Mac - if: runner.os != 'macOS' - run: | - if (getRversion() < "4.0") { - message("Setting _R_CHECK_FORCE_SUGGESTS_") - cat('_R_CHECK_FORCE_SUGGESTS_=false\n', file = Sys.getenv("GITHUB_ENV"), append = TRUE) - } - shell: Rscript {0} - - - name: Define DM_TEST_SRC - run: | - echo "DM_TEST_SRC=${{ matrix.config.test-src }}" | tee -a $GITHUB_ENV - shell: bash - - - name: Clean up broken mysql apt - # FIXME: Remove if package becomes unavailable - if: runner.os == 'Linux' - run: | - sudo apt-get update - if [ $(lsb_release --short --codename) == 'focal' ]; then - sudo apt-get install mysql-common=5.8+1.0.5ubuntu2 --allow-downgrades - fi - shell: bash diff --git a/.github/workflows/build-and-check.yml b/.github/workflows/build-and-check.yml index 38499e6338..c22cfc64b0 100644 --- a/.github/workflows/build-and-check.yml +++ b/.github/workflows/build-and-check.yml @@ -16,162 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.sha }}-${{ github.base_ref || '' }} cancel-in-progress: true -name: R-CMD-check +name: R-CMD-check-extra jobs: - build_src_package: - runs-on: ubuntu-22.04 - - name: Build source R package - - env: - RSPM: https://packagemanager.rstudio.com/cran/__linux__/jammy/latest - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - - - name: apt update - run: | - sudo apt-get update - sudo apt-get install -y libarpack2-dev - shell: bash - - - name: Cache Python virtualenv - uses: actions/cache@v2 - with: - path: .venv - key: Python-venv-jammy-${{ runner.os }}-${{ hashFiles('tools/build-requirements.txt') }} - - - name: Install R dependencies - uses: r-lib/actions/setup-r-dependencies@v2 - with: - needs: build - pak-version: devel - - - name: Create R source package - run: | - make igraph - shell: bash - - - name: Commit changes - if: ${{ env.GITHUB_ACTOR == env.GITHUB_REPOSITORY_OWNER }} - run: | - if [ -n "$(git status --porcelain)" ]; then - git config --local user.name "$GITHUB_ACTOR" - git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" - git fetch - if [ -n "${GITHUB_HEAD_REF}" ]; then - git add . - git stash save - git switch ${GITHUB_HEAD_REF} - git stash pop - fi - git add . - git commit -m "Automated changes" - git push - fi - shell: bash - - - name: Package validation - if: ${{ env.GITHUB_ACTOR != env.GITHUB_REPOSITORY_OWNER }} - run: | - git status --porcelain - if [ -n "$(git status --porcelain)" ]; then - git add . - git diff --cached - /bin/false - fi - shell: bash - - - name: Smoke test - run: | - make test - shell: bash - - - name: Upload R source package - uses: actions/upload-artifact@main - with: - name: rigraph - path: igraph_*.tar.gz - retention-days: 5 - - R-CMD-check: - runs-on: ${{ matrix.config.os }} - - needs: build_src_package - - name: Check ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - - {os: windows-latest, r: 'release'} - # - {os: macOS-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - # - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'oldrel-1', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'oldrel-2', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'oldrel-3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'oldrel-4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - env: - RSPM: ${{ matrix.config.rspm }} - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - RGL_USE_NULL: true # Ensure that rgl functions correctly on macOS - MAKEFLAGS: -j2 - _R_CHECK_PKG_SIZES_: FALSE - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Install ccache - uses: hendrikmuhs/ccache-action@v1.2.10 - with: - max-size: 10G - verbose: 1 - save: false - restore: false - - - name: apt update - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y libarpack2-dev - shell: bash - - - name: apt update - if: runner.os == 'macOS' - run: | - brew install glpk - shell: bash - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.config.r }} - - - name: Setup Pandoc - uses: r-lib/actions/setup-pandoc@v2 - - - name: Install R dependencies - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck - needs: check - - - name: Check R package - uses: r-lib/actions/check-r-package@v2 - with: - error-on: '"note"' - coverage: runs-on: ubuntu-20.04 diff --git a/.github/workflows/check/action.yml b/.github/workflows/check/action.yml index 52bac2d2d7..afb38194ca 100644 --- a/.github/workflows/check/action.yml +++ b/.github/workflows/check/action.yml @@ -7,7 +7,7 @@ inputs: runs: using: "composite" steps: - - uses: r-lib/actions/check-r-package@v2-branch + - uses: r-lib/actions/check-r-package@v2 with: # Fails on R 3.6 on Windows, remove when this job is removed? args: 'c("--no-manual", "--as-cran", "--no-multiarch")' diff --git a/.github/workflows/commit/action.yml b/.github/workflows/commit/action.yml index 89be422289..ed6f9b8968 100644 --- a/.github/workflows/commit/action.yml +++ b/.github/workflows/commit/action.yml @@ -1,4 +1,8 @@ name: "Action to commit changes to the repository" +inputs: + token: + description: "GitHub token" + required: true outputs: sha: description: "SHA of generated commit" @@ -7,23 +11,53 @@ outputs: runs: using: "composite" steps: - - name: Commit if changed + - name: Commit if changed, create a PR if protected id: commit + env: + GITHUB_TOKEN: ${{ inputs.token }} run: | set -x if [ -n "$(git status --porcelain)" ]; then echo "Changed" - git fetch - if [ -n "${GITHUB_HEAD_REF}" ]; then + protected=${{ github.ref_protected }} + foreign=${{ github.event.pull_request.head.repo.full_name != github.repository }} + if [ "${foreign}" = "true" ]; then + # https://github.com/krlmlr/actions-sync/issues/44 + echo "Can't push to foreign branch" + elif [ "${protected}" = "true" ]; then + current_branch=$(git branch --show-current) + new_branch=gha-commit-$(git rev-parse --short HEAD) + git checkout -b ${new_branch} git add . - git stash save - git switch ${GITHUB_HEAD_REF} - git merge origin/${GITHUB_BASE_REF} --no-edit - git stash pop + git commit -m "chore: Auto-update from GitHub Actions"$'\n'$'\n'"Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + # Force-push, used in only one place + # Alternative: separate branch names for each usage + git push -u origin HEAD -f + + existing_pr=$(gh pr list --state open --base main --head ${new_branch} --json number --jq '.[] | .number') + if [ -n "${existing_pr}" ]; then + echo "Existing PR: ${existing_pr}" + else + gh pr create --base main --head ${new_branch} --title "chore: Auto-update from GitHub Actions" --body "Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + fi + + gh workflow run rcc -f ref=$(git rev-parse HEAD) + gh pr merge --merge --auto + else + git fetch + if [ -n "${GITHUB_HEAD_REF}" ]; then + git add . + git stash save + git switch ${GITHUB_HEAD_REF} + git merge origin/${GITHUB_BASE_REF} --no-edit + git stash pop + fi + git add . + git commit -m "chore: Auto-update from GitHub Actions"$'\n'$'\n'"Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + git push -u origin HEAD + + # Only set output if changed + echo sha=$(git rev-parse HEAD) >> $GITHUB_OUTPUT fi - git add . - git commit -m "Auto-update from GitHub Actions"$'\n'$'\n'"Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" - git push -u origin HEAD - echo sha=$(git rev-parse HEAD) >> $GITHUB_OUTPUT fi shell: bash diff --git a/.github/workflows/dep-matrix-suggests/action.yml b/.github/workflows/dep-matrix-suggests/action.yml deleted file mode 100644 index deafab932e..0000000000 --- a/.github/workflows/dep-matrix-suggests/action.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: "Actions to compute a matrix with all suggested packages" -outputs: - matrix: - description: "Generated matrix" - value: ${{ steps.set-matrix.outputs.matrix }} - -runs: - using: "composite" - steps: - - id: set-matrix - run: | - get_deps <- function() { - # Determine package dependencies - if (!requireNamespace("desc", quietly = TRUE)) { - install.packages("desc") - } - - deps_df <- desc::desc_get_deps() - deps_df_optional <- deps_df$package[deps_df$type %in% c("Suggests", "Enhances")] - deps_df_hard <- deps_df$package[deps_df$type %in% c("Depends", "Imports", "LinkingTo")] - - packages <- sort(deps_df_optional) - packages <- intersect(packages, rownames(available.packages())) - - # Too big to fail, or can't be avoided: - off_limits <- c("testthat", "rmarkdown", "rcmdcheck", deps_df_hard) - off_limits_dep <- unlist(tools::package_dependencies(off_limits, recursive = TRUE, which = "strong")) - setdiff(packages, c(off_limits, off_limits_dep)) - } - - if (Sys.getenv("GITHUB_BASE_REF") != "") { - print(Sys.getenv("GITHUB_BASE_REF")) - has_diff <- (system("git diff ${{ github.event.pull_request.base.sha }}... | egrep '^[+][^+]' | grep -q ::") == 0) - if (has_diff) { - system("git diff ${{ github.event.pull_request.base.sha }}... | egrep '^[+][^+]' | grep -q ::") - packages <- get_deps() - } else { - writeLines("No changes using :: found, not checking without suggested packages") - packages <- character() - } - } else { - packages <- get_deps() - } - - if (length(packages) > 0) { - json <- paste0( - '{"package":[', - paste0('"', packages, '"', collapse = ","), - ']}' - ) - writeLines(json) - writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT")) - } else { - writeLines("Package list empty!") - } - shell: Rscript {0} diff --git a/.github/workflows/dep-suggests-matrix/action.R b/.github/workflows/dep-suggests-matrix/action.R new file mode 100644 index 0000000000..eff3a502c3 --- /dev/null +++ b/.github/workflows/dep-suggests-matrix/action.R @@ -0,0 +1,49 @@ +# FIXME: Dynamic lookup by parsing https://svn.r-project.org/R/tags/ +get_deps <- function() { + # Determine package dependencies + if (!requireNamespace("desc", quietly = TRUE)) { + install.packages("desc") + } + + deps_df <- desc::desc_get_deps() + deps_df_optional <- deps_df$package[deps_df$type %in% c("Suggests", "Enhances")] + deps_df_hard <- deps_df$package[deps_df$type %in% c("Depends", "Imports", "LinkingTo")] + deps_df_base <- unlist(tools::standard_package_names(), use.names = FALSE) + + packages <- sort(deps_df_optional) + packages <- intersect(packages, rownames(available.packages())) + + # Too big to fail, or can't be avoided: + off_limits <- c("testthat", "rmarkdown", "rcmdcheck", deps_df_hard, deps_df_base) + off_limits_dep <- unlist(tools::package_dependencies(off_limits, recursive = TRUE, which = "strong")) + setdiff(packages, c(off_limits, off_limits_dep)) +} + +if (Sys.getenv("GITHUB_BASE_REF") != "") { + print(Sys.getenv("GITHUB_BASE_REF")) + system("git fetch origin ${GITHUB_BASE_REF}") + # Use .. to avoid having to fetch the entire history + # https://github.com/krlmlr/actions-sync/issues/45 + has_diff <- (system("git diff origin/${GITHUB_BASE_REF}.. | egrep '^[+][^+]' | grep -q ::") == 0) + if (has_diff) { + system("git diff origin/${GITHUB_BASE_REF}.. | egrep '^[+][^+]' | grep -q ::") + packages <- get_deps() + } else { + writeLines("No changes using :: found, not checking without suggested packages") + packages <- character() + } +} else { + packages <- get_deps() +} + +if (length(packages) > 0) { + json <- paste0( + '{"package":[', + paste0('"', packages, '"', collapse = ","), + ']}' + ) + writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT")) + writeLines(json) +} else { + writeLines("No suggested packages found.") +} diff --git a/.github/workflows/dep-suggests-matrix/action.yml b/.github/workflows/dep-suggests-matrix/action.yml new file mode 100644 index 0000000000..0f5e649514 --- /dev/null +++ b/.github/workflows/dep-suggests-matrix/action.yml @@ -0,0 +1,13 @@ +name: "Actions to compute a matrix with all suggested packages" +outputs: + matrix: + description: "Generated matrix" + value: ${{ steps.set-matrix.outputs.matrix }} + +runs: + using: "composite" + steps: + - id: set-matrix + run: | + Rscript ./.github/workflows/dep-suggests-matrix/action.R + shell: bash diff --git a/.github/workflows/fledge.yaml b/.github/workflows/fledge.yaml index 81c2d0c0ae..7785ad93a5 100644 --- a/.github/workflows/fledge.yaml +++ b/.github/workflows/fledge.yaml @@ -3,56 +3,115 @@ name: fledge on: # for manual triggers workflow_dispatch: + inputs: + pr: + description: "Create PR" + required: false + type: boolean + default: false # daily run schedule: - cron: "30 0 * * *" concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.sha }}-${{ github.base_ref || '' }} + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }} cancel-in-progress: true jobs: check_fork: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 outputs: is_forked: ${{ steps.check.outputs.is_forked }} steps: - name: Check if the repo is forked id: check + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - echo "is_forked=$(curl -s -H "Accept: application/vnd.github+json" -H 'Authorization: Bearer ${{ github.token }}' -H "X-GitHub-Api-Version: 2022-11-28" ${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY} | jq .fork)" >> $GITHUB_OUTPUT + is_forked=$(gh api repos/${{ github.repository }} | jq .fork) + echo "is_forked=${is_forked}" >> $GITHUB_OUTPUT + shell: bash fledge: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 needs: check_fork if: needs.check_fork.outputs.is_forked == 'false' permissions: contents: write + pull-requests: write + actions: write env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} FLEDGE_GHA_CI: true steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: ./.github/workflows/git-identity + - name: Configure Git identity + run: | + env | sort + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + shell: bash + + - name: Update apt + run: | + sudo apt-get update + shell: bash - - uses: ./.github/workflows/install + - uses: r-lib/actions/setup-r@v2 with: - token: ${{ secrets.GITHUB_TOKEN }} - install-r: false - cache-version: fledge-1 + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + with: + pak-version: devel packages: cynkra/fledge + cache-version: fledge-1 + + - name: Count rulesets + # Assume that branch is protected if ruleset exists + id: rulesets + env: + GH_TOKEN: ${{ github.token }} + run: | + n_rulesets=$(gh api repos/${{ github.repository }}/rulesets -q length) + echo "count=${n_rulesets}" >> $GITHUB_OUTPUT + shell: bash + + - name: Switch to branch if branch protection is enabled + if: github.ref_protected == 'true' || inputs.pr == 'true' || steps.rulesets.outputs.count > 0 + run: | + git checkout -b fledge + git push -f -u origin HEAD + shell: bash - name: Bump version + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} run: | - if (fledge::bump_version(which = "dev", no_change_behavior = "noop")) { + check_default_branch <- ("${{ github.ref_protected == 'true' || inputs.pr == 'true' || steps.rulesets.outputs.count > 0 }}" != "true") + if (fledge::bump_version(which = "dev", no_change_behavior = "noop", check_default_branch = check_default_branch)) { fledge::finalize_version(push = TRUE) } shell: Rscript {0} + - name: Create and merge PR if branch protection is enabled + if: github.ref_protected == 'true' || inputs.pr == 'true' || steps.rulesets.outputs.count > 0 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -x + gh pr create --base main --head fledge --fill-first + gh workflow run rcc -f ref=$(git rev-parse HEAD) + gh pr merge --squash --auto + shell: bash + - name: Check release + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} run: | fledge:::release_after_cran_built_binaries() shell: Rscript {0} diff --git a/.github/workflows/install/action.yml b/.github/workflows/install/action.yml index e13e2f5921..59673d9cac 100644 --- a/.github/workflows/install/action.yml +++ b/.github/workflows/install/action.yml @@ -37,20 +37,48 @@ runs: echo "R_KEEP_PKG_SOURCE=yes" | tee -a $GITHUB_ENV echo "_R_CHECK_SYSTEM_CLOCK_=false" | tee -a $GITHUB_ENV echo "_R_CHECK_FUTURE_FILE_TIMESTAMPS_=false" | tee -a $GITHUB_ENV - echo "_R_CHECK_S3_METHODS_SHOW_POSSIBLE_ISSUES_=true" | tee -a $GITHUB_ENV - if [[ "${{ github.head_ref }}" =~ "^cran-" ]]; then echo "_R_CHECK_CRAN_INCOMING_=true" | tee -a $GITHUB_ENV; fi - # FIXME: False positive with cynkra.com? - echo "_R_CHECK_CRAN_INCOMING_REMOTE_=false" | tee -a $GITHUB_ENV - - # prevent rgl issues because no X11 display is available echo "RGL_USE_NULL=true" | tee -a $GITHUB_ENV + # from https://github.com/r-devel/r-dev-web/blob/main/CRAN/QA/Kurt/lib/R/Scripts/check_CRAN_incoming.R + echo "_R_CHECK_CRAN_INCOMING_CHECK_FILE_URIS_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_CRAN_INCOMING_NOTE_GNU_MAKE_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_PACKAGE_DEPENDS_IGNORE_MISSING_ENHANCES_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_CODE_CLASS_IS_STRING_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_CODOC_VARIABLES_IN_USAGES_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_CONNECTIONS_LEFT_OPEN_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_DATALIST_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_NEWS_IN_PLAIN_TEXT_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_PACKAGES_USED_CRAN_INCOMING_NOTES_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_RD_CONTENTS_KEYWORDS_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_R_DEPENDS_=warn" | tee -a $GITHUB_ENV + echo "_R_CHECK_S3_METHODS_SHOW_POSSIBLE_ISSUES_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_THINGS_IN_TEMP_DIR_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_UNDOC_USE_ALL_NAMES_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_URLS_SHOW_301_STATUS_=true" | tee -a $GITHUB_ENV + echo "_R_CXX_USE_NO_REMAP_=true" | tee -a $GITHUB_ENV + # There is no way to disable recency and frequency checks when the incoming checks are run + # echo "_R_CHECK_CRAN_INCOMING_=true" | tee -a $GITHUB_ENV + echo "_R_CHECK_CRAN_INCOMING_SKIP_LARGE_VERSION_=true" | tee -a $GITHUB_ENV + shell: bash + + - name: Set environment variables (non-Windows only) + if: runner.os != 'Windows' + run: | + echo "_R_CHECK_BASHISMS_=true" | tee -a $GITHUB_ENV shell: bash - name: Update apt if: runner.os == 'Linux' run: | sudo apt-get update + sudo apt-get install -y aspell + echo "_R_CHECK_CRAN_INCOMING_USE_ASPELL_=true" | tee -a $GITHUB_ENV + shell: bash + + - name: Remove pkg-config@0.29.2 + if: runner.os == 'macOS' + run: | + brew uninstall pkg-config@0.29.2 shell: bash - uses: r-lib/actions/setup-pandoc@v2 @@ -63,13 +91,17 @@ runs: use-public-rspm: true - id: get-extra - uses: ./.github/workflows/get-extra + run: | + set -x + packages=$( ( grep Config/gha/extra-packages DESCRIPTION || true ) | cut -d " " -f 2) + echo packages=$packages >> $GITHUB_OUTPUT + shell: bash - uses: r-lib/actions/setup-r-dependencies@v2 env: GITHUB_PAT: ${{ inputs.token }} with: - pak-version: devel + pak-version: stable needs: ${{ inputs.needs }} packages: ${{ inputs.packages }} extra-packages: ${{ inputs.extra-packages }} ${{ ( matrix.config.covr && 'any::covr' ) || '' }} ${{ steps.get-extra.outputs.packages }} @@ -121,3 +153,8 @@ runs: git rm -rf .ccache || true rm -rf .ccache shell: bash + + - name: Show R CMD config --all + run: | + R CMD config --all + shell: bash diff --git a/.github/workflows/lock.yaml b/.github/workflows/lock.yaml index 2b6f44ecdf..6c52f683d6 100644 --- a/.github/workflows/lock.yaml +++ b/.github/workflows/lock.yaml @@ -6,11 +6,11 @@ permissions: on: workflow_dispatch: schedule: - - cron: "0 0 * * *" + - cron: "37 2 * * *" jobs: lock: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: dessant/lock-threads@v5 with: diff --git a/.github/workflows/matrix-check/action.yml b/.github/workflows/matrix-check/action.yml new file mode 100644 index 0000000000..b94304819b --- /dev/null +++ b/.github/workflows/matrix-check/action.yml @@ -0,0 +1,23 @@ +name: "Actions to check a matrix with all R and OS versions, computed with the versions-matrix action" +inputs: + matrix: + description: "Generated matrix" + required: true + +runs: + using: "composite" + steps: + - name: Install json2yaml + run: | + sudo npm install -g json2yaml + shell: bash + + - run: | + matrix='${{ inputs.matrix }}' + if [ -n "${matrix}" ]; then + echo $matrix | jq . + echo $matrix | json2yaml + else + echo "No matrix found" + fi + shell: bash diff --git a/.github/workflows/pkgdown-deploy/action.yml b/.github/workflows/pkgdown-deploy/action.yml index 18d0206dff..b7c3ff4caf 100644 --- a/.github/workflows/pkgdown-deploy/action.yml +++ b/.github/workflows/pkgdown-deploy/action.yml @@ -4,7 +4,7 @@ runs: using: "composite" steps: - name: Deploy site - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 15 max_attempts: 10 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index a7bee3a955..60d1849077 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,51 +1,53 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Also included in R-CMD-check.yaml, this workflow only listens to pushes to branches # that start with "docs*" on: push: branches: - - main - "docs*" - "cran-*" - pull_request: - branches: - - main - release: - types: [published] workflow_dispatch: name: pkgdown +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.sha }}-${{ github.base_ref || '' }} + cancel-in-progress: true + 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 + runs-on: ubuntu-24.04 + + name: "pkgdown" + + # Begin custom: services + # End custom: services - - uses: r-lib/actions/setup-pandoc@v2 + steps: + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-r@v2 + - uses: ./.github/workflows/rate-limit with: - use-public-rspm: true + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: ./.github/workflows/git-identity + if: github.event_name == 'push' + + - uses: ./.github/workflows/custom/before-install + if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' - - uses: r-lib/actions/setup-r-dependencies@v2 + - uses: ./.github/workflows/install with: - extra-packages: any::pkgdown, local::. + token: ${{ secrets.GITHUB_TOKEN }} + cache-version: pkgdown-2 needs: website + extra-packages: r-lib/pkgdown local::. - - name: Build site - run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) - shell: Rscript {0} + - uses: ./.github/workflows/custom/after-install + if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' - - 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 + - uses: ./.github/workflows/pkgdown-build + if: github.event_name != 'push' + + - uses: ./.github/workflows/pkgdown-deploy + if: github.event_name == 'push' diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 0000000000..b07a6f3a7f --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -0,0 +1,99 @@ +on: + issue_comment: + types: [created] +name: Commands +jobs: + document: + if: startsWith(github.event.comment.body, '/document') + name: document + # macos is actually better here due to native binary packages + runs-on: macos-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@v2 + - name: Configure Git identity + run: | + env | sort + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + shell: bash + - name: Install dependencies + run: | + install.packages(c("remotes", "roxygen2"), type = "binary") + remotes::install_deps(dependencies = TRUE) + shell: Rscript {0} + - name: Document + run: | + roxygen2::roxygenise() + shell: Rscript {0} + - name: commit + run: | + if [ -n "$(git status --porcelain man/ NAMESPACE)" ]; then + git add man/ NAMESPACE + git commit -m 'Document' + fi + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + style: + if: startsWith(github.event.comment.body, '/style') + name: style + # macos is actually better here due to native binary packages + runs-on: macos-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@v2 + - name: Configure Git identity + run: | + env | sort + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + shell: bash + - name: Install dependencies + run: | + install.packages(c("styler", "roxygen2"), type = "binary") + shell: Rscript {0} + - name: Style + run: | + styler::style_pkg(strict = FALSE) + shell: Rscript {0} + - name: commit + run: | + if [ -n "$(git status --porcelain '*.R' '*.Rmd')" ]; then + git add '*.R' '*.Rmd' + git commit -m 'Style' + fi + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + merge: + if: startsWith(github.event.comment.body, '/merge') + name: merge + runs-on: ubuntu-22.04 + steps: + - name: Create and merge pull request + run: | + set -exo pipefail + PR_DETAILS=$( curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} ) + echo "$PR_DETAILS" | jq . + PR_BASE=$(echo "$PR_DETAILS" | jq -r .base.ref) + PR_HEAD=$(echo "$PR_DETAILS" | jq -r .head.ref) + PR_URL=$(curl -s -X POST --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --data '{ "head": "'$PR_BASE'", "base": "'$PR_HEAD'", "title": "Merge back PR target branch", "body": "Target: #${{ github.event.issue.number }}" }' https://api.github.com/repos/${{ github.repository }}/pulls | jq -r .url ) + echo $PR_URL + # Merging here won't run CI/CD + # curl -s -X PUT --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $PR_URL/merge + # A mock job just to ensure we have a successful build status + finish: + runs-on: ubuntu-22.04 + steps: + - run: true diff --git a/.github/workflows/revdep.yaml b/.github/workflows/revdep.yaml new file mode 100644 index 0000000000..0fa67dce86 --- /dev/null +++ b/.github/workflows/revdep.yaml @@ -0,0 +1,213 @@ +# This workflow creates many jobs, run only when a branch is created +on: + push: + branches: + - "revdep*" # never run automatically on main branch + +name: revdep + +jobs: + matrix: + runs-on: ubuntu-22.04 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + + name: Collect revdeps + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + # prevent rgl issues because no X11 display is available + RGL_USE_NULL: true + # Begin custom: env vars + # End custom: env vars + + steps: + - name: Check rate limits + run: | + curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit + shell: bash + + - uses: actions/checkout@v4 + + # FIXME: Avoid reissuing succesful jobs + # https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-jobs-for-a-workflow-run + # https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflow-runs + - id: set-matrix + run: | + package <- read.dcf("DESCRIPTION")[, "Package"][[1]] + deps <- tools:::package_dependencies(package, reverse = TRUE, which = c("Depends", "Imports", "LinkingTo", "Suggests"))[[1]] + json <- paste0( + '{"package":[', + paste0('"', deps, '"', collapse = ","), + ']}' + ) + writeLines(json) + writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT")) + shell: Rscript {0} + + check-matrix: + runs-on: ubuntu-22.04 + needs: matrix + steps: + - name: Install json2yaml + run: | + sudo npm install -g json2yaml + + - name: Check matrix definition + run: | + matrix='${{ needs.matrix.outputs.matrix }}' + echo $matrix + echo $matrix | jq . + echo $matrix | json2yaml + + R-CMD-check: + needs: matrix + + runs-on: ubuntu-22.04 + + name: 'revdep: ${{ matrix.package }}' + + # Begin custom: services + # End custom: services + + strategy: + fail-fast: false + matrix: ${{fromJson(needs.matrix.outputs.matrix)}} + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + # prevent rgl issues because no X11 display is available + RGL_USE_NULL: true + # Begin custom: env vars + # End custom: env vars + + steps: + - name: Check rate limits + run: | + curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit + shell: bash + + - uses: actions/checkout@v4 + + # Begin custom: before install + # End custom: before install + + - name: Use RSPM + run: | + mkdir -p /home/runner/work/_temp/Library + echo 'local({release <- system2("lsb_release", "-sc", stdout = TRUE); options(repos=c(CRAN = paste0("https://packagemanager.rstudio.com/all/__linux__/", release, "/latest")), HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version$platform, R.version$arch, R.version$os)))}); .libPaths("/home/runner/work/_temp/Library")' | sudo tee /etc/R/Rprofile.site + + - name: Install remotes + run: | + if (!requireNamespace("curl", quietly = TRUE)) install.packages("curl") + if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes") + shell: Rscript {0} + + - uses: r-lib/actions/setup-pandoc@v2 + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + sudo apt-get update -y + Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "22.04")); package <- "${{ matrix.package }}"; deps <- tools::package_dependencies(package, which = "Suggests")[[1]]; lapply(c(package, deps), function(x) { writeLines(remotes::system_requirements("ubuntu", "22.04", package = x)) })' | sort | uniq > .github/deps.sh + cat .github/deps.sh + sudo sh < .github/deps.sh + + - name: Install package + run: | + package <- "${{ matrix.package }}" + install.packages(package, dependencies = TRUE) + remotes::install_cran("rcmdcheck") + shell: Rscript {0} + + - name: Session info old + run: | + options(width = 100) + if (!requireNamespace("sessioninfo", quietly = TRUE)) install.packages("sessioninfo") + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + # Begin custom: after install + # End custom: after install + + - name: Check old + env: + _R_CHECK_CRAN_INCOMING_: false + _R_CHECK_SYSTEM_CLOCK_: false + _R_CHECK_FUTURE_FILE_TIMESTAMPS_: false + # Avoid downloading binary package from RSPM + run: | + package <- "${{ matrix.package }}" + options(HTTPUserAgent = "gha") + path <- download.packages(package, destdir = ".github")[, 2] + print(path) + + dir <- file.path("revdep", package) + dir.create(dir, showWarnings = FALSE, recursive = TRUE) + check <- rcmdcheck::rcmdcheck(path, args = c("--no-manual", "--as-cran"), error_on = "never", check_dir = file.path(dir, "check")) + file.rename(file.path(dir, "check"), file.path(dir, "old")) + saveRDS(check, file.path(dir, "old.rds")) + shell: Rscript {0} + + - name: Install local package + run: | + remotes::install_local(".", force = TRUE) + shell: Rscript {0} + + - name: Session info new + run: | + options(width = 100) + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + - name: Check new + env: + _R_CHECK_CRAN_INCOMING_: false + _R_CHECK_SYSTEM_CLOCK_: false + _R_CHECK_FUTURE_FILE_TIMESTAMPS_: false + run: | + package <- "${{ matrix.package }}" + path <- dir(".github", pattern = paste0("^", package), full.names = TRUE)[[1]] + print(path) + + dir <- file.path("revdep", package) + check <- rcmdcheck::rcmdcheck(path, args = c("--no-manual", "--as-cran"), error_on = "never", check_dir = file.path(dir, "check")) + file.rename(file.path(dir, "check"), file.path(dir, "new")) + saveRDS(check, file.path(dir, "new.rds")) + shell: Rscript {0} + + - name: Compare + run: | + package <- "${{ matrix.package }}" + dir <- file.path("revdep", package) + old <- readRDS(file.path(dir, "old.rds")) + new <- readRDS(file.path(dir, "new.rds")) + compare <- rcmdcheck::compare_checks(old, new) + compare + cmp <- compare$cmp + if (!identical(cmp[cmp$which == "old", "output"], cmp[cmp$which == "new", "output"])) { + if (!requireNamespace("waldo", quietly = TRUE)) install.packages("waldo") + print(waldo::compare(old, new)) + + stop("Check output differs.") + } + shell: Rscript {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ matrix.package }}-results + path: revdep/${{ matrix.package }} + + - name: Check rate limits + if: always() + run: | + curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit + shell: bash diff --git a/.github/workflows/style/action.yml b/.github/workflows/style/action.yml index b209d9efb5..6b40c0a408 100644 --- a/.github/workflows/style/action.yml +++ b/.github/workflows/style/action.yml @@ -15,7 +15,7 @@ runs: echo rmd=$rmd >> $GITHUB_OUTPUT shell: bash - - uses: actions/cache@v3 + - uses: actions/cache@v4 if: ${{ steps.check.outputs.scope }} with: path: | diff --git a/.github/workflows/update-snapshots/action.yml b/.github/workflows/update-snapshots/action.yml index 2e1db0e3cc..5ee7e3ecc5 100644 --- a/.github/workflows/update-snapshots/action.yml +++ b/.github/workflows/update-snapshots/action.yml @@ -3,6 +3,11 @@ description: > This action will run `testthat::test_local()` for tests that seem to use snapshots, this is determined by reading and grepping the test files. If the tests are failing, snapshots are updated, and a pull request is opened. +inputs: + base: + description: "The base branch to create the pull request against." + required: false + default: "main" runs: using: "composite" @@ -65,12 +70,12 @@ runs: - name: Create pull request if: ${{ steps.check-changed.outputs.changed }} id: cpr - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 with: - base: ${{ github.head_ref }} - branch: snapshot-${{ github.ref_name }}-${{ github.job }}-${{ steps.matrix-desc.outputs.branch }} + base: ${{ inputs.base }} + branch: snapshot-${{ inputs.base }}-${{ github.job }}-${{ steps.matrix-desc.outputs.branch }} delete-branch: true - title: Snapshot updates for ${{ github.job }} (${{ steps.matrix-desc.outputs.text }}) + title: "test: Snapshot updates for ${{ github.job }} (${{ steps.matrix-desc.outputs.text }})" body: "Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action${{ github.event.number && format(' for #{0}', github.event.number) || '' }}." add-paths: | tests/testthat/_snaps diff --git a/.github/workflows/versions-matrix/action.R b/.github/workflows/versions-matrix/action.R new file mode 100644 index 0000000000..b8e2dcfb1d --- /dev/null +++ b/.github/workflows/versions-matrix/action.R @@ -0,0 +1,60 @@ +# Determine active versions of R to test against +tags <- xml2::read_html("https://svn.r-project.org/R/tags/") + +bullets <- + tags |> + xml2::xml_find_all("//li") |> + xml2::xml_text() + +version_bullets <- grep("^R-([0-9]+-[0-9]+-[0-9]+)/$", bullets, value = TRUE) +versions <- unique(gsub("^R-([0-9]+)-([0-9]+)-[0-9]+/$", "\\1.\\2", version_bullets)) + +r_release <- head(sort(as.package_version(versions), decreasing = TRUE), 5) + +deps <- desc::desc_get_deps() +r_crit <- deps$version[deps$package == "R"] +if (length(r_crit) == 1) { + min_r <- as.package_version(gsub("^>= ([0-9]+[.][0-9]+)(?:.*)$", "\\1", r_crit)) + r_release <- r_release[r_release >= min_r] +} + +r_versions <- c("devel", as.character(r_release)) + +macos <- data.frame(os = "macos-latest", r = r_versions[2:3]) +windows <- data.frame(os = "windows-latest", r = r_versions[1:3]) +linux_devel <- data.frame(os = "ubuntu-22.04", r = r_versions[1], `http-user-agent` = "release", check.names = FALSE) +linux <- data.frame(os = "ubuntu-22.04", r = r_versions[-1]) +covr <- data.frame(os = "ubuntu-22.04", r = r_versions[2], covr = "true", desc = "with covr") + +include_list <- list(macos, windows, linux_devel, linux, covr) + +if (file.exists(".github/versions-matrix.R")) { + custom <- source(".github/versions-matrix.R")$value + include_list <- c(include_list, list(custom)) +} + +print(include_list) + +filter <- read.dcf("DESCRIPTION")[1,]["Config/gha/filter"] +if (!is.na(filter)) { + filter_expr <- parse(text = filter)[[1]] + subset_fun_expr <- bquote(function(x) subset(x, .(filter_expr))) + subset_fun <- eval(subset_fun_expr) + include_list <- lapply(include_list, subset_fun) + print(include_list) +} + +to_json <- function(x) { + if (nrow(x) == 0) return(character()) + parallel <- vector("list", length(x)) + for (i in seq_along(x)) { + parallel[[i]] <- paste0('"', names(x)[[i]], '":"', x[[i]], '"') + } + paste0("{", do.call(paste, c(parallel, sep = ",")), "}") +} + +configs <- unlist(lapply(include_list, to_json)) +json <- paste0('{"include":[', paste(configs, collapse = ","), ']}') + +writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT")) +writeLines(json) diff --git a/.github/workflows/versions-matrix/action.yml b/.github/workflows/versions-matrix/action.yml new file mode 100644 index 0000000000..af7378a1bd --- /dev/null +++ b/.github/workflows/versions-matrix/action.yml @@ -0,0 +1,19 @@ +name: "Actions to compute a matrix with all R and OS versions" + +outputs: + matrix: + description: "Generated matrix" + value: ${{ steps.set-matrix.outputs.matrix }} + +runs: + using: "composite" + steps: + - name: Install json2yaml + run: | + sudo npm install -g json2yaml + shell: bash + + - id: set-matrix + run: | + Rscript ./.github/workflows/versions-matrix/action.R + shell: bash diff --git a/DESCRIPTION b/DESCRIPTION index d66999eb98..b9c8b96eaa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -72,5 +72,5 @@ Config/testthat/start-first: vs-es, scan, vs-operators, weakref, watts.strogatz.game Encoding: UTF-8 Roxygen: list(markdown = TRUE, roclets = c("collate", "rd", "namespace", "igraph.r2cdocs::cdocs_roclet", "devtag::dev_roclet"), packages = "igraph.r2cdocs") -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.2.9000 SystemRequirements: libxml2 (optional), glpk (>= 4.57, optional) diff --git a/R/palette.R b/R/palette.R index f6c080917d..cae91257fb 100644 --- a/R/palette.R +++ b/R/palette.R @@ -82,7 +82,7 @@ categorical_pal <- function(n) { #' #' @family palettes #' @export -#' @examplesIf rlang::is_installed("igraphdata") +#' @examplesIf rlang::is_installed(c("igraphdata", "scales")) #' library(igraphdata) #' data(karate) #' karate <- karate %>% @@ -139,7 +139,7 @@ sequential_pal <- function(n) { #' #' @family palettes #' @export -#' @examplesIf rlang::is_installed("igraphdata") +#' @examplesIf rlang::is_installed(c("igraphdata", "scales")) #' library(igraphdata) #' data(foodwebs) #' fw <- foodwebs[[1]] %>% diff --git a/man/as_directed.Rd b/man/as_directed.Rd index 73c9e213a5..e8a1ee31ba 100644 --- a/man/as_directed.Rd +++ b/man/as_directed.Rd @@ -77,7 +77,7 @@ g3 <- make_ring(10, directed = TRUE, mutual = TRUE) E(g3)$weight <- seq_len(ecount(g3)) ug3 <- as_undirected(g3) print(ug3, e = TRUE) -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} x11(width = 10, height = 5) layout(rbind(1:2)) plot(g3, layout = layout_in_circle, edge.label = E(g3)$weight) diff --git a/man/as_graphnel.Rd b/man/as_graphnel.Rd index 6575a54cbe..96650d6746 100644 --- a/man/as_graphnel.Rd +++ b/man/as_graphnel.Rd @@ -25,7 +25,7 @@ vertex names in the graphNEL graph. Otherwise numeric igraph vertex ids will be used for this purpose. } \examples{ -\dontshow{if (rlang::is_installed("graph")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed("graph")) withAutoprint(\{ # examplesIf} ## Undirected g <- make_ring(10) V(g)$name <- letters[1:10] diff --git a/man/diverging_pal.Rd b/man/diverging_pal.Rd index 2dfdd6c350..0457d31356 100644 --- a/man/diverging_pal.Rd +++ b/man/diverging_pal.Rd @@ -24,7 +24,7 @@ Use this palette, if you have such a quantity to mark with vertex colors. } \examples{ -\dontshow{if (rlang::is_installed("igraphdata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed(c("igraphdata", "scales"))) withAutoprint(\{ # examplesIf} library(igraphdata) data(foodwebs) fw <- foodwebs[[1]] \%>\% diff --git a/man/fit_hrg.Rd b/man/fit_hrg.Rd index 51c385d4e7..29b1cb4b3c 100644 --- a/man/fit_hrg.Rd +++ b/man/fit_hrg.Rd @@ -48,7 +48,7 @@ from a given HRG, if this is given in the \code{hrg()} argument and the \code{as.hclust()} provided in this package. } \examples{ -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} ## A graph with two dense groups g <- sample_gnp(10, p = 1 / 2) + sample_gnp(10, p = 1 / 2) diff --git a/man/graph_from_graphnel.Rd b/man/graph_from_graphnel.Rd index d812659128..ef7b6d0f1e 100644 --- a/man/graph_from_graphnel.Rd +++ b/man/graph_from_graphnel.Rd @@ -39,7 +39,7 @@ attributes of the multiple edges are lost: they are all replaced by the attributes of the first of the multiple edges. } \examples{ -\dontshow{if (rlang::is_installed("graph")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed("graph")) withAutoprint(\{ # examplesIf} ## Undirected g <- make_ring(10) V(g)$name <- letters[1:10] diff --git a/man/layout_in_circle.Rd b/man/layout_in_circle.Rd index 2a8615f48a..d510125956 100644 --- a/man/layout_in_circle.Rd +++ b/man/layout_in_circle.Rd @@ -29,7 +29,7 @@ If you want to order the vertices differently, then permute them using the \code{\link[=permute]{permute()}} function. } \examples{ -\dontshow{if (igraph:::has_glpk() && rlang::is_installed("igraphdata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (igraph:::has_glpk() && rlang::is_installed("igraphdata")) withAutoprint(\{ # examplesIf} ## Place vertices on a circle, order them according to their ## community diff --git a/man/predict_edges.Rd b/man/predict_edges.Rd index b2c92ca5b7..0c16c20bbb 100644 --- a/man/predict_edges.Rd +++ b/man/predict_edges.Rd @@ -47,7 +47,7 @@ argument is set to \code{TRUE}. Otherwise a HRG is fitted to the graph first. } \examples{ -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} ## A graph with two dense groups g <- sample_gnp(10, p = 1 / 2) + sample_gnp(10, p = 1 / 2) diff --git a/man/sample_degseq.Rd b/man/sample_degseq.Rd index 65454dafd8..8000211b9d 100644 --- a/man/sample_degseq.Rd +++ b/man/sample_degseq.Rd @@ -123,7 +123,7 @@ exp_vl_graph <- sample_degseq(exponential_degrees, method = "vl") all(degree(exp_vl_graph) == exponential_degrees) ## An example that does not work -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} ## withr::with_seed(11, { ## exponential_degrees <- sample(1:100, 100, replace = TRUE, prob = exp(-0.5 * (1:100))) ## }) @@ -168,7 +168,7 @@ powerlaw_vl_graph <- sample_degseq(powerlaw_degrees, method = "vl") all(degree(powerlaw_vl_graph) == powerlaw_degrees) ## An example that does not work -\dontshow{if (rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_interactive()) withAutoprint(\{ # examplesIf} ## withr::with_seed(2, { ## powerlaw_degrees <- sample(1:100, 100, replace = TRUE, prob = (1:100)^-2) ## }) diff --git a/man/sample_pref.Rd b/man/sample_pref.Rd index 0564fe08ef..2b1140ec00 100644 --- a/man/sample_pref.Rd +++ b/man/sample_pref.Rd @@ -85,7 +85,7 @@ The types of the generated vertices can be retrieved from the pf <- matrix(c(1, 0, 0, 1), nrow = 2) g <- sample_pref(20, 2, pref.matrix = pf) -\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) withAutoprint(\{ # examplesIf} # example code tkplot(g, layout = layout_with_fr) @@ -93,7 +93,7 @@ tkplot(g, layout = layout_with_fr) pf <- matrix(c(0, 1, 0, 0), nrow = 2) g <- sample_asym_pref(20, 2, pref.matrix = pf) -\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) withAutoprint(\{ # examplesIf} tkplot(g, layout = layout_in_circle) \dontshow{\}) # examplesIf} } diff --git a/man/sequential_pal.Rd b/man/sequential_pal.Rd index e5b898516e..bbe3514c4e 100644 --- a/man/sequential_pal.Rd +++ b/man/sequential_pal.Rd @@ -23,7 +23,7 @@ centrality measure, or some ordinal vertex covariate, like the age of people, or their seniority level. } \examples{ -\dontshow{if (rlang::is_installed("igraphdata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (rlang::is_installed(c("igraphdata", "scales"))) withAutoprint(\{ # examplesIf} library(igraphdata) data(karate) karate <- karate \%>\% diff --git a/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index 5e321077ca..7392eb68d7 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -176,7 +176,7 @@ [1] 0 $options$numreo - [1] 6 + [1] 5