Skip to content

Commit

Permalink
Update os values to macos-latest, ubuntu-latest, and `windows-lat…
Browse files Browse the repository at this point in the history
…est` (#276)

* Update os values to `macos-latest`, `ubuntu-latest`, and `windows-latest`

The windows change is a no-op.

As of this commit...
* Ubuntu is migrating from 20 -> 22
* macos is migrating from 12 -> 14

* Allow for `.github` to be ok for PR testing

* Allow for github folder alterations to test all apps

* Move Rscript commands below installing R

* Temp use macos-13 for r-version 4.0

* Typo

* Remove unused variables
  • Loading branch information
schloerke authored Dec 6, 2024
1 parent b672fa2 commit 82e9fb0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 42 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/apps-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ on:
# NOTE: Update badges and table in README when changing runner OS versions
macos:
description: macos OS value
value: "macos-12"
# https://github.com/rstudio/shiny-workflows/blob/fdfacec40c723210c92a287dcb67cdf7f5d621ef/.github/workflows/R-CMD-check.yaml#L23
value: "macos-latest"
windows:
description: windows OS value
value: "windows-2022"
value: "windows-latest"
ubuntu:
description: ubuntu OS value
value: "ubuntu-20.04"
value: "ubuntu-latest"
cache-version:
description: cache-version to be used when pulling library cache
value: "5"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/apps-test-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ jobs:
uses: ./.github/workflows/apps-test-os.yml
with:
r-version: ${{ needs.config.outputs.oldrel4 }}
os: ${{ needs.config.outputs.macos }}
os: macos-13
# TODO-future: Use config below when the oldrel4 r-version is >= 4.1
# os: ${{ needs.config.outputs.macos }}
cache-version: ${{ needs.config.outputs.cache-version }}

ubuntu-release:
Expand Down
76 changes: 38 additions & 38 deletions .github/workflows/apps-test-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,6 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Short R version, SHA, and OS
id: short
shell: bash
run: |
# keep only the major.minor values
RVERSION=`echo '${{ inputs.r-version }}' | sed 's/\([0-9]\.[0-9]\).*/\1/'`
echo "r-version: $RVERSION"
echo "r-version=$RVERSION" >> $GITHUB_OUTPUT
SHA="${{github.event.pull_request.head.sha}}${{ github.sha }}"
if [[ -z "$SHA" ]]; then
SHA="${{ github.sha }}"
fi
SHORT_SHA="${SHA:0:7}"
echo "sha: $SHORT_SHA"
echo "sha=$SHORT_SHA" >> $GITHUB_OUTPUT
OS=`Rscript -e 'cat(sessionInfo()$running, "\n", sep = "")'`
echo "os-version=$OS" >> $GITHUB_OUTPUT
# The `github.sha` value is the commit sha as if the PR was merged. :-(
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-event-pull_request
# Checking for the pull request sha and then pasting it to the possibly 'merged' sha. If main branch, only the `.sha` exists. If a PR, the PR sha exists.
# Either way, take the first 7 characters.
# Found `github.event.pull_request.head.sha` example here: https://github.com/actions/checkout/commit/cab31617d857bf9e70dc35fd9e4dafe350794082#diff-04c6e90faac2675aa89e2176d2eec7d8R92
# The webhook payload example (equivalent to `github.event.pull_request`) shows the keys `head > sha` : https://developer.github.com/v3/activity/events/types/#pullrequestevent
- name: Create failure branch name
id: failed_branch
shell: Rscript {0}
run: |
cat("name=", '${{ steps.short.outputs.sha }}', '${{ inputs.extra-key }}', '-', format(Sys.time(), '%Y_%m_%d_%H_%M'), "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
- name: Create GHA branch name (i.e., test run identifier)
id: gha_branch
shell: Rscript {0}
run: |
cat("name=gha-", '${{ steps.failed_branch.outputs.name }}', '-', '${{ steps.short.outputs.r-version }}', '-', '${{ runner.os }}', "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
- name: Windows git setup
if: runner.os == 'Windows'
run: git config --global core.autocrlf false
Expand Down Expand Up @@ -131,6 +94,40 @@ jobs:
pandoc-version: ${{ inputs.pandoc-version }}
extra-packages: ${{ inputs.extra-packages }}

- name: Short R version, SHA, and OS
id: short
shell: bash
run: |
# keep only the major.minor values
RVERSION=`echo '${{ inputs.r-version }}' | sed 's/\([0-9]\.[0-9]\).*/\1/'`
echo "r-version: $RVERSION"
echo "r-version=$RVERSION" >> $GITHUB_OUTPUT
SHA="${{github.event.pull_request.head.sha}}${{ github.sha }}"
if [[ -z "$SHA" ]]; then
SHA="${{ github.sha }}"
fi
SHORT_SHA="${SHA:0:7}"
echo "sha: $SHORT_SHA"
echo "sha=$SHORT_SHA" >> $GITHUB_OUTPUT
# The `github.sha` value is the commit sha as if the PR was merged. :-(
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-event-pull_request
# Checking for the pull request sha and then pasting it to the possibly 'merged' sha. If main branch, only the `.sha` exists. If a PR, the PR sha exists.
# Either way, take the first 7 characters.
# Found `github.event.pull_request.head.sha` example here: https://github.com/actions/checkout/commit/cab31617d857bf9e70dc35fd9e4dafe350794082#diff-04c6e90faac2675aa89e2176d2eec7d8R92
# The webhook payload example (equivalent to `github.event.pull_request`) shows the keys `head > sha` : https://developer.github.com/v3/activity/events/types/#pullrequestevent
- name: Create failure branch name
id: failed_branch
shell: Rscript {0}
run: |
cat("name=", '${{ steps.short.outputs.sha }}', '${{ inputs.extra-key }}', '-', format(Sys.time(), '%Y_%m_%d_%H_%M'), "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
- name: Create GHA branch name (i.e., test run identifier)
id: gha_branch
shell: Rscript {0}
run: |
cat("name=gha-", '${{ steps.failed_branch.outputs.name }}', '-', '${{ steps.short.outputs.r-version }}', '-', '${{ runner.os }}', "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
# Install packages as necessary!
- name: Run tests
timeout-minutes: 180 # 3 hrs
Expand All @@ -147,14 +144,17 @@ jobs:
if (is_pull_request) {
# reduce apps to only changed apps
files_changed <- jsonlite::parse_json('${{ steps.files_changed.outputs.added_modified }}', simplifyVector = TRUE)
has_altered_github <- any(unlist(lapply(strsplit(files_changed, "/"), function(folder_components) { folder_components[[1]] == ".github" })))
changed_app_folders <-
Filter(strsplit(files_changed, "/"), f = function(item) {
length(item) >= 3 &&
identical(item[[2]], "apps") &&
dir.exists(file.path(item[[1]], item[[2]], item[[3]]))
})
unique_changed_apps <- unique(unlist(lapply(changed_app_folders, `[[`, 3)))
if (length(unique_changed_apps) > 10) {
if (has_altered_github) {
message("Altered `.github` folder. Testing all apps!")
} else if (length(unique_changed_apps) > 10) {
message("More than ten apps were altered. Testing all apps!")
} else if (length(changed_app_folders) > 250) {
message("More than 250 app files were altered. Testing all apps!")
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/apps-test-precheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
for FIL in ${FILES_CHANGED[@]}; do
echo "Inspecting file: '$FIL'"
# check if path is in apps
if [[ "$FIL" =~ ^".github" ]]; then
echo '.github folder was altered. Returning early'
exit 0
fi
if [[ "$FIL" =~ ^"inst/apps" ]]; then
SUBFIL=$(echo "$FIL" | cut -d/ -f 1-2)
echo "first two folders of file: '$SUBFIL'"
Expand Down

0 comments on commit 82e9fb0

Please sign in to comment.