Skip to content

Commit

Permalink
Dynamic version matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jun 25, 2024
1 parent ccabf55 commit acdb551
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 39 deletions.
74 changes: 35 additions & 39 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,53 +117,49 @@ 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: r-lib/actions/setup-r@v2
with:
install-r: false
use-public-rspm: true

- uses: ./.github/workflows/update-snapshots
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
- id: set-matrix
uses: ./.github/workflows/versions-matrix

- uses: ./.github/workflows/check
with:
results: ${{ runner.os }}-r${{ matrix.config.r }}
check-versions-matrix:
runs-on: ubuntu-22.04
needs: versions-matrix

name: Check 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
rcc-full:
needs: rcc-smoke
Expand Down Expand Up @@ -252,13 +248,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

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

steps:
- name: Install json2yaml
Expand All @@ -267,7 +263,7 @@ 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
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/versions-matrix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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:
- id: set-matrix
run: |
json <- '[{os: macos-latest, r: "release"}, {os: ubuntu-20.04, r: "release"}, {os: ubuntu-22.04, r: "devel", http-user-agent: "release"}]'
writeLines(json)
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
shell: Rscript {0}

0 comments on commit acdb551

Please sign in to comment.