85
85
# source flair_env/bin/activate
86
86
# R CMD build --no-build-vignettes .
87
87
# shell: bash
88
+ # name: R-MacOS
89
+ #
90
+ # on:
91
+ # push:
92
+ # branches: [ "main" ]
93
+ # pull_request:
94
+ # branches: [ "main" ]
95
+ #
96
+ # permissions:
97
+ # contents: read
98
+ #
99
+ # jobs:
100
+ # build:
101
+ # runs-on: macos-latest
102
+ # strategy:
103
+ # matrix:
104
+ # r-version: ['4.4.0', '4.3.2']
105
+ # fail-fast: false
106
+ #
107
+ # steps:
108
+ # - uses: actions/checkout@v3
109
+ #
110
+ # - name: Update Homebrew
111
+ # run: brew update
112
+ #
113
+ # - name: Install pandoc
114
+ # run: |
115
+ # for i in {1..3}
116
+ # do
117
+ # brew install pandoc && break || sleep 15
118
+ # done
119
+ #
120
+ # - name: Install gfortran and configure Makevars
121
+ # run: |
122
+ # brew install gcc
123
+ # mkdir -p ~/.R
124
+ # touch ~/.R/Makevars
125
+ # echo "FC=$(brew --prefix)/bin/gfortran" >> ~/.R/Makevars
126
+ # echo "F77=$(brew --prefix)/bin/gfortran" >> ~/.R/Makevars
127
+ # echo "FLIBS=-L$(brew --prefix)/lib/gcc/current -lgfortran -lquadmath -lm" >> ~/.R/Makevars
128
+ # echo "LDFLAGS=-L$(brew --prefix)/lib/gcc/current" >> ~/.R/Makevars
129
+ #
130
+ # - name: Set up R ${{ matrix.r-version }}
131
+ # uses: r-lib/actions/setup-r@v2
132
+ # with:
133
+ # r-version: ${{ matrix.r-version }}
134
+ #
135
+ # - name: Install R dependencies
136
+ # run: |
137
+ # # 基礎包安裝
138
+ # Rscript -e 'install.packages(c("remotes", "rcmdcheck", "reticulate", "renv", "knitr", "rmarkdown", "lsa", "purrr", "testthat"), repos="https://cran.r-project.org")'
139
+ #
140
+ # # 根據 R 版本有條件地安裝 Matrix
141
+ # Rscript -e '
142
+ # if (getRversion() >= "4.4.0") {
143
+ # install.packages("Matrix")
144
+ # } else {
145
+ # remotes::install_version("Matrix", version = "1.5.1", repos = "https://cran.r-project.org")
146
+ # }
147
+ # '
148
+ #
149
+ # # 安裝指定版本的 htmltools
150
+ # Rscript -e 'remotes::install_version("htmltools", version = "0.5.8")'
151
+ #
152
+ # # 最後執行 renv::restore()
153
+ # Rscript -e 'renv::restore()'
154
+ #
155
+ # - name: Set up Python
156
+ # uses: actions/setup-python@v2
157
+ # with:
158
+ # python-version: '3.10.x'
159
+ #
160
+ # - name: Install Python virtualenv
161
+ # run: pip install virtualenv
162
+ #
163
+ # - name: Create Python virtual environment
164
+ # run: virtualenv flair_env
165
+ #
166
+ # - name: Install Python dependencies in virtual environment
167
+ # run: |
168
+ # source flair_env/bin/activate
169
+ # pip install --upgrade pip
170
+ # pip install scipy==1.12.0
171
+ # pip install flair
172
+ #
173
+ # - name: Remove Python cache files
174
+ # run: find . -name '*.pyc' -delete
175
+ #
176
+ # - name: Check (with virtual environment)
177
+ # run: |
178
+ # source flair_env/bin/activate
179
+ # R CMD build --no-build-vignettes .
180
+ # shell: bash
181
+
182
+
88
183
name : R-MacOS
89
184
90
185
on :
@@ -101,7 +196,7 @@ jobs:
101
196
runs-on : macos-latest
102
197
strategy :
103
198
matrix :
104
- r-version : ['4.4.0', '4.3.2']
199
+ r-version : ['4.4.0', '4.2.3'] # 改為 4.2.3
105
200
fail-fast : false
106
201
107
202
steps :
@@ -134,28 +229,49 @@ jobs:
134
229
135
230
- name : Install R dependencies
136
231
run : |
137
- # 基礎包安裝
138
- Rscript -e 'install.packages(c("remotes", "rcmdcheck", "reticulate", "renv", "knitr", "rmarkdown", "lsa", "purrr", "testthat" ), repos="https://cran.r-project.org")'
232
+ # 首先安裝基礎包
233
+ Rscript -e 'install.packages(c("remotes", "rcmdcheck", "reticulate", "renv"), repos="https://cran.r-project.org")'
139
234
140
- # 根據 R 版本有條件地安裝 Matrix
235
+ # 根據 R 版本安裝相應的 Matrix 版本
141
236
Rscript -e '
142
237
if (getRversion() >= "4.4.0") {
143
- install.packages("Matrix")
238
+ remotes::install_version("Matrix", version = "1.5-3")
239
+ } else if (getRversion() >= "4.2.0" && getRversion() < "4.3.0") {
240
+ remotes::install_version("Matrix", version = "1.4-1")
144
241
} else {
145
- remotes::install_version("Matrix", version = "1.5.1", repos = "https://cran.r-project.org ")
242
+ remotes::install_version("Matrix", version = "1.5-1 ")
146
243
}
147
244
'
148
245
149
- # 安裝指定版本的 htmltools
246
+ # 安裝其他依賴
247
+ Rscript -e 'install.packages(c("knitr", "rmarkdown", "lsa", "purrr", "testthat"), repos="https://cran.r-project.org")'
248
+
249
+ # 安裝特定版本的 htmltools
150
250
Rscript -e 'remotes::install_version("htmltools", version = "0.5.8")'
151
251
152
- # 最後執行 renv::restore()
153
- Rscript -e 'renv::restore()'
252
+ # renv 相關操作
253
+ Rscript -e '
254
+ tryCatch({
255
+ renv::restore()
256
+ }, error = function(e) {
257
+ message("Error in renv::restore(): ", e$message)
258
+ if (!requireNamespace("Matrix", quietly = TRUE)) {
259
+ if (getRversion() >= "4.4.0") {
260
+ install.packages("Matrix")
261
+ } else if (getRversion() >= "4.2.0" && getRversion() < "4.3.0") {
262
+ remotes::install_version("Matrix", version = "1.4-1")
263
+ } else {
264
+ remotes::install_version("Matrix", version = "1.5-1")
265
+ }
266
+ }
267
+ })
268
+ '
154
269
155
270
- name : Set up Python
156
- uses : actions/setup-python@v2
271
+ uses : actions/setup-python@v4 # 更新到 v4
157
272
with :
158
273
python-version : ' 3.10.x'
274
+ cache : ' pip'
159
275
160
276
- name : Install Python virtualenv
161
277
run : pip install virtualenv
@@ -169,12 +285,14 @@ jobs:
169
285
pip install --upgrade pip
170
286
pip install scipy==1.12.0
171
287
pip install flair
288
+ deactivate
172
289
173
290
- name : Remove Python cache files
174
291
run : find . -name '*.pyc' -delete
175
292
176
293
- name : Check (with virtual environment)
177
294
run : |
178
295
source flair_env/bin/activate
296
+ set -e
179
297
R CMD build --no-build-vignettes .
180
298
shell : bash
0 commit comments