Skip to content

Commit 82e9fb0

Browse files
authored
Update os values to macos-latest, ubuntu-latest, and windows-latest (#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
1 parent b672fa2 commit 82e9fb0

File tree

4 files changed

+49
-42
lines changed

4 files changed

+49
-42
lines changed

.github/workflows/apps-config.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ on:
99
# NOTE: Update badges and table in README when changing runner OS versions
1010
macos:
1111
description: macos OS value
12-
value: "macos-12"
12+
# https://github.com/rstudio/shiny-workflows/blob/fdfacec40c723210c92a287dcb67cdf7f5d621ef/.github/workflows/R-CMD-check.yaml#L23
13+
value: "macos-latest"
1314
windows:
1415
description: windows OS value
15-
value: "windows-2022"
16+
value: "windows-latest"
1617
ubuntu:
1718
description: ubuntu OS value
18-
value: "ubuntu-20.04"
19+
value: "ubuntu-latest"
1920
cache-version:
2021
description: cache-version to be used when pulling library cache
2122
value: "5"

.github/workflows/apps-test-matrix.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ jobs:
5858
uses: ./.github/workflows/apps-test-os.yml
5959
with:
6060
r-version: ${{ needs.config.outputs.oldrel4 }}
61-
os: ${{ needs.config.outputs.macos }}
61+
os: macos-13
62+
# TODO-future: Use config below when the oldrel4 r-version is >= 4.1
63+
# os: ${{ needs.config.outputs.macos }}
6264
cache-version: ${{ needs.config.outputs.cache-version }}
6365

6466
ubuntu-release:

.github/workflows/apps-test-os.yml

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -47,43 +47,6 @@ jobs:
4747
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
4848

4949
steps:
50-
- name: Short R version, SHA, and OS
51-
id: short
52-
shell: bash
53-
run: |
54-
# keep only the major.minor values
55-
RVERSION=`echo '${{ inputs.r-version }}' | sed 's/\([0-9]\.[0-9]\).*/\1/'`
56-
echo "r-version: $RVERSION"
57-
echo "r-version=$RVERSION" >> $GITHUB_OUTPUT
58-
59-
SHA="${{github.event.pull_request.head.sha}}${{ github.sha }}"
60-
if [[ -z "$SHA" ]]; then
61-
SHA="${{ github.sha }}"
62-
fi
63-
SHORT_SHA="${SHA:0:7}"
64-
echo "sha: $SHORT_SHA"
65-
echo "sha=$SHORT_SHA" >> $GITHUB_OUTPUT
66-
67-
OS=`Rscript -e 'cat(sessionInfo()$running, "\n", sep = "")'`
68-
echo "os-version=$OS" >> $GITHUB_OUTPUT
69-
70-
# The `github.sha` value is the commit sha as if the PR was merged. :-(
71-
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-event-pull_request
72-
# 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.
73-
# Either way, take the first 7 characters.
74-
# Found `github.event.pull_request.head.sha` example here: https://github.com/actions/checkout/commit/cab31617d857bf9e70dc35fd9e4dafe350794082#diff-04c6e90faac2675aa89e2176d2eec7d8R92
75-
# The webhook payload example (equivalent to `github.event.pull_request`) shows the keys `head > sha` : https://developer.github.com/v3/activity/events/types/#pullrequestevent
76-
- name: Create failure branch name
77-
id: failed_branch
78-
shell: Rscript {0}
79-
run: |
80-
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)
81-
- name: Create GHA branch name (i.e., test run identifier)
82-
id: gha_branch
83-
shell: Rscript {0}
84-
run: |
85-
cat("name=gha-", '${{ steps.failed_branch.outputs.name }}', '-', '${{ steps.short.outputs.r-version }}', '-', '${{ runner.os }}', "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
86-
8750
- name: Windows git setup
8851
if: runner.os == 'Windows'
8952
run: git config --global core.autocrlf false
@@ -131,6 +94,40 @@ jobs:
13194
pandoc-version: ${{ inputs.pandoc-version }}
13295
extra-packages: ${{ inputs.extra-packages }}
13396

97+
- name: Short R version, SHA, and OS
98+
id: short
99+
shell: bash
100+
run: |
101+
# keep only the major.minor values
102+
RVERSION=`echo '${{ inputs.r-version }}' | sed 's/\([0-9]\.[0-9]\).*/\1/'`
103+
echo "r-version: $RVERSION"
104+
echo "r-version=$RVERSION" >> $GITHUB_OUTPUT
105+
106+
SHA="${{github.event.pull_request.head.sha}}${{ github.sha }}"
107+
if [[ -z "$SHA" ]]; then
108+
SHA="${{ github.sha }}"
109+
fi
110+
SHORT_SHA="${SHA:0:7}"
111+
echo "sha: $SHORT_SHA"
112+
echo "sha=$SHORT_SHA" >> $GITHUB_OUTPUT
113+
114+
# The `github.sha` value is the commit sha as if the PR was merged. :-(
115+
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-event-pull_request
116+
# 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.
117+
# Either way, take the first 7 characters.
118+
# Found `github.event.pull_request.head.sha` example here: https://github.com/actions/checkout/commit/cab31617d857bf9e70dc35fd9e4dafe350794082#diff-04c6e90faac2675aa89e2176d2eec7d8R92
119+
# The webhook payload example (equivalent to `github.event.pull_request`) shows the keys `head > sha` : https://developer.github.com/v3/activity/events/types/#pullrequestevent
120+
- name: Create failure branch name
121+
id: failed_branch
122+
shell: Rscript {0}
123+
run: |
124+
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)
125+
- name: Create GHA branch name (i.e., test run identifier)
126+
id: gha_branch
127+
shell: Rscript {0}
128+
run: |
129+
cat("name=gha-", '${{ steps.failed_branch.outputs.name }}', '-', '${{ steps.short.outputs.r-version }}', '-', '${{ runner.os }}', "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
130+
134131
# Install packages as necessary!
135132
- name: Run tests
136133
timeout-minutes: 180 # 3 hrs
@@ -147,14 +144,17 @@ jobs:
147144
if (is_pull_request) {
148145
# reduce apps to only changed apps
149146
files_changed <- jsonlite::parse_json('${{ steps.files_changed.outputs.added_modified }}', simplifyVector = TRUE)
147+
has_altered_github <- any(unlist(lapply(strsplit(files_changed, "/"), function(folder_components) { folder_components[[1]] == ".github" })))
150148
changed_app_folders <-
151149
Filter(strsplit(files_changed, "/"), f = function(item) {
152150
length(item) >= 3 &&
153151
identical(item[[2]], "apps") &&
154152
dir.exists(file.path(item[[1]], item[[2]], item[[3]]))
155153
})
156154
unique_changed_apps <- unique(unlist(lapply(changed_app_folders, `[[`, 3)))
157-
if (length(unique_changed_apps) > 10) {
155+
if (has_altered_github) {
156+
message("Altered `.github` folder. Testing all apps!")
157+
} else if (length(unique_changed_apps) > 10) {
158158
message("More than ten apps were altered. Testing all apps!")
159159
} else if (length(changed_app_folders) > 250) {
160160
message("More than 250 app files were altered. Testing all apps!")

.github/workflows/apps-test-precheck.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ jobs:
3535
for FIL in ${FILES_CHANGED[@]}; do
3636
echo "Inspecting file: '$FIL'"
3737
# check if path is in apps
38+
if [[ "$FIL" =~ ^".github" ]]; then
39+
echo '.github folder was altered. Returning early'
40+
exit 0
41+
fi
3842
if [[ "$FIL" =~ ^"inst/apps" ]]; then
3943
SUBFIL=$(echo "$FIL" | cut -d/ -f 1-2)
4044
echo "first two folders of file: '$SUBFIL'"

0 commit comments

Comments
 (0)