Skip to content

Commit

Permalink
ci: Rethink versions matrix, store in file
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jun 26, 2024
1 parent 9635815 commit 7e44911
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 50 deletions.
25 changes: 4 additions & 21 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 @@ -139,27 +142,7 @@ jobs:
use-public-rspm: true

- id: set-matrix
uses: ./.github/workflows/versions-matrix

check-versions-matrix:
runs-on: ubuntu-22.04
needs: versions-matrix

name: Check versions deps

if: ${{ needs.versions-matrix.outputs.matrix != '' }}

steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml
- name: Check matrix definition
run: |
matrix='${{ needs.versions-matrix.outputs.matrix }}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml
uses: ./.github/workflows/versions-matrix-read

rcc-full:
needs:
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
13 changes: 13 additions & 0 deletions .github/workflows/versions-matrix-read/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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:
- id: set-matrix
run: |
echo matrix=$(cat .github/versions-matrix.json || echo '[]') >> $GITHUB_OUTPUT
shell: bash
25 changes: 1 addition & 24 deletions .github/workflows/versions-matrix/action.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
# - {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

# 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])
Expand Down Expand Up @@ -51,7 +30,5 @@ to_json <- function(x) {
configs <- unlist(lapply(include_list, to_json))
json <- paste0('{"include":[', paste(configs, collapse = ","), ']}')

if (Sys.getenv("GITHUB_OUTPUT") != "") {
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
}
writeLines(json, ".github/version-matrix.json")
writeLines(json)
4 changes: 0 additions & 4 deletions .github/workflows/versions-matrix/action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
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"
Expand Down

0 comments on commit 7e44911

Please sign in to comment.