Skip to content

Commit

Permalink
ci: Recent updates
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jun 27, 2024
1 parent 4df00e5 commit 8c528c7
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ jobs:

- uses: ./.github/workflows/check
with:
results: ${{ matrix.package }}
results: ${{ matrix.package }}
106 changes: 34 additions & 72 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
34 changes: 34 additions & 0 deletions .github/workflows/update-status/action.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .github/workflows/versions-matrix-read/action.yml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions .github/workflows/versions-matrix/action.R
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions .github/workflows/versions-matrix/action.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8c528c7

Please sign in to comment.