├── .Rbuildignore ├── .gitattributes ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── Makefile ├── NAMESPACE ├── R ├── RcppExports.R └── fakepackage.r ├── README.md ├── appveyor.yml ├── data └── x.rda ├── fakepackage.Rproj ├── inst └── doc │ ├── test.R │ ├── test.Rmd │ └── test.html ├── man ├── MASS_huber.Rd ├── is_three.Rd ├── three.Rd └── x.Rd ├── r-travis ├── .travis.yml ├── ISSUE_TEMPLATE.md ├── LICENSE.txt ├── README.md ├── fakepackage │ ├── DESCRIPTION │ ├── NAMESPACE │ ├── R │ │ └── fakepackage.r │ ├── inst │ │ └── tests │ │ │ └── test-fakepackage.r │ ├── man │ │ └── fakepackage.Rd │ └── tests │ │ └── test-all.R ├── git-hooks │ ├── README.md │ └── pre-commit ├── sample.travis.yml ├── sample_revdeps.travis.yml └── scripts │ ├── create-osx.sh │ ├── dropbox.sh │ └── travis-tool.sh ├── sample.appveyor.yml ├── scripts └── appveyor-tool.ps1 ├── src ├── .gitignore ├── RcppExports.cpp └── hello.cpp ├── tests ├── test-all.R └── testthat │ └── test-fakepackage.r └── vignettes └── test.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^appveyor\.yml$ 2 | ^README\.md$ 3 | ^sample\.appveyor\.yml$ 4 | ^scripts$ 5 | ^Makefile$ 6 | ^.*\.Rproj$ 7 | ^\.Rproj\.user$ 8 | ^\.travis\.yml$ 9 | ^r-travis$ 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | data/* binary 3 | src/* text=lf 4 | R/* text=lf 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: r 4 | cache: packages 5 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: fakepackage 2 | Title: Test package for r-travis (http://github.com/craigcitro/r-travis) 3 | Version: 0.1 4 | Author: Craig Citro 5 | Maintainer: Craig Citro 6 | Depends: 7 | R (>= 3.0.1) 8 | License: Apache License (== 2.0) 9 | Description: This is just a fake package allowing me to use travis to check my 10 | package to make it easier to use travis. 11 | Imports: 12 | assertthat, 13 | MASS, 14 | Rcpp 15 | Suggests: 16 | testthat, 17 | knitr, 18 | rmarkdown 19 | VignetteBuilder: knitr 20 | LinkingTo: Rcpp 21 | RoxygenNote: 7.1.2 22 | Encoding: UTF-8 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: test-failure 2 | 3 | test-failure: FORCE 4 | git merge-into $$(git branch | grep "[*]" | cut -d " " -f 2)-fail --no-edit 5 | git push $$(git branch | grep "[*]" | cut -d " " -f 2)-fail 6 | 7 | FORCE: 8 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(is_three) 4 | export(three) 5 | import(MASS) 6 | import(assertthat) 7 | importFrom(Rcpp,sourceCpp) 8 | useDynLib(fakepackage, .registration = TRUE) 9 | -------------------------------------------------------------------------------- /R/RcppExports.R: -------------------------------------------------------------------------------- 1 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | hello <- function(a) { 5 | .Call(`_fakepackage_hello`, a) 6 | } 7 | 8 | -------------------------------------------------------------------------------- /R/fakepackage.r: -------------------------------------------------------------------------------- 1 | #' Returns 3. 2 | #' @export 3 | three <- function() { 4 | 3 5 | } 6 | 7 | #' Check to see if our argument is three. 8 | #' @param x Argument to check 9 | #' @import assertthat 10 | #' @export 11 | is_three <- function(x) { 12 | see_if(are_equal(3, x)) 13 | } 14 | 15 | #' Use something from MASS 16 | #' @import MASS 17 | MASS_huber <- function() MASS::huber 18 | 19 | #' @useDynLib fakepackage, .registration = TRUE 20 | #' @importFrom Rcpp sourceCpp 21 | NULL 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # R + AppVeyor [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/krlmlr/r-appveyor?branch=master&svg=true)](https://ci.appveyor.com/project/krlmlr/r-appveyor/branch/master) [![Travis-CI Build Status](https://travis-ci.org/krlmlr/r-appveyor.svg?branch=master)](https://travis-ci.org/krlmlr/r-appveyor) 2 | 3 | This is a solution for continuous integration for R projects on Windows, using [AppVeyor](http://appveyor.com) -- a CI testing service similar to [Travis-CI](http://travis-ci.org). 4 | Under the hood, [r-travis](https://github.com/craigcitro/r-travis) is used to perform the testing; this works even on Windows thanks to [MinGW and MSYS](http://www.mingw.org/). 5 | 6 | 7 | Usage 8 | ----- 9 | 10 | 1. Sign up to [AppVeyor](http://appveyor.com). 11 | 2. [Enable testing](https://ci.appveyor.com/projects/new) for your project. 12 | 3. Run `usethis::use_appveyor()` in your project. 13 | 4. (Optional) Adapt `appveyor.yml` to your needs according to the [documentation](http://www.appveyor.com/docs/appveyor-yml). 14 | 5. (Optional) Add a badge as described by the output of `usethis::use_appveyor()`. 15 | 6. Be sure to supply a `.gitattributes` file that takes care of fixing CRLF conversion settings that are relevant on Windows. [The one in this repo](/.gitattributes) can be used for starters. 16 | 7. Push to your repo to start building. 17 | 8. Enjoy! 18 | 19 | 20 | Build and test commands 21 | ----------------------- 22 | 23 | The `travis-tool` used in `appveyor.yml` is a [modified copy](https://github.com/krlmlr/r-travis) of the r-travis project, documentation is available [on its wiki](https://github.com/craigcitro/r-travis/wiki#configuration-options). 24 | 25 | 26 | 27 | Environment variables 28 | --------------------- 29 | 30 | These can be set in the `appveyor.yml`, overriding the defaults. [This repo](https://github.com/krlmlr/r-appveyor/blob/master/appveyor.yml#L20) tests several configurations at once in a build matrix, see also the [build status](https://ci.appveyor.com/project/krlmlr/r-appveyor/branch/master). 31 | 32 | Example: 33 | ``` 34 | environment: 35 | VARIABLE: value 36 | ``` 37 | 38 | - `R_VERSION`: The version of R to be used for testing. Specify `devel`, `patched`, `stable` (or `release`), `oldrel`, or a version number. 39 | - `R_ARCH`: The architecture to be used for testing, one of `x64` (default) or `i386`. 40 | - `RTOOLS_VERSION`: The version of Rtools to be used for testing, defaults to the most recent Rtools. Specify e.g. `33` for Rtools 3.3. 41 | - `USE_RTOOLS`: Set `USE_RTOOLS: true` (or `USE_RTOOLS: yes`) if Rtools needs to be installed. Defaults to `true` if your package has a `src/` directory and `false` otherwise. Rtools may be needed if you use `install_github()`, if there are packages in `Remotes:` in your `DESCRIPTION` file, or if one of your dependencies has updated, but the associated Windows binary is not yet available from CRAN. (Set `PKGTYPE=binary` to avoid installing packages from source.) 42 | - `GCC_PATH`: The path to GCC in the Rtools installation, currently one of `gcc-4.6.3` (default), `mingw_32` or `mingw_64`. 43 | - `WARNINGS_ARE_ERRORS`: Set to 1 to treat all warnings as errors, otherwise leave empty. 44 | - `CRAN`: The CRAN mirror to use, defaults to [RStudio's CDN via HTTPS](https://cloud.r-project.org). Change to [HTTP](http://cloud.r-project.org) for R 3.1.3 or earlier. 45 | - `R_BUILD_ARGS`: Arguments passed to `R CMD build`, defaults to `--no-manual`. 46 | - `R_CHECK_ARGS`: Arguments passed to `R CMD check`, defaults to `--no-manual --as-cran`. 47 | - `PKGTYPE`: Passed as `type` to `install.packages()`, `remotes::install_github()` and `remotes::install_deps()`. Set to `both` to install packages from source if the source version is more recent than the binary version. 48 | - `NOT_CRAN`: Set this to `true` if you are using [testthat](https://testthat.r-lib.org/) and want to run tests marked with `testthat::skip_on_cran()`. 49 | - `R_REMOTES_STANDALONE`: Set this to `true` if builds are failing due to the inability to update infrastructure packages such as curl, git2r and rlang. Read more in the [docs for the remotes package](https://github.com/r-lib/remotes#standalone-mode). 50 | - `_R_CHECK_FORCE_SUGGESTS_`: Set this to `false` to avoid errors of the form "Package suggested but not available". 51 | - `KEEP_VIGNETTES`: Set this to a nonempty value build vignettes. You will likely need LaTeX and/or Pandoc, see below for installation instructions. By default, all vignettes are purged and the `VignetteBuilder` entry in `DESCRIPTION` is removed. 52 | - `DOWNLOAD_FILE_METHOD`: On some versions of R, setting this to `wininet` appears to work better than the default `auto`. 53 | 54 | 55 | Artifacts 56 | --------- 57 | 58 | In contrast to Travis-CI, AppVeyor offers facilities for hosting artifacts. This can be configured by adding a section to the `appveyor.yml`. The sample file is configured to deploy logs, and source and **binary** versions of the built package. Check the "ARTIFACTS" section for [your project at AppVeyor](https://ci.appveyor.com/projects). 59 | 60 | 61 | LaTeX 62 | ----- 63 | 64 | See [the example contributed by @pat-s](https://github.com/krlmlr/r-appveyor/issues/10#issuecomment-423832887) for a way to install LaTeX. 65 | The [tinytex package](https://yihui.name/tinytex/) is another option. 66 | 67 | Pandoc and other software 68 | ------------------------- 69 | 70 | The [Chocolatey installer](https://chocolatey.org/) is a convenient way to install other software. 71 | See below for a Pandoc example from the [reprex repository](https://github.com/tidyverse/reprex/blob/2d505dd8a5c26366896a33d3a3f6a2c9092786d5/appveyor.yml#L21-L24): 72 | 73 | ```yaml 74 | before_test: 75 | - cinst pandoc 76 | - ps: $env:Path += ";C:\Program Files (x86)\Pandoc\" 77 | - pandoc -v 78 | ``` 79 | 80 | 81 | Troubleshooting 82 | --------------- 83 | 84 | ### Using a 64-bit R installation 85 | 86 | Some R packages, notably `rJava`, require a 64-bit installation of 87 | Windows and R. If you try to install these packages on a 32-bit 88 | system you'll see a message similar to: 89 | ``` 90 | Error: .onLoad failed in loadNamespace() for 'rJava', details: 91 | call: inDL(x, as.logical(local), as.logical(now), ...) 92 | error: unable to load shared object 'C:/Users/appveyor/AppData/Local/Temp/1/RtmpWa3KNC/RLIBS_bdc2913935/rJava/libs/i386/rJava.dll': 93 | LoadLibrary failure: %1 is not a valid Win32 application. 94 | ``` 95 | To solve this problem, add to your `appveyor.yml`: 96 | ``` 97 | platform: x64 98 | 99 | environment: 100 | R_ARCH: x64 101 | ``` 102 | This will cause Appveyor to run your build on a 64-bit version of 103 | Windows Server, using the 64-bit R binary. 104 | 105 | Acknowledgements 106 | ---------------- 107 | 108 | This wouldn't have been as easy without [r-travis](https://github.com/craigcitro/r-travis) and the experience gained there. Thanks! 109 | 110 | 111 | See also 112 | -------- 113 | 114 | The [win-builder project](http://win-builder.r-project.org/) has been around much longer and provides more comprehensive testing; you still might want to use this service before submitting to CRAN. 115 | 116 | 117 | Other branches 118 | -------------- 119 | 120 | [![Build status for expected failure](https://ci.appveyor.com/api/projects/status/github/krlmlr/r-appveyor?branch=master-fail&svg=true)](https://ci.appveyor.com/project/krlmlr/r-appveyor/branch/master-fail) ([`master-fail` branch](https://github.com/krlmlr/r-appveyor/tree/master-fail), failure expected) 121 | 122 | 123 | License 124 | ------- 125 | 126 | MIT © [Kirill Müller](https://github.com/krlmlr). 127 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # DO NOT CHANGE the "init" and "install" sections below 2 | 3 | # Download script file from GitHub 4 | init: 5 | ps: | 6 | Get-Date 7 | $ErrorActionPreference = "Stop" 8 | 9 | install: 10 | ps: | 11 | Import-Module '.\scripts\appveyor-tool.ps1' 12 | Bootstrap 13 | 14 | # Adapt as necessary starting from here 15 | 16 | environment: 17 | global: 18 | R_REMOTES_STANDALONE: true 19 | WARNINGS_ARE_ERRORS: 1 20 | 21 | matrix: 22 | - R_VERSION: devel 23 | GCC_PATH: mingw_32 24 | 25 | - R_VERSION: devel 26 | R_ARCH: x64 27 | GCC_PATH: mingw_64 28 | 29 | - R_VERSION: release 30 | R_ARCH: x64 31 | 32 | - R_VERSION: stable 33 | 34 | - R_VERSION: patched 35 | 36 | - R_VERSION: 3.5.3 37 | RTOOLS_VERSION: 35 38 | 39 | - R_VERSION: 3.4.4 40 | RTOOLS_VERSION: 34 41 | 42 | - R_VERSION: 3.3.3 43 | RTOOLS_VERSION: 33 44 | 45 | - R_VERSION: 3.2.5 46 | RTOOLS_VERSION: 33 47 | 48 | - R_VERSION: 3.2.3 49 | _R_CHECK_FORCE_SUGGESTS_: false 50 | PKGTYPE: source 51 | RTOOLS_VERSION: 33 52 | DOWNLOAD_FILE_METHOD: wininet 53 | 54 | - R_VERSION: 3.2.0 55 | _R_CHECK_FORCE_SUGGESTS_: false 56 | PKGTYPE: source 57 | RTOOLS_VERSION: 32 58 | DOWNLOAD_FILE_METHOD: wininet 59 | 60 | matrix: 61 | fast_finish: true 62 | 63 | build_script: 64 | - travis-tool.sh install_deps 65 | 66 | test_script: 67 | - travis-tool.sh run_tests 68 | 69 | on_failure: 70 | - 7z a failure.zip *.Rcheck\* 71 | - appveyor PushArtifact failure.zip 72 | 73 | artifacts: 74 | - path: '*.Rcheck\**\*.log' 75 | name: Logs 76 | 77 | - path: '*.Rcheck\**\*.out' 78 | name: Logs 79 | 80 | - path: '*.Rcheck\**\*.fail' 81 | name: Logs 82 | 83 | - path: '*.Rcheck\**\*.Rout' 84 | name: Logs 85 | 86 | - path: '\*_*.tar.gz' 87 | name: Bits 88 | 89 | - path: '\*_*.zip' 90 | name: Bits 91 | 92 | notifications: 93 | - provider: Email 94 | to: 95 | - krlmlr+appveyor@mailbox.org 96 | subject: 'r-appveyor build {{status}}' # optional 97 | message: "https://ci.appveyor.com/project/krlmlr/r-appveyor" # optional 98 | on_build_success: false 99 | on_build_failure: true 100 | on_build_status_changed: true 101 | -------------------------------------------------------------------------------- /data/x.rda: -------------------------------------------------------------------------------- 1 | RDA2 2 | A 3 | 2 4 | 196865 5 | 131840 6 | 1026 7 | 1 8 | 262153 9 | 1 10 | x 11 | 14 12 | 1 13 | 42 14 | 254 15 | -------------------------------------------------------------------------------- /fakepackage.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /inst/doc/test.R: -------------------------------------------------------------------------------- 1 | ## ---- fig.show='hold'---------------------------------------------------- 2 | plot(1:10) 3 | plot(10:1) 4 | 5 | ## ---- echo=FALSE, results='asis'----------------------------------------- 6 | knitr::kable(head(mtcars, 10)) 7 | 8 | -------------------------------------------------------------------------------- /inst/doc/test.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Vignette Title" 3 | author: "Vignette Author" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Vignette Title} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The `html_vignette` output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The `html_vignette` format: 13 | 14 | - Never uses retina figures 15 | - Has a smaller default figure size 16 | - Uses a custom CSS stylesheet instead of the default Twitter Bootstrap style 17 | 18 | ## Vignette Info 19 | 20 | Note the various macros within the `vignette` section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the `title` field and the `\VignetteIndexEntry` to match the title of your vignette. 21 | 22 | ## Styles 23 | 24 | The `html_vignette` template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows: 25 | 26 | output: 27 | rmarkdown::html_vignette: 28 | css: mystyles.css 29 | 30 | ## Figures 31 | 32 | The figure sizes have been customised so that you can easily put two images side-by-side. 33 | 34 | ```{r, fig.show='hold'} 35 | plot(1:10) 36 | plot(10:1) 37 | ``` 38 | 39 | You can enable figure captions by `fig_caption: yes` in YAML: 40 | 41 | output: 42 | rmarkdown::html_vignette: 43 | fig_caption: yes 44 | 45 | Then you can use the chunk option `fig.cap = "Your figure caption."` in **knitr**. 46 | 47 | ## More Examples 48 | 49 | You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using `knitr::kable()`. 50 | 51 | ```{r, echo=FALSE, results='asis'} 52 | knitr::kable(head(mtcars, 10)) 53 | ``` 54 | 55 | Also a quote using `>`: 56 | 57 | > "He who gives up [code] safety for [code] speed deserves neither." 58 | ([via](https://twitter.com/hadleywickham/status/504368538874703872)) 59 | -------------------------------------------------------------------------------- /inst/doc/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Vignette Title 18 | 19 | 20 | 21 | 22 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |

Vignette Title

72 |

Vignette Author

73 |

2016-09-07

74 | 75 | 76 | 77 |

Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The html_vignette output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The html_vignette format:

78 | 83 |
84 |

Vignette Info

85 |

Note the various macros within the vignette section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the title field and the \VignetteIndexEntry to match the title of your vignette.

86 |
87 |
88 |

Styles

89 |

The html_vignette template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows:

90 |
output: 
 91 |   rmarkdown::html_vignette:
 92 |     css: mystyles.css
93 |
94 |
95 |

Figures

96 |

The figure sizes have been customised so that you can easily put two images side-by-side.

97 |
plot(1:10)
 98 | plot(10:1)
99 |

100 |

You can enable figure captions by fig_caption: yes in YAML:

101 |
output:
102 |   rmarkdown::html_vignette:
103 |     fig_caption: yes
104 |

Then you can use the chunk option fig.cap = "Your figure caption." in knitr.

105 |
106 |
107 |

More Examples

108 |

You can write math expressions, e.g. \(Y = X\beta + \epsilon\), footnotes1, and tables, e.g. using knitr::kable().

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 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 |
mpgcyldisphpdratwtqsecvsamgearcarb
Mazda RX421.06160.01103.902.62016.460144
Mazda RX4 Wag21.06160.01103.902.87517.020144
Datsun 71022.84108.0933.852.32018.611141
Hornet 4 Drive21.46258.01103.083.21519.441031
Hornet Sportabout18.78360.01753.153.44017.020032
Valiant18.16225.01052.763.46020.221031
Duster 36014.38360.02453.213.57015.840034
Merc 240D24.44146.7623.693.19020.001042
Merc 23022.84140.8953.923.15022.901042
Merc 28019.26167.61233.923.44018.301044
269 |

Also a quote using >:

270 |
271 |

“He who gives up [code] safety for [code] speed deserves neither.” (via)

272 |
273 |
274 |
275 |
276 |
    277 |
  1. A footnote here.

  2. 278 |
279 |
280 | 281 | 282 | 283 | 284 | 292 | 293 | 294 | 295 | -------------------------------------------------------------------------------- /man/MASS_huber.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fakepackage.r 3 | \name{MASS_huber} 4 | \alias{MASS_huber} 5 | \title{Use something from MASS} 6 | \usage{ 7 | MASS_huber() 8 | } 9 | \description{ 10 | Use something from MASS 11 | } 12 | -------------------------------------------------------------------------------- /man/is_three.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fakepackage.r 3 | \name{is_three} 4 | \alias{is_three} 5 | \title{Check to see if our argument is three.} 6 | \usage{ 7 | is_three(x) 8 | } 9 | \arguments{ 10 | \item{x}{Argument to check} 11 | } 12 | \description{ 13 | Check to see if our argument is three. 14 | } 15 | -------------------------------------------------------------------------------- /man/three.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fakepackage.r 3 | \name{three} 4 | \alias{three} 5 | \title{Returns 3.} 6 | \usage{ 7 | three() 8 | } 9 | \description{ 10 | Returns 3. 11 | } 12 | -------------------------------------------------------------------------------- /man/x.Rd: -------------------------------------------------------------------------------- 1 | \docType{data} 2 | \name{x} 3 | \alias{x} 4 | \title{The Answer.} 5 | \format{An integer} 6 | \usage{ 7 | x 8 | } 9 | \description{ 10 | The answer to all questions, now neatly packaged. 11 | } 12 | -------------------------------------------------------------------------------- /r-travis/.travis.yml: -------------------------------------------------------------------------------- 1 | # .travis.yml for r-travis. 2 | # 3 | # If you're looking to use r-travis with your project, DO NOT USE THIS 4 | # FILE -- use `sample.travis.yml` instead. 5 | 6 | language: c 7 | 8 | os: 9 | - linux 10 | - osx 11 | env: 12 | global: 13 | - OS=$(uname -s) 14 | matrix: 15 | - BOOTSTRAP_LATEX=" " 16 | - R_BUILD_ARGS=" " R_CHECK_ARGS="--as-cran" BOOTSTRAP_LATEX="1" _R_CHECK_CRAN_INCOMING_=TRUE BOOTSTRAP_PANDOC="1" 17 | script: ./travis-tool.sh run_tests 18 | notifications: 19 | email: 20 | on_success: change 21 | on_failure: change 22 | before_install: 23 | - cp scripts/travis-tool.sh fakepackage 24 | - cd fakepackage 25 | - ./travis-tool.sh bootstrap 26 | before_script: 27 | - ./travis-tool.sh dump_sysinfo 28 | after_success: 29 | - ./travis-tool.sh dump_logs_by_extension out 30 | after_failure: 31 | - ./travis-tool.sh dump_logs 32 | install: 33 | - ./travis-tool.sh install_deps 34 | # TESTS 35 | # 36 | # The following lines exist to test various features of our travis 37 | # scripts; don't use these as a model for other `.travis.yml` files. 38 | # Test install_aptget with multiple arguments. 39 | # - if test ${OS} = Linux; then test -z "$(which tmux)"; fi 40 | # - if test ${OS} = Linux; then test -z "$(which sponge)"; fi 41 | - if test ${OS} = Linux; then ./travis-tool.sh install_aptget tmux moreutils; fi 42 | # - if test ${OS} = Linux; then test -n "$(which tmux)"; fi 43 | # - if test ${OS} = Linux; then test -n "$(which sponge)"; fi 44 | # Test install_r (which accepts multiple arguments). 45 | - ./travis-tool.sh install_r stringr lubridate 46 | - Rscript -e 'library(stringr); library(lubridate)' 47 | # Test github package installation (which accepts multiple arguments). 48 | #- Rscript -e 'stopifnot(!all(c("selectr", "rvest") %in% rownames(installed.packages())))' 49 | #- ./travis-tool.sh install_github sjp/selectr hadley/rvest 50 | #- Rscript -e 'library(selectr); library(rvest)' 51 | # Test R binary installation. 52 | - if test ${OS} = Linux; then ./travis-tool.sh install_r_binary RUnit survey; fi 53 | - if test ${OS} = Linux; then Rscript -e 'library(RUnit); library(survey)'; fi 54 | - ./travis-tool.sh dump_sysinfo | grep -q 'R version ' 55 | - ./travis-tool.sh bioc_install GenomicFeatures AnnotationDbi 56 | - Rscript -e 'library(GenomicFeatures); library(AnnotationDbi)' 57 | - if test ${BOOTSTRAP_PANDOC} = 1; then pandoc --version; fi 58 | -------------------------------------------------------------------------------- /r-travis/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### **STOP** If your `.travis.yml` is using `language: r` you are not using the code from this project! ### 2 | 3 | You should instead file your issues at https://github.com/travis-ci/travis-ci/issues and mention @craigcitro, @hadley and @jimhester in the issue. 4 | 5 | In either case please use the following template to submit your issue. 6 | 7 | ### Prerequisites 8 | - [ ] Did you search the [r-travis](https://github.com/craigcitro/r-travis/issues?q=is%3Aissue) and [travis-ci](https://github.com/travis-ci/travis-ci/issues?q=is%3Aissue) issues to ensure it has not already been reported? 9 | 10 | ### Description 11 | Provide a detailed description of your issue. 12 | 13 | ### Versions 14 | 15 | Replace the `YOUR_USER` and `YOUR_REPO` parts of the following links with those of your project. 16 | 17 | - [Build Report with Failure](https://travis-ci.org/YOUR_USER/YOUR_REPO#L123) 18 | - [.travis.yml](https://github.com/YOUR_USER/YOUR_REPO/blob/master/.travis.yml) 19 | 20 | cc @craigcitro @hadley @jimhester 21 | -------------------------------------------------------------------------------- /r-travis/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /r-travis/README.md: -------------------------------------------------------------------------------- 1 | # R+Travis 2 | 3 | [![Build Status](https://travis-ci.org/craigcitro/r-travis.svg?branch=master,osx)](https://travis-ci.org/craigcitro/r-travis) 4 | 5 | # NATIVE R SUPPORT IN TRAVIS IS LIVE! 6 | 7 | We've finally merged support based on this repo into Travis-CI, so you can simply use `language: r` to test your R packages! 8 | 9 | * New users should check out [the official Travis-CI R docs](http://docs.travis-ci.com/user/languages/r/) 10 | * Existing users should check out the [porting guide](https://github.com/craigcitro/r-travis/wiki/Porting-to-native-R-support-in-Travis). 11 | 12 | ## Setting up r-travis 13 | 14 | This package has a simple shell script for use in running R package builds on 15 | [travis](http://travis-ci.org/), along with a sample `.travis.yml` file. One 16 | should be able to set up travis for their own project by: 17 | * Copying `sample.travis.yml` to `.travis.yml` in your project. 18 | * Copying `sample_revdeps.travis.yml` to `.travis.yml` in your project will passively check reverse dependencies. 19 | * Adding `.travis.yml` to your `.Rbuildignore`. 20 | * Modifying `.travis.yml` to list any packages that must be installed from 21 | github (instead of CRAN). 22 | * [Turn on travis](https://travis-ci.org/profile) for your project. (Note that 23 | in some cases, it may take time for travis to start watching your repo.) 24 | * Add a 25 | [travis "build status" shield](http://about.travis-ci.org/docs/user/status-images/) 26 | to your `README` file. 27 | 28 | See the [wiki](https://github.com/craigcitro/r-travis/wiki) for more 29 | extensive documentation and examples. 30 | 31 | ## Linux or OS X builds 32 | 33 | By default, builds are done on Linux. That is enabled by choosing 34 | `language: c` in the .travis.yml file. Builds on OS X can be enabled by 35 | choosing `language: objective-c`. See the comments in `sample.travis.yml`. 36 | 37 | Currently, Travis-CI does not support builds that loop over platforms (such as 38 | Linux and OS X) in one build. 39 | 40 | ## The future 41 | 42 | My plan is to ultimately merge this into travis as a first-class citizen, so 43 | that the simplest config would simply say `language: R`. However, I'm using 44 | this repo as a staging ground to make sure I have the kinks worked out first. 45 | The end goal would be for the `.travis.yml` for an R project to be something 46 | as simple as 47 | 48 | language: r 49 | github_packages: 50 | - assertthat 51 | - devtools 52 | -------------------------------------------------------------------------------- /r-travis/fakepackage/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: fakepackage 2 | Title: Test package for r-travis (http://github.com/craigcitro/r-travis) 3 | Version: 0.1 4 | Author: Craig Citro 5 | Maintainer: Craig Citro 6 | Depends: R (>= 3.0.1) 7 | License: Apache License (== 2.0) 8 | Description: This is just a fake package allowing me to use travis to check my 9 | package to make it easier to use travis. 10 | Imports: 11 | assertthat 12 | Suggests: 13 | testthat 14 | Collate: 15 | 'fakepackage.r' 16 | -------------------------------------------------------------------------------- /r-travis/fakepackage/NAMESPACE: -------------------------------------------------------------------------------- 1 | export(is_three) 2 | export(three) 3 | import(assertthat) 4 | -------------------------------------------------------------------------------- /r-travis/fakepackage/R/fakepackage.r: -------------------------------------------------------------------------------- 1 | #' Returns 3. 2 | three <- function() { 3 | 3 4 | } 5 | 6 | #' Check to see if our argument is three. 7 | is_three <- function(x) { 8 | see_if(are_equal(3, x)) 9 | } 10 | -------------------------------------------------------------------------------- /r-travis/fakepackage/inst/tests/test-fakepackage.r: -------------------------------------------------------------------------------- 1 | context("fake") 2 | 3 | test_that("returns 3", { 4 | expect_equal(3, three()) 5 | }) 6 | 7 | test_that("is_three recognizes 3", { 8 | expect_that(is_three(3), is_true()) 9 | expect_that(is_three(5), not(is_true())) 10 | expect_that(is_three(5), is_false()) 11 | }) 12 | -------------------------------------------------------------------------------- /r-travis/fakepackage/man/fakepackage.Rd: -------------------------------------------------------------------------------- 1 | \name{fakepackage} 2 | \alias{three} 3 | \alias{is_three} 4 | 5 | \title{A fake package.} 6 | 7 | \description{This is fake. I'm using it for testing.} 8 | \usage{ 9 | three() 10 | is_three(x) 11 | } 12 | \arguments{ 13 | \item{x}{A value.} 14 | } 15 | \details{ 16 | 17 | \code{three} returns \code{3}. Useful when you need a small, odd 18 | prime. 19 | 20 | \code{is_three} checks if its argument is three. Not for the faint of 21 | heart. 22 | } 23 | -------------------------------------------------------------------------------- /r-travis/fakepackage/tests/test-all.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | test_package("fakepackage") 3 | -------------------------------------------------------------------------------- /r-travis/git-hooks/README.md: -------------------------------------------------------------------------------- 1 | These are hooks I found useful for working on `r-travis`; symlink them into 2 | `$REPO_ROOT/.git/hooks` to use them. 3 | -------------------------------------------------------------------------------- /r-travis/git-hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # -*- mode: sh-mode; -*- 3 | # 4 | # pre-commit hooks for r-travis. 5 | 6 | # validate the two travis yaml files; requires travis-lint: 7 | # http://github.com/travis-ci/travis-lint 8 | 9 | RunTravisLint() { 10 | travis-lint $1 >/dev/null 11 | if [[ "$?" -ne 0 ]]; then 12 | echo "Error running travis-lint on $1:" 13 | travis-lint $1 14 | exit $? 15 | fi 16 | shift 17 | } 18 | 19 | RunTravisLint .travis.yml 20 | RunTravisLint sample.travis.yml 21 | -------------------------------------------------------------------------------- /r-travis/sample.travis.yml: -------------------------------------------------------------------------------- 1 | # Sample .travis.yml for R projects. 2 | # 3 | # See README.md for instructions, or for more configuration options, 4 | # see the wiki: 5 | # https://github.com/craigcitro/r-travis/wiki 6 | 7 | language: c 8 | 9 | before_install: 10 | - curl -OL http://raw.githubusercontent.com/craigcitro/r-travis/master/scripts/travis-tool.sh 11 | - chmod 755 ./travis-tool.sh 12 | - ./travis-tool.sh bootstrap 13 | install: 14 | - ./travis-tool.sh install_deps 15 | script: ./travis-tool.sh run_tests 16 | 17 | after_failure: 18 | - ./travis-tool.sh dump_logs 19 | 20 | notifications: 21 | email: 22 | on_success: change 23 | on_failure: change 24 | -------------------------------------------------------------------------------- /r-travis/sample_revdeps.travis.yml: -------------------------------------------------------------------------------- 1 | # Sample .travis.yml for R projects. 2 | # 3 | # See README.md for instructions, or for more configuration options, 4 | # see the wiki: 5 | # https://github.com/craigcitro/r-travis/wiki 6 | 7 | language: c 8 | 9 | env: 10 | - BOOTSTRAP_LATEX="1" 11 | - BOOTSTRAP_LATEX="1" R_CHECK_REVDEP="1" # checks reverse depends 12 | 13 | 14 | # Create a build matrix that will test a regular check 15 | # and also check the reverse dependencies 16 | matrix: 17 | # http://docs.travis-ci.com/user/build-configuration/#Fast-finishing 18 | # allows the build to "pass" when the non-failure-able builds are done 19 | fast_finish: true 20 | 21 | # http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail 22 | allow_failures: 23 | # allows the revdep build to fail and still "pass" within travis 24 | - env: BOOTSTRAP_LATEX="1" R_CHECK_REVDEP="1" 25 | 26 | 27 | before_install: 28 | - curl -OL http://raw.githubusercontent.com/craigcitro/r-travis/master/scripts/travis-tool.sh 29 | - chmod 755 ./travis-tool.sh 30 | - ./travis-tool.sh bootstrap 31 | install: 32 | - ./travis-tool.sh install_deps 33 | script: ./travis-tool.sh run_tests 34 | 35 | after_failure: 36 | - ./travis-tool.sh dump_logs 37 | 38 | notifications: 39 | email: 40 | on_success: change 41 | on_failure: change 42 | -------------------------------------------------------------------------------- /r-travis/scripts/create-osx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | BRANCH=$(git symbolic-ref HEAD | awk -F/ '{print $3}') 6 | OSX_BRANCH=${OSX_BRANCH:-${BRANCH}-osx} 7 | 8 | if test -n "$(git status --porcelain)"; then 9 | echo "$(basename $0): Working copy not clean. Exiting." 10 | exit 1 11 | fi 12 | 13 | if [[ -n "$(git branch | egrep "^ *$OSX_BRANCH")" ]]; then 14 | git checkout $OSX_BRANCH 15 | if git merge $BRANCH --no-edit; then 16 | git checkout $BRANCH 17 | exit 0 18 | fi 19 | echo "WARNING: Can't merge, falling back to overwriting branch" 20 | git checkout $BRANCH 21 | git branch -D $OSX_BRANCH 22 | fi 23 | 24 | git checkout -b $OSX_BRANCH 25 | sed -i '' -e 's/^language: c/language: objective-c/' .travis.yml 26 | git add .travis.yml 27 | git commit -m "change language to objective-c to test OS X" 28 | git checkout $BRANCH 29 | -------------------------------------------------------------------------------- /r-travis/scripts/dropbox.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Dropbox Uploader 4 | # 5 | # Copyright (C) 2010-2013 Andrea Fabrizi 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | # 21 | 22 | #Default chunk size in Mb for the upload process 23 | #It is recommended to increase this value only if you have enough free space on your /tmp partition 24 | #Lower values may increase the number of http requests 25 | CHUNK_SIZE=4 26 | 27 | #Curl location 28 | #If not set, curl will be searched into the $PATH 29 | #CURL_BIN="/usr/bin/curl" 30 | 31 | #Default values 32 | TMP_DIR="/tmp" 33 | DEBUG=0 34 | QUIET=0 35 | SHOW_PROGRESSBAR=0 36 | SKIP_EXISTING_FILES=0 37 | ERROR_STATUS=0 38 | 39 | #Don't edit these... 40 | API_REQUEST_TOKEN_URL="https://api.dropbox.com/1/oauth/request_token" 41 | API_USER_AUTH_URL="https://www2.dropbox.com/1/oauth/authorize" 42 | API_ACCESS_TOKEN_URL="https://api.dropbox.com/1/oauth/access_token" 43 | API_CHUNKED_UPLOAD_URL="https://api-content.dropbox.com/1/chunked_upload" 44 | API_CHUNKED_UPLOAD_COMMIT_URL="https://api-content.dropbox.com/1/commit_chunked_upload" 45 | API_UPLOAD_URL="https://api-content.dropbox.com/1/files_put" 46 | API_DOWNLOAD_URL="https://api-content.dropbox.com/1/files" 47 | API_DELETE_URL="https://api.dropbox.com/1/fileops/delete" 48 | API_MOVE_URL="https://api.dropbox.com/1/fileops/move" 49 | API_COPY_URL="https://api.dropbox.com/1/fileops/copy" 50 | API_METADATA_URL="https://api.dropbox.com/1/metadata" 51 | API_INFO_URL="https://api.dropbox.com/1/account/info" 52 | API_MKDIR_URL="https://api.dropbox.com/1/fileops/create_folder" 53 | API_SHARES_URL="https://api.dropbox.com/1/shares" 54 | APP_CREATE_URL="https://www2.dropbox.com/developers/apps" 55 | RESPONSE_FILE="$TMP_DIR/du_resp_$RANDOM" 56 | CHUNK_FILE="$TMP_DIR/du_chunk_$RANDOM" 57 | BIN_DEPS="sed basename date grep stat dd printf mkdir" 58 | VERSION="0.12.1" 59 | 60 | umask 077 61 | 62 | #Check the shell 63 | if [ -z "$BASH_VERSION" ]; then 64 | echo -e "Error: this script requires the BASH shell!" 65 | exit 1 66 | fi 67 | 68 | shopt -s nullglob #Bash allows filename patterns which match no files to expand to a null string, rather than themselves 69 | shopt -s dotglob #Bash includes filenames beginning with a "." in the results of filename expansion 70 | 71 | #Look for optional config file parameter 72 | while getopts ":qpskd:" opt; do 73 | case $opt in 74 | 75 | d) 76 | DEBUG=1 77 | ;; 78 | 79 | q) 80 | QUIET=1 81 | ;; 82 | 83 | p) 84 | SHOW_PROGRESSBAR=1 85 | ;; 86 | 87 | k) 88 | CURL_ACCEPT_CERTIFICATES="-k" 89 | ;; 90 | 91 | s) 92 | SKIP_EXISTING_FILES=1 93 | ;; 94 | 95 | \?) 96 | echo "Invalid option: -$OPTARG" >&2 97 | exit 1 98 | ;; 99 | 100 | :) 101 | echo "Option -$OPTARG requires an argument." >&2 102 | exit 1 103 | ;; 104 | 105 | esac 106 | done 107 | 108 | if [[ $DEBUG != 0 ]]; then 109 | set -x 110 | RESPONSE_FILE="$TMP_DIR/du_resp_debug" 111 | fi 112 | 113 | if [[ $CURL_BIN == "" ]]; then 114 | BIN_DEPS="$BIN_DEPS curl" 115 | CURL_BIN="curl" 116 | fi 117 | 118 | #Dependencies check 119 | which $BIN_DEPS > /dev/null 120 | if [[ $? != 0 ]]; then 121 | for i in $BIN_DEPS; do 122 | which $i > /dev/null || 123 | NOT_FOUND="$i $NOT_FOUND" 124 | done 125 | echo -e "Error: Required program could not be found: $NOT_FOUND" 126 | exit 1 127 | fi 128 | 129 | #Check if readlink is installed and supports the -m option 130 | #It's not necessary, so no problem if it's not installed 131 | which readlink > /dev/null 132 | if [[ $? == 0 && $(readlink -m "//test" 2> /dev/null) == "/test" ]]; then 133 | HAVE_READLINK=1 134 | else 135 | HAVE_READLINK=0 136 | fi 137 | 138 | #Print the message based on $QUIET variable 139 | function print 140 | { 141 | if [[ $QUIET == 0 ]]; then 142 | echo -ne "$1"; 143 | fi 144 | } 145 | 146 | #Returns unix timestamp 147 | function utime 148 | { 149 | echo $(date +%s) 150 | } 151 | 152 | #Remove temporary files 153 | function remove_temp_files 154 | { 155 | if [[ $DEBUG == 0 ]]; then 156 | rm -fr "$RESPONSE_FILE" 157 | rm -fr "$CHUNK_FILE" 158 | fi 159 | } 160 | 161 | #Returns the file size in bytes 162 | # generic GNU Linux: linux-gnu 163 | # windows cygwin: cygwin 164 | # raspberry pi: linux-gnueabihf 165 | # macosx: darwin10.0 166 | # freebsd: FreeBSD 167 | # qnap: linux-gnueabi 168 | # iOS: darwin9 169 | function file_size 170 | { 171 | #Some embedded linux devices 172 | if [[ $OSTYPE == "linux-gnueabi" || $OSTYPE == "linux-gnu" ]]; then 173 | stat -c "%s" "$1" 174 | return 175 | 176 | #Generic Unix 177 | elif [[ ${OSTYPE:0:5} == "linux" || $OSTYPE == "cygwin" || ${OSTYPE:0:7} == "solaris" || ${OSTYPE} == "darwin9" ]]; then 178 | stat --format="%s" "$1" 179 | return 180 | 181 | #BSD or others OS 182 | else 183 | stat -f "%z" "$1" 184 | return 185 | fi 186 | } 187 | 188 | #Usage 189 | function usage 190 | { 191 | echo -e "Dropbox Uploader v$VERSION" 192 | echo -e "Andrea Fabrizi - andrea.fabrizi@gmail.com\n" 193 | echo -e "Usage: $0 COMMAND [PARAMETERS]..." 194 | echo -e "\nCommands:" 195 | 196 | echo -e "\t upload [LOCAL_FILE/DIR] " 197 | echo -e "\t download [REMOTE_FILE/DIR] " 198 | echo -e "\t delete [REMOTE_FILE/DIR]" 199 | echo -e "\t move [REMOTE_FILE/DIR] [REMOTE_FILE/DIR]" 200 | echo -e "\t copy [REMOTE_FILE/DIR] [REMOTE_FILE/DIR]" 201 | echo -e "\t mkdir [REMOTE_DIR]" 202 | echo -e "\t list " 203 | echo -e "\t share [REMOTE_FILE]" 204 | echo -e "\t info" 205 | echo -e "\t unlink" 206 | 207 | echo -e "\nOptional parameters:" 208 | echo -e "\t-f [FILENAME] Load the configuration file from a specific file" 209 | echo -e "\t-s Skip already existing files when download/upload. Default: Overwrite" 210 | echo -e "\t-d Enable DEBUG mode" 211 | echo -e "\t-q Quiet mode. Don't show messages" 212 | echo -e "\t-p Show cURL progress meter" 213 | echo -e "\t-k Doesn't check for SSL certificates (insecure)" 214 | 215 | echo -en "\nFor more info and examples, please see the README file.\n\n" 216 | remove_temp_files 217 | exit 1 218 | } 219 | 220 | #Check the curl exit code 221 | function check_http_response 222 | { 223 | CODE=$? 224 | 225 | #Checking curl exit code 226 | case $CODE in 227 | 228 | #OK 229 | 0) 230 | 231 | ;; 232 | 233 | #Proxy error 234 | 5) 235 | print "\nError: Couldn't resolve proxy. The given proxy host could not be resolved.\n" 236 | 237 | remove_temp_files 238 | exit 1 239 | ;; 240 | 241 | #Missing CA certificates 242 | 60|58) 243 | print "\nError: cURL is not able to performs peer SSL certificate verification.\n" 244 | print "Please, install the default ca-certificates bundle.\n" 245 | print "To do this in a Debian/Ubuntu based system, try:\n" 246 | print " sudo apt-get install ca-certificates\n\n" 247 | print "If the problem persists, try to use the -k option (insecure).\n" 248 | 249 | remove_temp_files 250 | exit 1 251 | ;; 252 | 253 | 6) 254 | print "\nError: Couldn't resolve host.\n" 255 | 256 | remove_temp_files 257 | exit 1 258 | ;; 259 | 260 | 7) 261 | print "\nError: Couldn't connect to host.\n" 262 | 263 | remove_temp_files 264 | exit 1 265 | ;; 266 | 267 | esac 268 | 269 | #Checking response file for generic errors 270 | if grep -q "HTTP/1.1 400" "$RESPONSE_FILE"; then 271 | ERROR_MSG=$(sed -n -e 's/{"error": "\([^"]*\)"}/\1/p' "$RESPONSE_FILE") 272 | 273 | case $ERROR_MSG in 274 | *access?attempt?failed?because?this?app?is?not?configured?to?have*) 275 | echo -e "\nError: The Permission type/Access level configured doesn't match the DropBox App settings!\nPlease run \"$0 unlink\" and try again." 276 | exit 1 277 | ;; 278 | esac 279 | 280 | fi 281 | 282 | } 283 | 284 | #Urlencode 285 | function urlencode 286 | { 287 | local string="${1}" 288 | local strlen=${#string} 289 | local encoded="" 290 | 291 | for (( pos=0 ; pos /dev/null 321 | check_http_response 322 | 323 | #Even if the file/dir has been deleted from DropBox we receive a 200 OK response 324 | #So we must check if the file exists or if it has been deleted 325 | if grep -q "\"is_deleted\":" "$RESPONSE_FILE"; then 326 | local IS_DELETED=$(sed -n 's/.*"is_deleted":.\([^,]*\).*/\1/p' "$RESPONSE_FILE") 327 | else 328 | local IS_DELETED="false" 329 | fi 330 | 331 | #Exits... 332 | grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE" 333 | if [[ $? == 0 && $IS_DELETED != "true" ]]; then 334 | 335 | local IS_DIR=$(sed -n 's/^\(.*\)\"contents":.\[.*/\1/p' "$RESPONSE_FILE") 336 | 337 | #It's a directory 338 | if [[ $IS_DIR != "" ]]; then 339 | echo "DIR" 340 | #It's a file 341 | else 342 | echo "FILE" 343 | fi 344 | 345 | #Doesn't exists 346 | else 347 | echo "ERR" 348 | fi 349 | } 350 | 351 | #Generic upload wrapper around db_upload_file and db_upload_dir functions 352 | #$1 = Local source file/dir 353 | #$2 = Remote destination file/dir 354 | function db_upload 355 | { 356 | local SRC=$(normalize_path "$1") 357 | local DST=$(normalize_path "$2") 358 | 359 | #Checking if the file/dir exists 360 | if [[ ! -f $SRC && ! -d $SRC ]]; then 361 | print " > No such file or directory: $SRC\n" 362 | ERROR_STATUS=1 363 | return 364 | fi 365 | 366 | #Checking if the file/dir has read permissions 367 | if [[ ! -r $SRC ]]; then 368 | print " > Error reading file $SRC: permission denied\n" 369 | ERROR_STATUS=1 370 | return 371 | fi 372 | 373 | #Checking if DST it's a folder or if it doesn' exists (in this case will be the destination name) 374 | TYPE=$(db_stat "$DST") 375 | if [[ $TYPE == "DIR" ]]; then 376 | local filename=$(basename "$SRC") 377 | DST="$DST/$filename" 378 | fi 379 | 380 | #It's a file 381 | if [[ -f $SRC ]]; then 382 | db_upload_file "$SRC" "$DST" 383 | 384 | #It's a directory 385 | elif [[ -d $SRC ]]; then 386 | db_upload_dir "$SRC" "$DST" 387 | 388 | #Unsupported object... 389 | else 390 | print " > Skipping not regular file \"$SRC\"\n" 391 | fi 392 | } 393 | 394 | #Generic upload wrapper around db_chunked_upload_file and db_simple_upload_file 395 | #The final upload function will be choosen based on the file size 396 | #$1 = Local source file 397 | #$2 = Remote destination file 398 | function db_upload_file 399 | { 400 | local FILE_SRC=$(normalize_path "$1") 401 | local FILE_DST=$(normalize_path "$2") 402 | 403 | shopt -s nocasematch 404 | 405 | #Checking not allowed file names 406 | basefile_dst=$(basename "$FILE_DST") 407 | if [[ $basefile_dst == "thumbs.db" || \ 408 | $basefile_dst == "desktop.ini" || \ 409 | $basefile_dst == ".ds_store" || \ 410 | $basefile_dst == "icon\r" || \ 411 | $basefile_dst == ".dropbox" || \ 412 | $basefile_dst == ".dropbox.attr" \ 413 | ]]; then 414 | print " > Skipping not allowed file name \"$FILE_DST\"\n" 415 | return 416 | fi 417 | 418 | shopt -u nocasematch 419 | 420 | #Checking file size 421 | FILE_SIZE=$(file_size "$FILE_SRC") 422 | 423 | #Checking if the file already exists 424 | TYPE=$(db_stat "$FILE_DST") 425 | if [[ $TYPE != "ERR" && $SKIP_EXISTING_FILES == 1 ]]; then 426 | print " > Skipping already existing file \"$FILE_DST\"\n" 427 | return 428 | fi 429 | 430 | if (( $FILE_SIZE > 157286000 )); then 431 | #If the file is greater than 150Mb, the chunked_upload API will be used 432 | db_chunked_upload_file "$FILE_SRC" "$FILE_DST" 433 | else 434 | db_simple_upload_file "$FILE_SRC" "$FILE_DST" 435 | fi 436 | 437 | } 438 | 439 | #Simple file upload 440 | #$1 = Local source file 441 | #$2 = Remote destination file 442 | function db_simple_upload_file 443 | { 444 | local FILE_SRC=$(normalize_path "$1") 445 | local FILE_DST=$(normalize_path "$2") 446 | 447 | if [[ $SHOW_PROGRESSBAR == 1 && $QUIET == 0 ]]; then 448 | CURL_PARAMETERS="--progress-bar" 449 | LINE_CR="\n" 450 | else 451 | CURL_PARAMETERS="-s" 452 | LINE_CR="" 453 | fi 454 | 455 | print " > Uploading \"$FILE_SRC\" to \"$FILE_DST\"... $LINE_CR" 456 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES $CURL_PARAMETERS -i --globoff -o "$RESPONSE_FILE" --upload-file "$FILE_SRC" "$API_UPLOAD_URL/$ACCESS_LEVEL/$(urlencode "$FILE_DST")?oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" 457 | check_http_response 458 | 459 | #Check 460 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 461 | print "DONE\n" 462 | else 463 | print "FAILED\n" 464 | print "An error occurred requesting /upload\n" 465 | ERROR_STATUS=1 466 | fi 467 | } 468 | 469 | #Chunked file upload 470 | #$1 = Local source file 471 | #$2 = Remote destination file 472 | function db_chunked_upload_file 473 | { 474 | local FILE_SRC=$(normalize_path "$1") 475 | local FILE_DST=$(normalize_path "$2") 476 | 477 | print " > Uploading \"$FILE_SRC\" to \"$FILE_DST\"" 478 | 479 | local FILE_SIZE=$(file_size "$FILE_SRC") 480 | local OFFSET=0 481 | local UPLOAD_ID="" 482 | local UPLOAD_ERROR=0 483 | local CHUNK_PARAMS="" 484 | 485 | #Uploading chunks... 486 | while ([[ $OFFSET != $FILE_SIZE ]]); do 487 | 488 | let OFFSET_MB=$OFFSET/1024/1024 489 | 490 | #Create the chunk 491 | dd if="$FILE_SRC" of="$CHUNK_FILE" bs=1048576 skip=$OFFSET_MB count=$CHUNK_SIZE 2> /dev/null 492 | 493 | #Only for the first request these parameters are not included 494 | if [[ $OFFSET != 0 ]]; then 495 | CHUNK_PARAMS="upload_id=$UPLOAD_ID&offset=$OFFSET" 496 | fi 497 | 498 | #Uploading the chunk... 499 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --upload-file "$CHUNK_FILE" "$API_CHUNKED_UPLOAD_URL?$CHUNK_PARAMS&oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" 2> /dev/null 500 | check_http_response 501 | 502 | #Check 503 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 504 | print "." 505 | UPLOAD_ERROR=0 506 | UPLOAD_ID=$(sed -n 's/.*"upload_id": *"*\([^"]*\)"*.*/\1/p' "$RESPONSE_FILE") 507 | OFFSET=$(sed -n 's/.*"offset": *\([^}]*\).*/\1/p' "$RESPONSE_FILE") 508 | else 509 | print "*" 510 | let UPLOAD_ERROR=$UPLOAD_ERROR+1 511 | 512 | #On error, the upload is retried for max 3 times 513 | if (( $UPLOAD_ERROR > 2 )); then 514 | print " FAILED\n" 515 | print "An error occurred requesting /chunked_upload\n" 516 | ERROR_STATUS=1 517 | return 518 | fi 519 | fi 520 | 521 | done 522 | 523 | UPLOAD_ERROR=0 524 | 525 | #Commit the upload 526 | while (true); do 527 | 528 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "upload_id=$UPLOAD_ID&oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" "$API_CHUNKED_UPLOAD_COMMIT_URL/$ACCESS_LEVEL/$(urlencode "$FILE_DST")" 2> /dev/null 529 | check_http_response 530 | 531 | #Check 532 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 533 | print "." 534 | UPLOAD_ERROR=0 535 | break 536 | else 537 | print "*" 538 | let UPLOAD_ERROR=$UPLOAD_ERROR+1 539 | 540 | #On error, the commit is retried for max 3 times 541 | if (( $UPLOAD_ERROR > 2 )); then 542 | print " FAILED\n" 543 | print "An error occurred requesting /commit_chunked_upload\n" 544 | ERROR_STATUS=1 545 | return 546 | fi 547 | fi 548 | 549 | done 550 | 551 | print " DONE\n" 552 | } 553 | 554 | #Directory upload 555 | #$1 = Local source dir 556 | #$2 = Remote destination dir 557 | function db_upload_dir 558 | { 559 | local DIR_SRC=$(normalize_path "$1") 560 | local DIR_DST=$(normalize_path "$2") 561 | 562 | #Creatig remote directory 563 | db_mkdir "$DIR_DST" 564 | 565 | for file in "$DIR_SRC/"*; do 566 | db_upload "$file" "$DIR_DST" 567 | done 568 | } 569 | 570 | #Returns the free space on DropBox in bytes 571 | function db_free_quota 572 | { 573 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" "$API_INFO_URL" 2> /dev/null 574 | check_http_response 575 | 576 | #Check 577 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 578 | 579 | quota=$(sed -n 's/.*"quota": \([0-9]*\).*/\1/p' "$RESPONSE_FILE") 580 | used=$(sed -n 's/.*"normal": \([0-9]*\).*/\1/p' "$RESPONSE_FILE") 581 | let free_quota=$quota-$used 582 | echo $free_quota 583 | 584 | else 585 | #On error, a big free quota is returned, so if this function fails the upload will not be blocked... 586 | echo 1000000000000 587 | fi 588 | } 589 | 590 | #Generic download wrapper 591 | #$1 = Remote source file/dir 592 | #$2 = Local destination file/dir 593 | function db_download 594 | { 595 | local SRC=$(normalize_path "$1") 596 | local DST=$(normalize_path "$2") 597 | 598 | TYPE=$(db_stat "$SRC") 599 | 600 | #It's a directory 601 | if [[ $TYPE == "DIR" ]]; then 602 | 603 | #If the DST folder is not specified, I assume that is the current directory 604 | if [[ $DST == "" ]]; then 605 | DST="." 606 | fi 607 | 608 | #Checking if the destination directory exists 609 | if [[ ! -d $DST ]]; then 610 | local basedir="" 611 | else 612 | local basedir=$(basename "$SRC") 613 | fi 614 | 615 | local DEST_DIR=$(normalize_path "$DST/$basedir") 616 | print " > Downloading \"$SRC\" to \"$DEST_DIR\"... \n" 617 | print " > Creating local directory \"$DEST_DIR\"... " 618 | mkdir -p "$DEST_DIR" 619 | 620 | #Check 621 | if [[ $? == 0 ]]; then 622 | print "DONE\n" 623 | else 624 | print "FAILED\n" 625 | ERROR_STATUS=1 626 | return 627 | fi 628 | 629 | #Extracting directory content [...] 630 | #and replacing "}, {" with "}\n{" 631 | #I don't like this piece of code... but seems to be the only way to do this with SED, writing a portable code... 632 | local DIR_CONTENT=$(sed -n 's/.*: \[{\(.*\)/\1/p' "$RESPONSE_FILE" | sed 's/}, *{/}\ 633 | {/g') 634 | 635 | #Extracing files and subfolders 636 | TMP_DIR_CONTENT_FILE="${RESPONSE_FILE}_$RANDOM" 637 | echo "$DIR_CONTENT" | sed -n 's/.*"path": *"\([^"]*\)",.*"is_dir": *\([^"]*\),.*/\1:\2/p' > $TMP_DIR_CONTENT_FILE 638 | 639 | #For each line... 640 | while read -r line; do 641 | 642 | local FILE=${line%:*} 643 | FILE=${FILE##*/} 644 | local TYPE=${line#*:} 645 | 646 | if [[ $TYPE == "false" ]]; then 647 | db_download_file "$SRC/$FILE" "$DEST_DIR/$FILE" 648 | else 649 | db_download "$SRC/$FILE" "$DEST_DIR" 650 | fi 651 | 652 | done < $TMP_DIR_CONTENT_FILE 653 | 654 | rm -fr $TMP_DIR_CONTENT_FILE 655 | 656 | #It's a file 657 | elif [[ $TYPE == "FILE" ]]; then 658 | 659 | #Checking DST 660 | if [[ $DST == "" ]]; then 661 | DST=$(basename "$SRC") 662 | fi 663 | 664 | #If the destination is a directory, the file will be download into 665 | if [[ -d $DST ]]; then 666 | DST="$DST/$SRC" 667 | fi 668 | 669 | db_download_file "$SRC" "$DST" 670 | 671 | #Doesn't exists 672 | else 673 | print " > No such file or directory: $SRC\n" 674 | ERROR_STATUS=1 675 | return 676 | fi 677 | } 678 | 679 | #Simple file download 680 | #$1 = Remote source file 681 | #$2 = Local destination file 682 | function db_download_file 683 | { 684 | local FILE_SRC=$(normalize_path "$1") 685 | local FILE_DST=$(normalize_path "$2") 686 | 687 | if [[ $SHOW_PROGRESSBAR == 1 && $QUIET == 0 ]]; then 688 | CURL_PARAMETERS="--progress-bar" 689 | LINE_CR="\n" 690 | else 691 | CURL_PARAMETERS="-s" 692 | LINE_CR="" 693 | fi 694 | 695 | #Checking if the file already exists 696 | if [[ -f $FILE_DST && $SKIP_EXISTING_FILES == 1 ]]; then 697 | print " > Skipping already existing file \"$FILE_DST\"\n" 698 | return 699 | fi 700 | 701 | #Creating the empty file, that for two reasons: 702 | #1) In this way I can check if the destination file is writable or not 703 | #2) Curl doesn't automatically creates files with 0 bytes size 704 | dd if=/dev/zero of="$FILE_DST" count=0 2> /dev/null 705 | if [[ $? != 0 ]]; then 706 | print " > Error writing file $FILE_DST: permission denied\n" 707 | ERROR_STATUS=1 708 | return 709 | fi 710 | 711 | print " > Downloading \"$FILE_SRC\" to \"$FILE_DST\"... $LINE_CR" 712 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES $CURL_PARAMETERS --globoff -D "$RESPONSE_FILE" -o "$FILE_DST" "$API_DOWNLOAD_URL/$ACCESS_LEVEL/$(urlencode "$FILE_SRC")?oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" 713 | check_http_response 714 | 715 | #Check 716 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 717 | print "DONE\n" 718 | else 719 | print "FAILED\n" 720 | rm -fr "$FILE_DST" 721 | ERROR_STATUS=1 722 | return 723 | fi 724 | } 725 | 726 | #Prints account info 727 | function db_account_info 728 | { 729 | print "Dropbox Uploader v$VERSION\n\n" 730 | print " > Getting info... " 731 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" "$API_INFO_URL" 2> /dev/null 732 | check_http_response 733 | 734 | #Check 735 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 736 | 737 | name=$(sed -n 's/.*"display_name": "\([^"]*\).*/\1/p' "$RESPONSE_FILE") 738 | echo -e "\n\nName:\t$name" 739 | 740 | uid=$(sed -n 's/.*"uid": \([0-9]*\).*/\1/p' "$RESPONSE_FILE") 741 | echo -e "UID:\t$uid" 742 | 743 | email=$(sed -n 's/.*"email": "\([^"]*\).*/\1/p' "$RESPONSE_FILE") 744 | echo -e "Email:\t$email" 745 | 746 | quota=$(sed -n 's/.*"quota": \([0-9]*\).*/\1/p' "$RESPONSE_FILE") 747 | let quota_mb=$quota/1024/1024 748 | echo -e "Quota:\t$quota_mb Mb" 749 | 750 | used=$(sed -n 's/.*"normal": \([0-9]*\).*/\1/p' "$RESPONSE_FILE") 751 | let used_mb=$used/1024/1024 752 | echo -e "Used:\t$used_mb Mb" 753 | 754 | let free_mb=($quota-$used)/1024/1024 755 | echo -e "Free:\t$free_mb Mb" 756 | 757 | echo "" 758 | 759 | else 760 | print "FAILED\n" 761 | ERROR_STATUS=1 762 | fi 763 | } 764 | 765 | #Delete a remote file 766 | #$1 = Remote file to delete 767 | function db_delete 768 | { 769 | local FILE_DST=$(normalize_path "$1") 770 | 771 | print " > Deleting \"$FILE_DST\"... " 772 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&root=$ACCESS_LEVEL&path=$(urlencode "$FILE_DST")" "$API_DELETE_URL" 2> /dev/null 773 | check_http_response 774 | 775 | #Check 776 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 777 | print "DONE\n" 778 | else 779 | print "FAILED\n" 780 | ERROR_STATUS=1 781 | fi 782 | } 783 | 784 | #Move/Rename a remote file 785 | #$1 = Remote file to rename or move 786 | #$2 = New file name or location 787 | function db_move 788 | { 789 | local FILE_SRC=$(normalize_path "$1") 790 | local FILE_DST=$(normalize_path "$2") 791 | 792 | TYPE=$(db_stat "$FILE_DST") 793 | 794 | #If the destination it's a directory, the source will be moved into it 795 | if [[ $TYPE == "DIR" ]]; then 796 | local filename=$(basename "$FILE_SRC") 797 | FILE_DST=$(normalize_path "$FILE_DST/$filename") 798 | fi 799 | 800 | print " > Moving \"$FILE_SRC\" to \"$FILE_DST\" ... " 801 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&root=$ACCESS_LEVEL&from_path=$(urlencode "$FILE_SRC")&to_path=$(urlencode "$FILE_DST")" "$API_MOVE_URL" 2> /dev/null 802 | check_http_response 803 | 804 | #Check 805 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 806 | print "DONE\n" 807 | else 808 | print "FAILED\n" 809 | ERROR_STATUS=1 810 | fi 811 | } 812 | 813 | #Copy a remote file to a remote location 814 | #$1 = Remote file to rename or move 815 | #$2 = New file name or location 816 | function db_copy 817 | { 818 | local FILE_SRC=$(normalize_path "$1") 819 | local FILE_DST=$(normalize_path "$2") 820 | 821 | TYPE=$(db_stat "$FILE_DST") 822 | 823 | #If the destination it's a directory, the source will be copied into it 824 | if [[ $TYPE == "DIR" ]]; then 825 | local filename=$(basename "$FILE_SRC") 826 | FILE_DST=$(normalize_path "$FILE_DST/$filename") 827 | fi 828 | 829 | print " > Copying \"$FILE_SRC\" to \"$FILE_DST\" ... " 830 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&root=$ACCESS_LEVEL&from_path=$(urlencode "$FILE_SRC")&to_path=$(urlencode "$FILE_DST")" "$API_COPY_URL" 2> /dev/null 831 | check_http_response 832 | 833 | #Check 834 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 835 | print "DONE\n" 836 | else 837 | print "FAILED\n" 838 | ERROR_STATUS=1 839 | fi 840 | } 841 | 842 | #Create a new directory 843 | #$1 = Remote directory to create 844 | function db_mkdir 845 | { 846 | local DIR_DST=$(normalize_path "$1") 847 | 848 | print " > Creating Directory \"$DIR_DST\"... " 849 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&root=$ACCESS_LEVEL&path=$(urlencode "$DIR_DST")" "$API_MKDIR_URL" 2> /dev/null 850 | check_http_response 851 | 852 | #Check 853 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 854 | print "DONE\n" 855 | elif grep -q "^HTTP/1.1 403 Forbidden" "$RESPONSE_FILE"; then 856 | print "ALREADY EXISTS\n" 857 | else 858 | print "FAILED\n" 859 | ERROR_STATUS=1 860 | fi 861 | } 862 | 863 | #List remote directory 864 | #$1 = Remote directory 865 | function db_list 866 | { 867 | local DIR_DST=$(normalize_path "$1") 868 | 869 | print " > Listing \"$DIR_DST\"... " 870 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" "$API_METADATA_URL/$ACCESS_LEVEL/$(urlencode "$DIR_DST")?oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" 2> /dev/null 871 | check_http_response 872 | 873 | #Check 874 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 875 | 876 | local IS_DIR=$(sed -n 's/^\(.*\)\"contents":.\[.*/\1/p' "$RESPONSE_FILE") 877 | 878 | #It's a directory 879 | if [[ $IS_DIR != "" ]]; then 880 | 881 | print "DONE\n" 882 | 883 | #Extracting directory content [...] 884 | #and replacing "}, {" with "}\n{" 885 | #I don't like this piece of code... but seems to be the only way to do this with SED, writing a portable code... 886 | local DIR_CONTENT=$(sed -n 's/.*: \[{\(.*\)/\1/p' "$RESPONSE_FILE" | sed 's/}, *{/}\ 887 | {/g') 888 | 889 | #Extracing files and subfolders 890 | echo "$DIR_CONTENT" | sed -n 's/.*"path": *"\([^"]*\)",.*"is_dir": *\([^"]*\),.*/\1:\2/p' > $RESPONSE_FILE 891 | 892 | #For each line... 893 | while read -r line; do 894 | 895 | local FILE=${line%:*} 896 | FILE=${FILE##*/} 897 | local TYPE=${line#*:} 898 | 899 | if [[ $TYPE == "false" ]]; then 900 | echo -ne " [F] $FILE\n" 901 | else 902 | echo -ne " [D] $FILE\n" 903 | fi 904 | done < $RESPONSE_FILE 905 | 906 | #It's a file 907 | else 908 | print "FAILED: $DIR_DST is not a directory!\n" 909 | ERROR_STATUS=1 910 | fi 911 | 912 | else 913 | print "FAILED\n" 914 | ERROR_STATUS=1 915 | fi 916 | } 917 | 918 | #Share remote file 919 | #$1 = Remote file 920 | function db_share 921 | { 922 | local FILE_DST=$(normalize_path "$1") 923 | 924 | $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" "$API_SHARES_URL/$ACCESS_LEVEL/$(urlencode "$FILE_DST")?oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&short_url=false" 2> /dev/null 925 | check_http_response 926 | 927 | #Check 928 | if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then 929 | print " > Share link: " 930 | echo $(sed -n 's/.*"url": "\([^"]*\).*/\1/p' "$RESPONSE_FILE") 931 | else 932 | print "FAILED\n" 933 | ERROR_STATUS=1 934 | fi 935 | } 936 | 937 | ################ 938 | #### SETUP #### 939 | ################ 940 | 941 | #Checking the loaded data 942 | if [[ $APPKEY == "" || $APPSECRET == "" || $OAUTH_ACCESS_TOKEN_SECRET == "" || $OAUTH_ACCESS_TOKEN == "" ]]; then 943 | echo -ne "Configuration error" 944 | remove_temp_files 945 | exit 1 946 | fi 947 | 948 | #Back compatibility with previous Dropbox Uploader versions 949 | if [[ $ACCESS_LEVEL == "" ]]; then 950 | ACCESS_LEVEL="dropbox" 951 | fi 952 | 953 | ################ 954 | #### START #### 955 | ################ 956 | 957 | COMMAND=${@:$OPTIND:1} 958 | ARG1=${@:$OPTIND+1:1} 959 | ARG2=${@:$OPTIND+2:1} 960 | 961 | #CHECKING PARAMS VALUES 962 | case $COMMAND in 963 | 964 | upload) 965 | 966 | FILE_SRC=$ARG1 967 | FILE_DST=$ARG2 968 | 969 | #Checking FILE_SRC 970 | if [[ $FILE_SRC == "" ]]; then 971 | print "Error: invalid source file or directory" 972 | remove_temp_files 973 | exit 1 974 | fi 975 | 976 | #Checking FILE_DST 977 | if [[ $FILE_DST == "" ]]; then 978 | if [[ -f $FILE_SRC ]]; then 979 | FILE_DST=/$(basename "$FILE_SRC") 980 | else 981 | FILE_DST=/ 982 | fi 983 | fi 984 | 985 | db_upload "$FILE_SRC" "/$FILE_DST" 986 | 987 | ;; 988 | 989 | download) 990 | 991 | FILE_SRC=$ARG1 992 | FILE_DST=$ARG2 993 | 994 | #Checking FILE_SRC 995 | if [[ $FILE_SRC == "" ]]; then 996 | print "Error: invalid source file or directory" 997 | remove_temp_files 998 | exit 1 999 | fi 1000 | 1001 | db_download "/$FILE_SRC" "$FILE_DST" 1002 | 1003 | ;; 1004 | 1005 | share) 1006 | 1007 | FILE_DST=$ARG1 1008 | 1009 | #Checking FILE_DST 1010 | if [[ $FILE_DST == "" ]]; then 1011 | print "Error: Please specify the file to share" 1012 | remove_temp_files 1013 | exit 1 1014 | fi 1015 | 1016 | db_share "/$FILE_DST" 1017 | 1018 | ;; 1019 | 1020 | info) 1021 | 1022 | db_account_info 1023 | 1024 | ;; 1025 | 1026 | delete|remove) 1027 | 1028 | FILE_DST=$ARG1 1029 | 1030 | #Checking FILE_DST 1031 | if [[ $FILE_DST == "" ]]; then 1032 | print "Error: Please specify the file to remove" 1033 | remove_temp_files 1034 | exit 1 1035 | fi 1036 | 1037 | db_delete "/$FILE_DST" 1038 | 1039 | ;; 1040 | 1041 | move|rename) 1042 | 1043 | FILE_SRC=$ARG1 1044 | FILE_DST=$ARG2 1045 | 1046 | #Checking FILE_SRC 1047 | if [[ $FILE_SRC == "" ]]; then 1048 | print "Error: Please specify the source file" 1049 | remove_temp_files 1050 | exit 1 1051 | fi 1052 | 1053 | #Checking FILE_DST 1054 | if [[ $FILE_DST == "" ]]; then 1055 | print "Error: Please specify the destination file" 1056 | remove_temp_files 1057 | exit 1 1058 | fi 1059 | 1060 | db_move "/$FILE_SRC" "/$FILE_DST" 1061 | 1062 | ;; 1063 | 1064 | copy) 1065 | 1066 | FILE_SRC=$ARG1 1067 | FILE_DST=$ARG2 1068 | 1069 | #Checking FILE_SRC 1070 | if [[ $FILE_SRC == "" ]]; then 1071 | print "Error: Please specify the source file" 1072 | remove_temp_files 1073 | exit 1 1074 | fi 1075 | 1076 | #Checking FILE_DST 1077 | if [[ $FILE_DST == "" ]]; then 1078 | print "Error: Please specify the destination file" 1079 | remove_temp_files 1080 | exit 1 1081 | fi 1082 | 1083 | db_copy "/$FILE_SRC" "/$FILE_DST" 1084 | 1085 | ;; 1086 | 1087 | mkdir) 1088 | 1089 | DIR_DST=$ARG1 1090 | 1091 | #Checking DIR_DST 1092 | if [[ $DIR_DST == "" ]]; then 1093 | print "Error: Please specify the destination directory" 1094 | remove_temp_files 1095 | exit 1 1096 | fi 1097 | 1098 | db_mkdir "/$DIR_DST" 1099 | 1100 | ;; 1101 | 1102 | list) 1103 | 1104 | DIR_DST=$ARG1 1105 | 1106 | #Checking DIR_DST 1107 | if [[ $DIR_DST = "" ]]; then 1108 | DIR_DST="/" 1109 | fi 1110 | 1111 | db_list "/$DIR_DST" 1112 | 1113 | ;; 1114 | 1115 | *) 1116 | 1117 | if [[ $COMMAND != "" ]]; then 1118 | print "Error: Unknown command: $COMMAND\n\n" 1119 | ERROR_STATUS=1 1120 | fi 1121 | usage 1122 | 1123 | ;; 1124 | 1125 | esac 1126 | 1127 | remove_temp_files 1128 | exit $ERROR_STATUS 1129 | -------------------------------------------------------------------------------- /r-travis/scripts/travis-tool.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- sh-basic-offset: 4; sh-indentation: 4 -*- 3 | # Bootstrap an R/travis environment. 4 | 5 | set -e 6 | # Comment out this line for quieter output: 7 | set -x 8 | 9 | CRAN=${CRAN:-"https://cloud.r-project.org"} 10 | BIOC=${BIOC:-"http://bioconductor.org/biocLite.R"} 11 | PKGTYPE=${PKGTYPE:-"win.binary"} 12 | BIOC_USE_DEVEL=${BIOC_USE_DEVEL:-"TRUE"} 13 | OS=$(uname -s) 14 | DOWNLOAD_FILE_METHOD=${DOWNLOAD_FILE_METHOD:-"auto"} 15 | 16 | PANDOC_VERSION='1.13.1' 17 | PANDOC_DIR="${HOME}/opt/pandoc" 18 | PANDOC_URL="https://s3.amazonaws.com/rstudio-buildtools/pandoc-${PANDOC_VERSION}.zip" 19 | 20 | # MacTeX installs in a new $PATH entry, and there's no way to force 21 | # the *parent* shell to source it from here. So we just manually add 22 | # all the entries to a location we already know to be on $PATH. 23 | # 24 | # TODO(craigcitro): Remove this once we can add `/usr/texbin` to the 25 | # root path. 26 | PATH="${PATH}:/usr/texbin" 27 | 28 | R_BUILD_ARGS=${R_BUILD_ARGS-"--no-manual"} 29 | R_CHECK_ARGS=${R_CHECK_ARGS-"--no-manual --as-cran"} 30 | 31 | R_VERSION_TEST="getRversion() >= '3.5.0'" 32 | 33 | R_USE_BIOC_INST="source('${BIOC}');"\ 34 | " tryCatch(useDevel(${BIOC_USE_DEVEL}),"\ 35 | " error=function(e) {if (!grepl('already in use', e$message)) {e}});"\ 36 | " options(repos=biocinstallRepos())" 37 | 38 | R_USE_BIOC_MNGR="if (!requireNamespace('BiocManager', quietly=TRUE))"\ 39 | " install.packages('BiocManager', repos=c(CRAN='${CRAN}'));"\ 40 | " if (${BIOC_USE_DEVEL})"\ 41 | " BiocManager::install(version = 'devel', ask = FALSE);"\ 42 | " options(repos=BiocManager::repositories())" 43 | 44 | R_USE_BIOC_CMDS="if (${R_VERSION_TEST}) {${R_USE_BIOC_MNGR}} else {${R_USE_BIOC_INST}};" 45 | 46 | BIOC_INSTALL="{if (${R_VERSION_TEST}) BiocManager::install else BiocInstaller::biocLite}" 47 | 48 | Bootstrap() { 49 | if [[ "Darwin" == "${OS}" ]]; then 50 | BootstrapMac 51 | elif [[ "Linux" == "${OS}" ]]; then 52 | BootstrapLinux 53 | else 54 | echo "Unknown OS: ${OS}" 55 | exit 1 56 | fi 57 | 58 | if ! (test -e .Rbuildignore && grep -q 'travis-tool' .Rbuildignore); then 59 | echo '^travis-tool\.sh$' >>.Rbuildignore 60 | fi 61 | } 62 | 63 | InstallPandoc() { 64 | local os_path="$1" 65 | mkdir -p "${PANDOC_DIR}" 66 | curl -o /tmp/pandoc-${PANDOC_VERSION}.zip ${PANDOC_URL} 67 | unzip -j /tmp/pandoc-${PANDOC_VERSION}.zip "pandoc-${PANDOC_VERSION}/${os_path}/pandoc" -d "${PANDOC_DIR}" 68 | chmod +x "${PANDOC_DIR}/pandoc" 69 | sudo ln -s "${PANDOC_DIR}/pandoc" /usr/local/bin 70 | unzip -j /tmp/pandoc-${PANDOC_VERSION}.zip "pandoc-${PANDOC_VERSION}/${os_path}/pandoc-citeproc" -d "${PANDOC_DIR}" 71 | chmod +x "${PANDOC_DIR}/pandoc-citeproc" 72 | sudo ln -s "${PANDOC_DIR}/pandoc-citeproc" /usr/local/bin 73 | } 74 | 75 | BootstrapLinux() { 76 | # Set up our CRAN mirror. 77 | sudo add-apt-repository "deb ${CRAN}/bin/linux/ubuntu $(lsb_release -cs)/" 78 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 79 | 80 | # Add marutter's c2d4u repository. 81 | sudo add-apt-repository -y "ppa:marutter/rrutter" 82 | sudo add-apt-repository -y "ppa:marutter/c2d4u" 83 | 84 | # Update after adding all repositories. Retry several times to work around 85 | # flaky connection to Launchpad PPAs. 86 | Retry sudo apt-get update -qq 87 | 88 | # Install an R development environment. qpdf is also needed for 89 | # --as-cran checks: 90 | # https://stat.ethz.ch/pipermail/r-help//2012-September/335676.html 91 | Retry sudo apt-get install -y --no-install-recommends r-base-dev r-recommended qpdf 92 | 93 | # Change permissions for /usr/local/lib/R/site-library 94 | # This should really be via 'staff adduser travis staff' 95 | # but that may affect only the next shell 96 | sudo chmod 2777 /usr/local/lib/R /usr/local/lib/R/site-library 97 | 98 | # Process options 99 | BootstrapLinuxOptions 100 | } 101 | 102 | BootstrapLinuxOptions() { 103 | if [[ -n "$BOOTSTRAP_LATEX" ]]; then 104 | # We add a backports PPA for more recent TeX packages. 105 | sudo add-apt-repository -y "ppa:texlive-backports/ppa" 106 | 107 | Retry sudo apt-get install -y --no-install-recommends \ 108 | texlive-base texlive-latex-base texlive-generic-recommended \ 109 | texlive-fonts-recommended texlive-fonts-extra \ 110 | texlive-extra-utils texlive-latex-recommended texlive-latex-extra \ 111 | texinfo lmodern 112 | fi 113 | if [[ -n "$BOOTSTRAP_PANDOC" ]]; then 114 | InstallPandoc 'linux/debian/x86_64' 115 | fi 116 | } 117 | 118 | BootstrapMac() { 119 | # Install from latest CRAN binary build for OS X 120 | wget ${CRAN}/bin/macosx/R-latest.pkg -O /tmp/R-latest.pkg 121 | 122 | echo "Installing OS X binary package for R" 123 | sudo installer -pkg "/tmp/R-latest.pkg" -target / 124 | rm "/tmp/R-latest.pkg" 125 | 126 | # Process options 127 | BootstrapMacOptions 128 | } 129 | 130 | BootstrapMacOptions() { 131 | if [[ -n "$BOOTSTRAP_LATEX" ]]; then 132 | # TODO: Install MacTeX.pkg once there's enough disk space 133 | MACTEX=BasicTeX.pkg 134 | wget http://ctan.math.utah.edu/ctan/tex-archive/systems/mac/mactex/$MACTEX -O "/tmp/$MACTEX" 135 | 136 | echo "Installing OS X binary package for MacTeX" 137 | sudo installer -pkg "/tmp/$MACTEX" -target / 138 | rm "/tmp/$MACTEX" 139 | # We need a few more packages than the basic package provides; this 140 | # post saved me so much pain: 141 | # https://stat.ethz.ch/pipermail/r-sig-mac/2010-May/007399.html 142 | sudo tlmgr update --self 143 | sudo tlmgr install inconsolata upquote courier courier-scaled helvetic 144 | fi 145 | if [[ -n "$BOOTSTRAP_PANDOC" ]]; then 146 | InstallPandoc 'mac' 147 | fi 148 | } 149 | 150 | EnsureDevtools() { 151 | if ! Rscript -e 'if (!("devtools" %in% rownames(installed.packages()))) q(status=1)' ; then 152 | # Install devtools and testthat. 153 | RBinaryInstall devtools testthat 154 | fi 155 | } 156 | 157 | EnsureRemotes() { 158 | if ! Rscript -e 'if (!("remotes" %in% rownames(installed.packages()))) q(status=1)' ; then 159 | # Install remotes. 160 | RBinaryInstall remotes 161 | fi 162 | if ! Rscript -e 'if (!("remotes" %in% rownames(installed.packages()))) q(status=1)' ; then 163 | # Fallback: Install remotes from URL. 164 | Rscript -e 'path <- file.path(tempdir(), "remotes_1.0.0.tar.gz"); download.file("http://cran.r-project.org/src/contrib/Archive/remotes/remotes_1.0.0.tar.gz", path); install.packages(path, repos = NULL, type = "source")' 165 | fi 166 | } 167 | 168 | AptGetInstall() { 169 | if [[ "Linux" != "${OS}" ]]; then 170 | echo "Wrong OS: ${OS}" 171 | exit 1 172 | fi 173 | 174 | if [[ "" == "$*" ]]; then 175 | echo "No arguments to aptget_install" 176 | exit 1 177 | fi 178 | 179 | echo "Installing apt package(s) $@" 180 | Retry sudo apt-get -y install "$@" 181 | } 182 | 183 | DpkgCurlInstall() { 184 | if [[ "Linux" != "${OS}" ]]; then 185 | echo "Wrong OS: ${OS}" 186 | exit 1 187 | fi 188 | 189 | if [[ "" == "$*" ]]; then 190 | echo "No arguments to dpkgcurl_install" 191 | exit 1 192 | fi 193 | 194 | echo "Installing remote package(s) $@" 195 | for rf in "$@"; do 196 | curl -OL ${rf} 197 | f=$(basename ${rf}) 198 | sudo dpkg -i ${f} 199 | rm -v ${f} 200 | done 201 | } 202 | 203 | RInstall() { 204 | if [[ "" == "$*" ]]; then 205 | echo "No arguments to r_install" 206 | exit 1 207 | fi 208 | 209 | echo "Installing R package(s): $@" 210 | Rscript -e 'install.packages(commandArgs(TRUE), repos="'"${CRAN}"'", INSTALL_opts="", type="'"${PKGTYPE}"'")' "$@" 211 | } 212 | 213 | BiocInstall() { 214 | if [[ "" == "$*" ]]; then 215 | echo "No arguments to bioc_install" 216 | exit 1 217 | fi 218 | 219 | echo "Installing R Bioconductor package(s): $@" 220 | Rscript -e "${R_USE_BIOC_CMDS}"" ${BIOC_INSTALL}(commandArgs(TRUE))" "$@" 221 | } 222 | 223 | RBinaryInstall() { 224 | if [[ -z "$#" ]]; then 225 | echo "No arguments to r_binary_install" 226 | exit 1 227 | fi 228 | 229 | if [[ "Linux" != "${OS}" ]] || [[ -n "${FORCE_SOURCE_INSTALL}" ]]; then 230 | echo "Fallback: Installing from source" 231 | RInstall "$@" 232 | return 233 | fi 234 | 235 | echo "Installing *binary* R packages: $*" 236 | r_packages=$(echo $* | tr '[:upper:]' '[:lower:]') 237 | r_debs=$(for r_package in ${r_packages}; do echo -n "r-cran-${r_package} "; done) 238 | 239 | AptGetInstall ${r_debs} 240 | } 241 | 242 | InstallGithub() { 243 | EnsureRemotes 244 | 245 | echo "Installing GitHub packages: $@" 246 | # Install the package. 247 | Rscript -e 'options(repos = c(CRAN = "'"${CRAN}"'"), download.file.method = "'"${DOWNLOAD_FILE_METHOD}"'"); remotes::install_github(commandArgs(TRUE), type="'"${PKGTYPE}"'")' "$@" 248 | } 249 | 250 | InstallDeps() { 251 | EnsureRemotes 252 | 253 | echo "Installing dependencies" 254 | Rscript -e 'options(repos = c(CRAN = "'"${CRAN}"'"), download.file.method = "'"${DOWNLOAD_FILE_METHOD}"'"); remotes::install_deps(dependencies = TRUE, type="'"${PKGTYPE}"'")' 255 | } 256 | 257 | InstallBiocDeps() { 258 | EnsureDevtools 259 | Rscript -e "${R_USE_BIOC_CMDS}"' library(devtools); install_deps(dependencies = TRUE, type="'"${PKGTYPE}"'")' 260 | } 261 | 262 | DumpSysinfo() { 263 | echo "Dumping system information." 264 | R -e '.libPaths(); sessionInfo(); installed.packages()' 265 | } 266 | 267 | DumpLogsByExtension() { 268 | if [[ -z "$1" ]]; then 269 | echo "dump_logs_by_extension requires exactly one argument, got: $@" 270 | exit 1 271 | fi 272 | extension=$1 273 | shift 274 | package=$(find . -maxdepth 1 -name "*.Rcheck" -type d) 275 | if [[ ${#package[@]} -ne 1 ]]; then 276 | echo "Could not find package Rcheck directory, skipping log dump." 277 | exit 0 278 | fi 279 | for name in $(find "${package}" -type f -name "*${extension}"); do 280 | echo ">>> Filename: ${name} <<<" 281 | cat ${name} 282 | done 283 | } 284 | 285 | DumpLogs() { 286 | echo "Dumping test execution logs." 287 | DumpLogsByExtension "out" 288 | DumpLogsByExtension "log" 289 | DumpLogsByExtension "fail" 290 | } 291 | 292 | RunTests() { 293 | echo "Building with: R CMD build ${R_BUILD_ARGS}" 294 | if [[ "${KEEP_VIGNETTES}" == "" ]]; then 295 | if [[ "${OS:0:5}" == "MINGW" || "${OS:0:4}" == "MSYS" ]]; then 296 | if [[ -d vignettes ]]; then 297 | rm -rf vignettes 298 | Rscript -e "d <- read.dcf('DESCRIPTION'); d[, colnames(d) == 'VignetteBuilder'] <- NA; write.dcf(d, 'DESCRIPTION')" 299 | fi 300 | fi 301 | fi 302 | R CMD build ${R_BUILD_ARGS} . 303 | # We want to grab the version we just built. 304 | FILE=$(ls -1t *.tar.gz | head -n 1) 305 | 306 | # Create binary package (currently Windows only) 307 | if [[ "${OS:0:5}" == "MINGW" || "${OS:0:4}" == "MSYS" ]]; then 308 | R_CHECK_INSTALL_ARGS="--install-args=--build" 309 | fi 310 | 311 | echo "Testing with: R CMD check \"${FILE}\" ${R_CHECK_ARGS} ${R_CHECK_INSTALL_ARGS}" 312 | _R_CHECK_CRAN_INCOMING_=${_R_CHECK_CRAN_INCOMING_:-FALSE} 313 | if [[ "$_R_CHECK_CRAN_INCOMING_" == "FALSE" ]]; then 314 | echo "(CRAN incoming checks are off)" 315 | fi 316 | _R_CHECK_CRAN_INCOMING_=${_R_CHECK_CRAN_INCOMING_} R_QPDF=true R CMD check "${FILE}" ${R_CHECK_ARGS} ${R_CHECK_INSTALL_ARGS} 317 | 318 | # Check reverse dependencies 319 | if [[ -n "$R_CHECK_REVDEP" ]]; then 320 | echo "Checking reverse dependencies" 321 | EnsureDevtools 322 | Rscript -e 'library(devtools); checkOutput <- unlist(revdep_check(as.package(".")$package));if (!is.null(checkOutput)) {print(data.frame(pkg = names(checkOutput), error = checkOutput));for(i in seq_along(checkOutput)){;cat("\n", names(checkOutput)[i], " Check Output:\n ", paste(readLines(regmatches(checkOutput[i], regexec("/.*\\.out", checkOutput[i]))[[1]]), collapse = "\n ", sep = ""), "\n", sep = "")};q(status = 1, save = "no")}' 323 | fi 324 | 325 | if [[ -n "${WARNINGS_ARE_ERRORS}" ]]; then 326 | if DumpLogsByExtension "00check.log" | grep -q WARNING; then 327 | echo "Found warnings, treated as errors." 328 | echo "Clear or unset the WARNINGS_ARE_ERRORS environment variable to ignore warnings." 329 | exit 1 330 | fi 331 | fi 332 | } 333 | 334 | Retry() { 335 | if "$@"; then 336 | return 0 337 | fi 338 | for wait_time in 5 20 30 60; do 339 | echo "Command failed, retrying in ${wait_time} ..." 340 | sleep ${wait_time} 341 | if "$@"; then 342 | return 0 343 | fi 344 | done 345 | echo "Failed all retries!" 346 | exit 1 347 | } 348 | 349 | COMMAND=$1 350 | echo "Running command: ${COMMAND}" 351 | shift 352 | case $COMMAND in 353 | ## 354 | ## Bootstrap a new core system 355 | "bootstrap") 356 | Bootstrap 357 | ;; 358 | ## 359 | ## Ensure devtools is loaded (implicitly called) 360 | "install_devtools"|"devtools_install") 361 | EnsureDevtools 362 | ;; 363 | ## 364 | ## Ensure remotes is loaded (implicitly called) 365 | "install_remotes"|"remotes_install") 366 | EnsureRemotes 367 | ;; 368 | ## 369 | ## Install a binary deb package via apt-get 370 | "install_aptget"|"aptget_install") 371 | AptGetInstall "$@" 372 | ;; 373 | ## 374 | ## Install a binary deb package via a curl call and local dpkg -i 375 | "install_dpkgcurl"|"dpkgcurl_install") 376 | DpkgCurlInstall "$@" 377 | ;; 378 | ## 379 | ## Install an R dependency from CRAN 380 | "install_r"|"r_install") 381 | RInstall "$@" 382 | ;; 383 | ## 384 | ## Install an R dependency from Bioconductor 385 | "install_bioc"|"bioc_install") 386 | BiocInstall "$@" 387 | ;; 388 | ## 389 | ## Install an R dependency as a binary (via c2d4u PPA) 390 | "install_r_binary"|"r_binary_install") 391 | RBinaryInstall "$@" 392 | ;; 393 | ## 394 | ## Install a package from github sources (needs remotes) 395 | "install_github"|"github_package") 396 | InstallGithub "$@" 397 | ;; 398 | ## 399 | ## Install package dependencies from CRAN (needs remotes) 400 | "install_deps") 401 | InstallDeps 402 | ;; 403 | ## 404 | ## Install package dependencies from Bioconductor and CRAN (needs devtools) 405 | "install_bioc_deps") 406 | InstallBiocDeps 407 | ;; 408 | ## 409 | ## Run the actual tests, ie R CMD check 410 | "run_tests") 411 | RunTests 412 | ;; 413 | ## 414 | ## Dump information about installed packages 415 | "dump_sysinfo") 416 | DumpSysinfo 417 | ;; 418 | ## 419 | ## Dump build or check logs 420 | "dump_logs") 421 | DumpLogs 422 | ;; 423 | ## 424 | ## Dump selected build or check logs 425 | "dump_logs_by_extension") 426 | DumpLogsByExtension "$@" 427 | ;; 428 | esac 429 | -------------------------------------------------------------------------------- /sample.appveyor.yml: -------------------------------------------------------------------------------- 1 | # DO NOT CHANGE the "init" and "install" sections below 2 | 3 | # Download script file from GitHub 4 | init: 5 | ps: | 6 | $ErrorActionPreference = "Stop" 7 | Invoke-WebRequest http://raw.githubusercontent.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" 8 | Import-Module '..\appveyor-tool.ps1' 9 | 10 | install: 11 | ps: Bootstrap 12 | 13 | # Adapt as necessary starting from here 14 | 15 | build_script: 16 | - travis-tool.sh install_deps 17 | 18 | test_script: 19 | - travis-tool.sh run_tests 20 | 21 | on_failure: 22 | - travis-tool.sh dump_logs 23 | 24 | environment: 25 | NOT_CRAN: true 26 | 27 | artifacts: 28 | - path: '*.Rcheck\**\*.log' 29 | name: Logs 30 | 31 | - path: '*.Rcheck\**\*.out' 32 | name: Logs 33 | 34 | - path: '*.Rcheck\**\*.fail' 35 | name: Logs 36 | 37 | - path: '*.Rcheck\**\*.Rout' 38 | name: Logs 39 | 40 | - path: '\*_*.tar.gz' 41 | name: Bits 42 | 43 | - path: '\*_*.zip' 44 | name: Bits 45 | -------------------------------------------------------------------------------- /scripts/appveyor-tool.ps1: -------------------------------------------------------------------------------- 1 | if ( -not(Test-Path Env:\CRAN) ) { 2 | $CRAN = "https://cloud.r-project.org" 3 | } 4 | Else { 5 | $CRAN = $env:CRAN 6 | } 7 | 8 | 9 | # Found at http://zduck.com/2012/powershell-batch-files-exit-codes/ 10 | Function Exec 11 | { 12 | [CmdletBinding()] 13 | param ( 14 | [Parameter(Position=0, Mandatory=1)] 15 | [scriptblock]$Command, 16 | [Parameter(Position=1, Mandatory=0)] 17 | [string]$ErrorMessage = "Execution of command failed.`n$Command" 18 | ) 19 | $ErrorActionPreference = "Continue" 20 | & $Command 2>&1 | %{ "$_" } 21 | if ($LastExitCode -ne 0) { 22 | throw "Exec: $ErrorMessage`nExit code: $LastExitCode" 23 | } 24 | } 25 | 26 | Function Progress 27 | { 28 | [CmdletBinding()] 29 | param ( 30 | [Parameter(Position=0, Mandatory=0)] 31 | [string]$Message = "" 32 | ) 33 | 34 | $ProgressMessage = '== ' + (Get-Date) + ': ' + $Message 35 | 36 | Write-Host $ProgressMessage -ForegroundColor Magenta 37 | } 38 | 39 | Function TravisTool 40 | { 41 | [CmdletBinding()] 42 | param ( 43 | [Parameter(Position=0, Mandatory=1)] 44 | [string[]]$Params 45 | ) 46 | 47 | Exec { bash.exe ../travis-tool.sh $Params } 48 | } 49 | 50 | Function InstallR { 51 | [CmdletBinding()] 52 | Param() 53 | 54 | if ( -not(Test-Path Env:\R_VERSION) ) { 55 | $version = "patched" 56 | } 57 | Else { 58 | $version = $env:R_VERSION 59 | } 60 | 61 | if ( -not(Test-Path Env:\R_ARCH) ) { 62 | $arch = "x64" 63 | } 64 | Else { 65 | $arch = $env:R_ARCH 66 | } 67 | 68 | If ($arch -eq "i386") { 69 | $mingw_path = "mingw_32" 70 | } 71 | Else { 72 | $mingw_path = "mingw_64" 73 | } 74 | 75 | Progress ("Version: " + $version) 76 | 77 | If ($version -eq "devel") { 78 | $url_path = "" 79 | $version = "devel" 80 | } 81 | ElseIf (($version -eq "stable") -or ($version -eq "release")) { 82 | $url_path = "" 83 | $version = $(ConvertFrom-JSON $(Invoke-WebRequest https://api.r-hub.io/rversions/r-release-win).Content).version 84 | If ($version -eq "3.2.4") { 85 | $version = "3.2.4revised" 86 | } 87 | } 88 | ElseIf ($version -eq "patched") { 89 | $url_path = "" 90 | $version = $(ConvertFrom-JSON $(Invoke-WebRequest https://api.r-hub.io/rversions/r-release-win).Content).version + "patched" 91 | } 92 | ElseIf ($version -eq "oldrel") { 93 | $version = $(ConvertFrom-JSON $(Invoke-WebRequest https://api.r-hub.io/rversions/r-oldrel).Content).version 94 | $url_path = ("old/" + $version + "/") 95 | } 96 | Else { 97 | $url_path = ("old/" + $version + "/") 98 | } 99 | 100 | Progress ("URL path: " + $url_path) 101 | 102 | $rurl = $CRAN + "/bin/windows/base/" + $url_path + "R-" + $version + "-win.exe" 103 | $global:rversion = $version 104 | 105 | Progress ("Downloading R from: " + $rurl) 106 | & "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../R-win.exe -L $rurl 107 | 108 | Progress "Running R installer" 109 | Start-Process -FilePath ..\R-win.exe -ArgumentList "/VERYSILENT /DIR=C:\R" -NoNewWindow -Wait 110 | 111 | $RDrive = "C:" 112 | echo "R is now available on drive $RDrive" 113 | 114 | Progress "Setting PATH" 115 | $env:PATH = $RDrive + '\R\bin\' + $arch + ';' + 'C:\Rtools\' + $mingw_path + '\bin;' + 'C:\MinGW\msys\1.0\bin;' + $env:PATH 116 | 117 | Progress "Testing R installation" 118 | Rscript -e "sessionInfo()" 119 | } 120 | 121 | Function InstallRtools40 { 122 | $rtoolsurl = $CRAN + "/bin/windows/Rtools/rtools40-x86_64.exe" 123 | 124 | Progress ("Downloading Rtools40 from: " + $rtoolsurl) 125 | & "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../rtools40-x86_64.exe -L $rtoolsurl 126 | 127 | Progress "Running Rtools40 installer" 128 | Start-Process -FilePath ..\rtools40-x86_64.exe -ArgumentList /VERYSILENT -NoNewWindow -Wait 129 | 130 | Progress "Setting PATH" 131 | $env:PATH = 'c:\rtools40\usr\bin;c:\rtools40\mingw64\bin;' + $env:PATH 132 | } 133 | 134 | Function InstallRtools { 135 | if ( -not(Test-Path Env:\RTOOLS_VERSION) ) { 136 | $rtoolsver = '35' 137 | } 138 | Else { 139 | $rtoolsver = $env:RTOOLS_VERSION 140 | } 141 | 142 | $rtoolsurl = $CRAN + "/bin/windows/Rtools/Rtools$rtoolsver.exe" 143 | 144 | Progress ("Downloading Rtools from: " + $rtoolsurl) 145 | & "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../Rtools-current.exe -L $rtoolsurl 146 | 147 | Progress "Running Rtools installer" 148 | Start-Process -FilePath ..\Rtools-current.exe -ArgumentList /VERYSILENT -NoNewWindow -Wait 149 | 150 | $RtoolsDrive = "C:" 151 | echo "Rtools is now available on drive $RtoolsDrive" 152 | 153 | Progress "Setting PATH" 154 | if ( -not(Test-Path Env:\GCC_PATH) ) { 155 | $gcc_path = "gcc-4.6.3" 156 | } 157 | Else { 158 | $gcc_path = $env:GCC_PATH 159 | } 160 | $env:PATH = $RtoolsDrive + '\Rtools\bin;' + $RtoolsDrive + '\Rtools\MinGW\bin;' + $RtoolsDrive + '\Rtools\' + $gcc_path + '\bin;' + $env:PATH 161 | $env:BINPREF=$RtoolsDrive + '/Rtools/mingw_$(WIN)/bin/' 162 | } 163 | 164 | Function Bootstrap { 165 | [CmdletBinding()] 166 | Param() 167 | 168 | Progress "Bootstrap: Start" 169 | 170 | Progress "Adding GnuWin32 tools to PATH" 171 | $env:PATH = "C:\Program Files (x86)\Git\bin;" + $env:PATH 172 | 173 | Progress "Setting time zone" 174 | tzutil /g 175 | tzutil /s "GMT Standard Time" 176 | tzutil /g 177 | 178 | InstallR 179 | 180 | if ((Test-Path "src") -or ($env:USE_RTOOLS -eq "true") -or ($env:USE_RTOOLS -eq "yes")) { 181 | if ($rversion.StartsWith("3")) { 182 | InstallRtools 183 | } Else { 184 | InstallRtools40 185 | } 186 | } 187 | Else { 188 | Progress "Skipping download of Rtools because src/ directory is missing." 189 | } 190 | 191 | Progress "Downloading and installing travis-tool.sh" 192 | Invoke-WebRequest https://raw.githubusercontent.com/krlmlr/r-appveyor/master/r-travis/scripts/travis-tool.sh -OutFile "..\travis-tool.sh" 193 | echo '@bash.exe ../travis-tool.sh %*' | Out-File -Encoding ASCII .\travis-tool.sh.cmd 194 | cat .\travis-tool.sh.cmd 195 | bash -c "( echo; echo '^travis-tool\.sh\.cmd$' ) >> .Rbuildignore" 196 | cat .\.Rbuildignore 197 | 198 | $env:PATH.Split(";") 199 | 200 | Progress "Setting R_LIBS_USER" 201 | $env:R_LIBS_USER = 'c:\RLibrary\' + $rversion.Substring(0,3) 202 | if ( -not(Test-Path $env:R_LIBS_USER) ) { 203 | mkdir $env:R_LIBS_USER 204 | } 205 | 206 | Progress "Setting TAR to 'internal'" 207 | $env:TAR = 'internal' 208 | 209 | Progress "Bootstrap: Done" 210 | } 211 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.dll 4 | -------------------------------------------------------------------------------- /src/RcppExports.cpp: -------------------------------------------------------------------------------- 1 | // Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | #include 5 | 6 | using namespace Rcpp; 7 | 8 | #ifdef RCPP_USE_GLOBAL_ROSTREAM 9 | Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); 10 | Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); 11 | #endif 12 | 13 | // hello 14 | RcppExport SEXP hello(SEXP a); 15 | RcppExport SEXP _fakepackage_hello(SEXP aSEXP) { 16 | BEGIN_RCPP 17 | Rcpp::RObject rcpp_result_gen; 18 | Rcpp::RNGScope rcpp_rngScope_gen; 19 | Rcpp::traits::input_parameter< SEXP >::type a(aSEXP); 20 | rcpp_result_gen = Rcpp::wrap(hello(a)); 21 | return rcpp_result_gen; 22 | END_RCPP 23 | } 24 | 25 | static const R_CallMethodDef CallEntries[] = { 26 | {"_fakepackage_hello", (DL_FUNC) &_fakepackage_hello, 1}, 27 | {NULL, NULL, 0} 28 | }; 29 | 30 | RcppExport void R_init_fakepackage(DllInfo *dll) { 31 | R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); 32 | R_useDynamicSymbols(dll, FALSE); 33 | } 34 | -------------------------------------------------------------------------------- /src/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // [[Rcpp::export]] 4 | RcppExport SEXP hello(SEXP a) { 5 | return Rcpp::wrap("Hello, Rcpp!"); 6 | } 7 | -------------------------------------------------------------------------------- /tests/test-all.R: -------------------------------------------------------------------------------- 1 | if (library(testthat, logical.return = TRUE)) { 2 | test_check("fakepackage") 3 | } 4 | -------------------------------------------------------------------------------- /tests/testthat/test-fakepackage.r: -------------------------------------------------------------------------------- 1 | context("fake") 2 | 3 | test_that("returns 3", { 4 | expect_equal(3, three()) 5 | }) 6 | 7 | test_that("is_three recognizes 3", { 8 | expect_that(is_three(3), is_true()) 9 | expect_that(is_three(5), not(is_true())) 10 | expect_that(is_three(5), is_false()) 11 | }) 12 | 13 | test_that("Rcpp", { 14 | expect_match(hello(5), "^Hello") 15 | }) 16 | -------------------------------------------------------------------------------- /vignettes/test.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Vignette Title" 3 | author: "Vignette Author" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Vignette Title} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The `html_vignette` output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The `html_vignette` format: 13 | 14 | - Never uses retina figures 15 | - Has a smaller default figure size 16 | - Uses a custom CSS stylesheet instead of the default Twitter Bootstrap style 17 | 18 | ## Vignette Info 19 | 20 | Note the various macros within the `vignette` section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the `title` field and the `\VignetteIndexEntry` to match the title of your vignette. 21 | 22 | ## Styles 23 | 24 | The `html_vignette` template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows: 25 | 26 | output: 27 | rmarkdown::html_vignette: 28 | css: mystyles.css 29 | 30 | ## Figures 31 | 32 | The figure sizes have been customised so that you can easily put two images side-by-side. 33 | 34 | ```{r, fig.show='hold'} 35 | plot(1:10) 36 | plot(10:1) 37 | ``` 38 | 39 | You can enable figure captions by `fig_caption: yes` in YAML: 40 | 41 | output: 42 | rmarkdown::html_vignette: 43 | fig_caption: yes 44 | 45 | Then you can use the chunk option `fig.cap = "Your figure caption."` in **knitr**. 46 | 47 | ## More Examples 48 | 49 | You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using `knitr::kable()`. 50 | 51 | ```{r, echo=FALSE, results='asis'} 52 | knitr::kable(head(mtcars, 10)) 53 | ``` 54 | 55 | Also a quote using `>`: 56 | 57 | > "He who gives up [code] safety for [code] speed deserves neither." 58 | ([via](https://twitter.com/hadleywickham/status/504368538874703872)) 59 | --------------------------------------------------------------------------------