-
Notifications
You must be signed in to change notification settings - Fork 54
209 lines (183 loc) · 8.63 KB
/
R-CMD-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
on:
push:
branches-ignore:
- updateREADME
pull_request:
branches:
- master
workflow_dispatch: # Allow manual triggers
schedule:
- cron: '0 8 * * 4'
name: R-CMD-check.yml
jobs:
## pre-job to determine if a job has been run for the same SHA (e.g. on a different branch)
gatekeeper:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
versions:
needs: gatekeeper
if: (github.event_name == 'schedule' && github.repository == 'mixOmicsTeam/mixOmics') || (github.event_name != 'schedule' && (needs.gatekeeper.outputs.should_skip == 'false') && !contains(github.event.head_commit.message, 'worksave') && !contains(github.event.head_commit.message, 'skip-ci'))
runs-on: ubuntu-latest
outputs:
r: ${{ steps.setup.outputs.r }}
bioc: ${{ steps.setup.outputs.bioc }}
dockerise: ${{ steps.setup.outputs.dockerise }}
docker_tag: ${{ steps.setup.outputs.docker_tag }}
steps:
- uses: rlespinasse/github-slug-action@v3.x
- uses: r-lib/actions/setup-r@v2
- name: Get R/Bioc versions
id: setup
run: |
BRANCH_NAME="${{ env.GITHUB_REF_SLUG }}"
## R and Bioc versions
Rscript -e "install.packages('BiocManager', Ncpus=2)"
r_devel=$(Rscript -e "vm=BiocManager:::.version_map(); cat(as.character(vm[vm\$BiocStatus == 'devel',]\$R))")
r_release=$(Rscript -e "vm=BiocManager:::.version_map(); cat(as.character(vm[vm\$BiocStatus == 'release',]\$R))")
if [[ $BRANCH_NAME =~ "release_" ]]
then
bioc="latest"
r="$r_release"
else
bioc="3.20"
r="$r_release"
## bioc="devel" comment this out for now as bioc version 3.21 requires r version 4.5, but also doesnt seem to like 'release' or 'devel' as arg here
## r="$r_devel" comment this out for now as R version 4.5 doesn't exist so fails on build
fi
echo "r=$r" >> $GITHUB_OUTPUT
echo "bioc=$bioc" >> $GITHUB_OUTPUT
## Docker
# Only Dockerise for 'master' or 'RELEASE_*' branches
dockerise='false'
[[ github.event_name != 'schedule' && ($BRANCH_NAME == "master" || $BRANCH_NAME =~ "release_") ]] && dockerise='true'
echo "dockerise=$dockerise" >> $GITHUB_OUTPUT
# Docker tag is 'github' for master and the branch name for release branches
docker_tag="github"
[[ $BRANCH_NAME =~ "release_" ]] && docker_tag=$BRANCH_NAME
echo "docker_tag=$docker_tag" >> $GITHUB_OUTPUT
R-CMD-check:
needs: [gatekeeper, versions]
## run scheduled jobs only on main repo - do not run a duplicate job for merges etc. Do not run if commit messages include any of 'worksave' or 'skip-ci'
if: (github.event_name == 'schedule' && github.repository == 'mixOmicsTeam/mixOmics') || (github.event_name != 'schedule' && (needs.gatekeeper.outputs.should_skip == 'false') && !contains(github.event.head_commit.message, 'worksave') && !contains(github.event.head_commit.message, 'skip-ci'))
runs-on: ${{ matrix.config.os }}
container: ${{ matrix.config.image }}
name: ${{ matrix.config.os }} (r_${{ matrix.config.r }} - bioc_${{ matrix.config.bioc }} - image_${{ matrix.config.image }})
strategy:
fail-fast: false
matrix:
config:
- { os: windows-latest, r: '${{ needs.versions.outputs.r }}', bioc: '${{ needs.versions.outputs.bioc }}'}
- { os: macOS-latest, r: '${{ needs.versions.outputs.r }}', bioc: '${{ needs.versions.outputs.bioc }}'}
- { os: ubuntu-latest, r: '${{ needs.versions.outputs.r }}', bioc: '${{ needs.versions.outputs.bioc }}', image: 'bioconductor/bioconductor_docker:${{ needs.versions.outputs.bioc }}'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
CRAN: ${{ matrix.config.cran }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out repo ⬇️
uses: actions/checkout@v2
- name: Set up R ▶️
uses: r-lib/actions/setup-r@v2
if: matrix.config.image == null
with:
r-version: ${{ matrix.config.r }}
- name: Create slug/short variables
uses: rlespinasse/github-slug-action@v3.x
- name: Install remotes 🔭
run: |
install.packages('remotes', Ncpus=2)
shell: Rscript {0}
- name: Set BiocManager version 📆
if: matrix.config.image == null
run: |
install.packages('BiocManager', Ncpus=2)
BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE, Ncpus=2)
shell: Rscript {0}
- name: Query dependencies ❓
run: |
saveRDS(remotes::dev_package_deps(dependencies = TRUE, repos = c(getOption('repos'), BiocManager::repositories())), 'depends.Rds', version = 2)
shell: Rscript {0}
- name: Cache R packages 💾
if: runner.os != 'Windows' && matrix.config.image == null
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-bioc-${{ matrix.config.bioc }}-${{ hashFiles('depends.Rds') }}
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-bioc-${{ matrix.config.bioc }}-
- name: Install system and package dependencies using github action 🔧
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-repositories: 'https://cloud.r-project.org'
- name: Install extra dependencies for macOS
if: runner.os == 'macOS'
run: |
brew install --cask xquartz
brew install gcc
- name: Install extra dependencies for linux
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
sudo apt-get update
sudo apt-get install -y qpdf
- name: Install R dependencies 🔨
run: |
options(repos = c(CRAN = "https://cran.r-project.org"))
remotes::install_deps(dependencies = TRUE, repos = BiocManager::repositories(), Ncpus=2)
remotes::install_cran("rcmdcheck", Ncpus=2)
remotes::install_cran("covr", Ncpus=2)
shell: Rscript {0}
- name: Session info 🖥️
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}
# runs rmdcheck, first runs 'devtools::install to make sure there is a copy of mixOmics the parallel workers can access'
- name: Check ✅
if: (!contains(github.event.head_commit.message, 'skip-check'))
run: |
remotes::install_cran("devtools", Ncpus=2)
devtools::install()
devtools::check(args = c("--no-manual"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
- name: BiocCheck 🧬 ✅
if: (!contains(github.event.head_commit.message, 'skip-check'))
run: |
BiocManager::install("BiocCheck", Ncpus=2)
BiocCheck::BiocCheck(".")
shell: Rscript {0}
- name: Check --as-cran ✅ ✅
if: (github.event_name == 'schedule' && github.repository == 'mixOmicsTeam/mixOmics') || (github.event_name == 'workflow_dispatch' && github.repository == 'mixOmicsTeam/mixOmics')
env:
_R_CHECK_CRAN_INCOMING_: false
run: |
options(devtools.check.dir = "check/asCRAN", devtools.check.warning = "never")
devtools::check(args = c("--no-manual", "--as-cran", "--ignore-vignettes", "--run-dontrun"), build_args = c("--no-build-vignettes"))
shell: Rscript {0}
- name: Upload check results ⬆️
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
- name: Show testthat output 📖
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
- name: Push to DockerHub 📦
if: runner.os == 'Linux' && needs.versions.outputs.dockerise == 'true' && !contains(github.event.head_commit.message, 'skip-docker')
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: mixomicsteam/mixomics
tags: ${{ needs.versions.outputs.docker_tag }}
build_args: BIOC_VERSION=${{ needs.versions.outputs.bioc }}