From acdb551db86f75118fc54cf98e69b09045e4dce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 25 Jun 2024 20:56:24 +0200 Subject: [PATCH] Dynamic version matrix --- .github/workflows/R-CMD-check.yaml | 74 +++++++++----------- .github/workflows/versions-matrix/action.yml | 15 ++++ 2 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/versions-matrix/action.yml diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 921c120..20431df 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/versions-matrix/action.yml b/.github/workflows/versions-matrix/action.yml new file mode 100644 index 0000000..d091895 --- /dev/null +++ b/.github/workflows/versions-matrix/action.yml @@ -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}