From 946e9746d6b7d28d76f10cfe887b92ae15f6f297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 27 Jun 2024 00:09:12 +0200 Subject: [PATCH] ci: Recent updates --- .github/workflows/R-CMD-check-dev.yaml | 2 +- .github/workflows/R-CMD-check.yaml | 106 ++++++------------ .github/workflows/commit/action.yml | 2 +- .github/workflows/install/action.yml | 25 +++++ .github/workflows/update-status/action.yml | 34 ++++++ .../workflows/versions-matrix-read/action.yml | 21 ++++ .github/workflows/versions-matrix/action.R | 34 ++++++ .github/workflows/versions-matrix/action.yml | 9 ++ 8 files changed, 159 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/update-status/action.yml create mode 100644 .github/workflows/versions-matrix-read/action.yml create mode 100644 .github/workflows/versions-matrix/action.R create mode 100644 .github/workflows/versions-matrix/action.yml diff --git a/.github/workflows/R-CMD-check-dev.yaml b/.github/workflows/R-CMD-check-dev.yaml index 23c4a6b..9b00903 100644 --- a/.github/workflows/R-CMD-check-dev.yaml +++ b/.github/workflows/R-CMD-check-dev.yaml @@ -147,4 +147,4 @@ jobs: - uses: ./.github/workflows/check with: - results: ${{ matrix.package }} + results: ${{ matrix.package }} \ No newline at end of file diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 921c120..baf5c56 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -56,6 +56,9 @@ jobs: - uses: ./.github/workflows/custom/after-install if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' + - uses: ./.github/workflows/versions-matrix + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + - uses: ./.github/workflows/update-snapshots if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository @@ -117,91 +120,45 @@ jobs: - uses: ./.github/workflows/pkgdown-deploy if: github.event_name == 'push' - # Windows checks can be run in parallel and independently - # when they alone take as long as the smoke and full tests combined. - # To achieve this, remove the "needs:" element below. - rcc-windows: - # Begin custom: early run - needs: rcc-smoke - # End custom: early run - - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) ${{ matrix.config.desc }} - - # Begin custom: services - # End custom: services + versions-matrix: + runs-on: ubuntu-22.04 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} - strategy: - fail-fast: false - matrix: - config: - - {os: windows-latest, r: 'release'} - # Use 3.6 to trigger usage of RTools35 - - {os: windows-latest, r: '3.6'} + name: Collect versions 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') != '' + fetch-depth: 0 - - uses: ./.github/workflows/install + - uses: ./.github/workflows/rate-limit with: - r-version: ${{ matrix.config.r }} - cache-version: rcc-windows-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 + - uses: r-lib/actions/setup-r@v2 with: - results: ${{ runner.os }}-r${{ matrix.config.r }} + install-r: false + use-public-rspm: true + + - id: set-matrix + uses: ./.github/workflows/versions-matrix-read rcc-full: - needs: rcc-smoke + needs: + - rcc-smoke + - versions-matrix - runs-on: ${{ matrix.config.os }} + runs-on: ${{ matrix.os }} - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) ${{ matrix.config.desc }} + name: ${{ matrix.os }} (${{ matrix.r }}) ${{ matrix.desc }} # Begin custom: services # End custom: services strategy: fail-fast: false - matrix: - config: - - {os: macos-latest, r: 'release'} - - - {os: ubuntu-20.04, r: 'release'} - - # Use older ubuntu to maximise backward compatibility - - {os: ubuntu-22.04, r: 'devel', http-user-agent: 'release'} - - {os: ubuntu-22.04, r: 'release', covr: true, desc: 'with covr'} - - {os: ubuntu-22.04, r: 'oldrel-1'} - - # Begin custom: R 3.6 - - {os: ubuntu-22.04, r: 'oldrel-2'} - # End custom: R 3.6 - - # Begin custom: R 3.5 - - {os: ubuntu-22.04, r: 'oldrel-3'} - # End custom: R 3.5 - - # Begin custom: R 3.4 - - {os: ubuntu-22.04, r: 'oldrel-4'} - # End custom: R 3.4 - - # Begin custom: matrix elements - # End custom: matrix elements + matrix: ${{fromJson(needs.versions-matrix.outputs.matrix)}} steps: - uses: actions/checkout@v4 @@ -213,7 +170,7 @@ jobs: - uses: ./.github/workflows/install with: - r-version: ${{ matrix.config.r }} + r-version: ${{ matrix.r }} cache-version: rcc-full-1 token: ${{ secrets.GITHUB_TOKEN }} needs: check @@ -226,7 +183,12 @@ jobs: - uses: ./.github/workflows/check with: - results: ${{ runner.os }}-r${{ matrix.config.r }} + results: ${{ runner.os }}-r${{ matrix.r }} + + - uses: ./.github/workflows/update-status + if: always() + with: + sha: ${{ needs.rcc-smoke.outputs.sha }} suggests-matrix: runs-on: ubuntu-22.04 @@ -252,13 +214,13 @@ jobs: - id: set-matrix uses: ./.github/workflows/dep-matrix-suggests - check-matrix: + check-suggests-matrix: runs-on: ubuntu-22.04 needs: suggests-matrix - name: Check deps + name: Check suggests deps - if: ${{ needs.matrix.outputs.matrix != '' }} + if: ${{ needs.suggests-matrix.outputs.matrix != '' }} steps: - name: Install json2yaml @@ -267,15 +229,15 @@ jobs: - name: Check matrix definition run: | - matrix='${{ needs.matrix.outputs.matrix }}' + matrix='${{ needs.suggests-matrix.outputs.matrix }}' echo $matrix echo $matrix | jq . echo $matrix | json2yaml rcc-suggests: needs: - - suggests-matrix - rcc-smoke + - suggests-matrix runs-on: ubuntu-22.04 diff --git a/.github/workflows/commit/action.yml b/.github/workflows/commit/action.yml index 89be422..bd375d3 100644 --- a/.github/workflows/commit/action.yml +++ b/.github/workflows/commit/action.yml @@ -22,7 +22,7 @@ runs: git stash pop 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 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 echo sha=$(git rev-parse HEAD) >> $GITHUB_OUTPUT fi diff --git a/.github/workflows/install/action.yml b/.github/workflows/install/action.yml index cf83bdb..449cd8c 100644 --- a/.github/workflows/install/action.yml +++ b/.github/workflows/install/action.yml @@ -39,12 +39,32 @@ runs: echo "_R_CHECK_FUTURE_FILE_TIMESTAMPS_=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_BASHISMS_=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 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 - uses: r-lib/actions/setup-pandoc@v2 @@ -115,3 +135,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/update-status/action.yml b/.github/workflows/update-status/action.yml new file mode 100644 index 0000000..1c66320 --- /dev/null +++ b/.github/workflows/update-status/action.yml @@ -0,0 +1,34 @@ +name: 'Update status' +description: 'Update status' +inputs: + sha: + description: 'SHA to update' + required: true + state: + description: 'state to update' + required: true + +runs: + using: "composite" + steps: + # It's difficult to get the URL of the current job. + # The /jobs API and/or the `github` context are misaligned. + # The duckdbneo repository contains several failed attempts. + - run: | + set -x + if [ -n '${{ inputs.sha }}' ]; then + export GH_TOKEN=${{ github.token }} + + 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) + + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/statuses/${{ inputs.sha }} \ + -f "state=${{ job.status }}" -f "target_url=$html_url" -f "description=${{ github.workflow }} / ${{ github.job }}" -f "context=actions-sync" + fi + shell: bash diff --git a/.github/workflows/versions-matrix-read/action.yml b/.github/workflows/versions-matrix-read/action.yml new file mode 100644 index 0000000..3e20f1d --- /dev/null +++ b/.github/workflows/versions-matrix-read/action.yml @@ -0,0 +1,21 @@ +name: "Actions to read a matrix with all R and OS versions, computed with the versions-matrix action" +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: | + matrix=$(cat .github/versions-matrix.json || echo '{"include":[]}') + echo $matrix | jq . + echo $matrix | json2yaml + echo "matrix=$matrix" | tee -a $GITHUB_OUTPUT + shell: bash diff --git a/.github/workflows/versions-matrix/action.R b/.github/workflows/versions-matrix/action.R new file mode 100644 index 0000000..bbcc71a --- /dev/null +++ b/.github/workflows/versions-matrix/action.R @@ -0,0 +1,34 @@ +# FIXME: Dynamic lookup by parsing https://svn.r-project.org/R/tags/ +r_versions <- c("devel", paste0("4.", 4:0)) +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) +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(json, ".github/versions-matrix.json") +writeLines(json) diff --git a/.github/workflows/versions-matrix/action.yml b/.github/workflows/versions-matrix/action.yml new file mode 100644 index 0000000..6ac164b --- /dev/null +++ b/.github/workflows/versions-matrix/action.yml @@ -0,0 +1,9 @@ +name: "Actions to compute a matrix with all R and OS versions" + +runs: + using: "composite" + steps: + - id: set-matrix + run: | + Rscript ./.github/workflows/versions-matrix/action.R + shell: bash