├── .gitignore ├── _build.sh ├── DESCRIPTION ├── travis_rmd_test.Rproj ├── .travis.yml ├── extra.Rmd ├── test_me.Rmd ├── README.md └── data └── dem_score.csv /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | .DS_store -------------------------------------------------------------------------------- /_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | Rscript -e 'rmd_files <- list.files(pattern = ".Rmd"); purrr::walk(rmd_files, rmarkdown::render, output_format = "html_document");' -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: maketraviswork 2 | Title: A dummy DESCRIPTION file necessary to trick travis-ci into thinking this is an R 3 | package; this will make travis-ci run the contents of _build.sh. This is 4 | because travis-ci is currently set up for R to only work with packages. 5 | Version: 0.0.0.9000 6 | -------------------------------------------------------------------------------- /travis_rmd_test.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: No 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: XeLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: r 2 | cache: packages 3 | 4 | # Add all CRAN versions of package you used here: 5 | r_packages: 6 | - tidyverse 7 | - here 8 | - fivethirtyeight 9 | 10 | # Add all GitHub versions of packages you used here: 11 | r_github_packages: 12 | - moderndive/moderndive 13 | 14 | 15 | # You do not need to change anything below this line: 16 | 17 | # This UNIX command changes file mode to executable +x i.e. make a bash script 18 | before_script: 19 | - chmod +x ./_build.sh 20 | # Run the bash script. 21 | script: 22 | - ./_build.sh 23 | -------------------------------------------------------------------------------- /extra.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Extras" 3 | author: "Albert Y. Kim & Chester Ismay" 4 | date: "`r Sys.Date()`" 5 | output: 6 | html_document: 7 | highlight: tango 8 | theme: cosmo 9 | toc: yes 10 | toc_depth: 2 11 | toc_float: 12 | collapsed: false 13 | df_print: kable 14 | --- 15 | 16 | ```{r setup, include=FALSE} 17 | knitr::opts_chunk$set(echo = TRUE) 18 | 19 | library(tidyverse) 20 | library(moderndive) 21 | ``` 22 | 23 | ```{r} 24 | # Test: try commenting out library(moderndive) b/c bowl data frame is there 25 | glimpse(bowl) 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /test_me.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Test me!" 3 | author: "Albert Y. Kim & Chester Ismay" 4 | date: "`r Sys.Date()`" 5 | output: 6 | html_document: 7 | highlight: tango 8 | theme: cosmo 9 | toc: yes 10 | toc_depth: 2 11 | toc_float: 12 | collapsed: false 13 | df_print: kable 14 | --- 15 | 16 | ```{r setup, include=FALSE} 17 | library(tidyverse) 18 | library(here) 19 | library(fivethirtyeight) 20 | ``` 21 | 22 | ## Plots 23 | 24 | ```{r plot} 25 | # In this code block, test travis by uncommenting out this line 26 | # blah 27 | 28 | ggplot(hate_crimes, aes(x= median_house_inc, share_vote_trump)) + 29 | geom_point() 30 | ``` 31 | 32 | ```{r} 33 | # In this code block, test that all filepaths work 34 | file_path <- here("data", "dem_score.csv") 35 | dem_score <- read_csv(file_path) 36 | ``` 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # travis_rmd_test 2 | 3 | [![Build Status](https://travis-ci.com/rudeboybert/travis_rmd_test.svg?branch=master)](https://travis-ci.com/rudeboybert/travis_rmd_test) 4 | 5 | Automatically test if `.Rmd` R Markdown files "knit" ✅ or not ❌ using travis-ci on GitHub. 6 | 7 | **Instructors**: If you use this repo's RStudio Project contents as a template for assigning student problem sets and projects (in particular the `DESCRIPTION`, `.travis.yml` & `_build.sh` files), then students will be able to check for themselves on GitHub whether their work is reproducible by looking at the above "travis status badge." 8 | 9 | I welcome your comments, questions, and feedback via a GitHub issue! Shout out to [Chester Ismay](https://github.com/ismayc) for his help with travis-ci and to [Katie Kinnaird](https://github.com/kmkinnaird) for brainstorming with me. 10 | 11 | ## Take it for a test drive! 12 | 13 | * Fork and clone a copy of this repo 14 | * Integrate your GitHub account and travis-ci by following steps 1-3 of these [instructions](https://docs.travis-ci.com/user/tutorial/#to-get-started-with-travis-ci) 15 | * Trigger the first travis build by pushing a commit. 16 | + For example, a good first commit would be to edit `README.md` -> Line 3 -> replace both instances of `rudeboybert` with your GitHub login. That way the resulting "travis status badge" you see on GitHub.com reflects the pass/fail status of your forked repo (and not `rudeboybert`'s). 17 | + The first travis build will take a while (approximately 15 minutes) as travis needs to install R and all packages (in particular `tidyverse`). Because R and package builds get cached however, all subsequent travis builds will be much quicker. 18 | * Check that travis returns ❌ if all `.Rmd` files don't knit: 19 | + Edit `test_me.Rmd` so that it does not knit. Commit and push these changes. 20 | + You can see real-time updates of the progress of the travis checks at . 21 | + After travis checks are done, your "travis status badge" should now read "build: failing" in red. Click on "travis status badge" for the report. 22 | * Check that travis returns ✅ if all `.Rmd` files do knit: 23 | + Revert the above change to `test_me.Rmd`. Commit and push these changes. 24 | + You can see real-time updates of the progress of the travis checks at . 25 | + After travis checks are done, your "travis status badge" should now read "build: passing" in green. Click on "travis status badge" for the report. 26 | 27 | 28 | ## Things to keep in mind 29 | 30 | * The user is responsible for adding all packages used in any `.Rmd` file to `.travis.yml` as follows: 31 | + CRAN versions under `r_packages` 32 | + GitHub versions under `r_github_packages` 33 | * `here::here()` is used to handle macOS, windows, and UNIX variations in file path specifications. 34 | * The `_build.sh` bash file is set up to test if every `.Rmd` file in the repo/RStudio Project folder knits or not. 35 | 36 | 37 | ## TODO 38 | 39 | * Record a loom screencast demonstrating all of this 40 | * Vouch for using `usethis` package to initiate GitHub from a downloaded .zip file of repo. 41 | 42 | ``` 43 | # Enable git in an RStudio project 44 | usethis::use_git() 45 | # Restart R, then follow these steps to create a new repo on GitHub and make 46 | # first commit of contents of RStudio Project 47 | usethis::use_github() 48 | ``` 49 | -------------------------------------------------------------------------------- /data/dem_score.csv: -------------------------------------------------------------------------------- 1 | country,1952,1957,1962,1967,1972,1977,1982,1987,1992 2 | Albania,-9,-9,-9,-9,-9,-9,-9,-9,5 3 | Argentina,-9,-1,-1,-9,-9,-9,-8,8,7 4 | Armenia,-9,-7,-7,-7,-7,-7,-7,-7,7 5 | Australia,10,10,10,10,10,10,10,10,10 6 | Austria,10,10,10,10,10,10,10,10,10 7 | Azerbaijan,-9,-7,-7,-7,-7,-7,-7,-7,1 8 | Belarus,-9,-7,-7,-7,-7,-7,-7,-7,7 9 | Belgium,10,10,10,10,10,10,10,10,10 10 | Bhutan,-10,-10,-10,-10,-10,-10,-10,-10,-10 11 | Bolivia,-4,-3,-3,-4,-7,-7,8,9,9 12 | Brazil,5,5,5,-9,-9,-4,-3,7,8 13 | Bulgaria,-7,-7,-7,-7,-7,-7,-7,-7,8 14 | Canada,10,10,10,10,10,10,10,10,10 15 | Chile,2,5,5,6,6,-7,-7,-6,8 16 | China,-8,-8,-8,-9,-8,-7,-7,-7,-7 17 | Colombia,-5,7,7,7,7,8,8,8,9 18 | Costa Rica,10,10,10,10,10,10,10,10,10 19 | Croatia,-7,-7,-7,-7,-7,-7,-5,-5,-3 20 | Cuba,0,-9,-7,-7,-7,-7,-7,-7,-7 21 | Czech Rep.,-7,-7,-7,-7,-7,-7,-7,-7,8 22 | Denmark,10,10,10,10,10,10,10,10,10 23 | Dominican Rep.,-9,-9,8,-3,-3,-3,6,6,6 24 | Ecuador,2,2,-1,-1,-5,-5,9,8,9 25 | Egypt,-7,-7,-7,-7,-7,-6,-6,-6,-6 26 | El Salvador,-6,-5,-3,0,-1,-6,2,6,7 27 | Estonia,-9,-7,-7,-7,-7,-7,-7,-7,6 28 | Ethiopia,-9,-9,-9,-9,-9,-7,-7,-8,0 29 | Finland,10,10,10,10,10,10,10,10,10 30 | France,10,10,5,5,8,8,8,9,9 31 | Georgia,-9,-7,-7,-7,-7,-7,-7,-7,4 32 | Germany,10,10,10,10,10,10,10,10,10 33 | Greece,4,4,4,-7,-7,8,8,10,10 34 | Guatemala,2,-6,-5,3,1,-3,-7,3,3 35 | Haiti,-5,-5,-9,-9,-10,-9,-9,-8,-7 36 | Honduras,-3,-1,-1,-1,-1,-1,6,5,6 37 | Hungary,-7,-7,-7,-7,-7,-7,-7,-7,10 38 | India,9,9,9,9,9,8,8,8,8 39 | Indonesia,0,-1,-5,-7,-7,-7,-7,-7,-7 40 | Iran,-1,-10,-10,-10,-10,-10,-6,-6,-6 41 | Iraq,-4,-4,-5,-5,-7,-7,-9,-9,-9 42 | Ireland,10,10,10,10,10,10,10,10,10 43 | Israel,10,10,10,9,9,9,9,9,9 44 | Italy,10,10,10,10,10,10,10,10,10 45 | Japan,10,10,10,10,10,10,10,10,10 46 | Jordan,-1,-9,-9,-9,-9,-10,-10,-9,-2 47 | Kazakhstan,-9,-7,-7,-7,-7,-7,-7,-7,-3 48 | "Korea, Dem. Rep.",-7,-8,-8,-9,-9,-9,-9,-9,-9 49 | "Korea, Rep.",-4,-4,-7,3,-9,-8,-5,1,6 50 | Kyrgyzstan,-9,-7,-7,-7,-7,-7,-7,-7,-3 51 | Latvia,-9,-7,-7,-7,-7,-7,-7,-7,8 52 | Lebanon,2,2,2,2,5,0,0,0,0 53 | Liberia,-6,-6,-6,-6,-6,-6,-7,-6,0 54 | Libya,-7,-7,-7,-7,-7,-7,-7,-7,-7 55 | Lithuania,-9,-7,-7,-7,-7,-7,-7,-7,10 56 | "Macedonia, FYR",-7,-7,-7,-7,-7,-7,-5,-5,6 57 | Mexico,-6,-6,-6,-6,-6,-3,-3,-3,0 58 | Moldova,-9,-7,-7,-7,-7,-7,-7,-7,5 59 | Mongolia,-7,-7,-7,-7,-7,-7,-7,-7,9 60 | Montenegro,-7,-7,-7,-7,-7,-7,-5,-5,-5 61 | Myanmar,8,8,-6,-7,-7,-6,-8,-8,-7 62 | Nepal,-7,-4,-9,-9,-9,-9,-2,-2,5 63 | Netherlands,10,10,10,10,10,10,10,10,10 64 | New Zealand,10,10,10,10,10,10,10,10,10 65 | Nicaragua,-8,-8,-8,-8,-8,-8,-5,-1,6 66 | Norway,10,10,10,10,10,10,10,10,10 67 | Oman,-6,-10,-10,-10,-10,-10,-10,-10,-9 68 | Pakistan,5,8,1,1,4,-7,-7,-4,8 69 | Panama,-1,4,4,4,-7,-7,-5,-8,8 70 | Paraguay,-5,-9,-9,-8,-8,-8,-8,-8,7 71 | Peru,-2,5,-6,5,-7,-7,7,7,-3 72 | Philippines,5,5,5,5,-9,-9,-7,8,8 73 | Poland,-7,-7,-7,-7,-7,-7,-8,-6,8 74 | Portugal,-9,-9,-9,-9,-9,9,10,10,10 75 | Romania,-7,-7,-7,-7,-7,-8,-8,-8,5 76 | Russia,-9,-7,-7,-7,-7,-7,-7,-7,5 77 | Saudi Arabia,-10,-10,-10,-10,-10,-10,-10,-10,-10 78 | Serbia,-7,-7,-7,-7,-7,-7,-5,-5,-5 79 | Slovak Republic,-7,-7,-7,-7,-7,-7,-7,-7,8 80 | Slovenia,-7,-7,-7,-7,-7,-7,-5,-5,10 81 | South Africa,4,4,4,4,4,4,4,4,6 82 | Spain,-7,-7,-7,-7,-7,5,10,10,10 83 | Sri Lanka,7,7,7,7,8,8,5,5,5 84 | Sweden,10,10,10,10,10,10,10,10,10 85 | Switzerland,10,10,10,10,10,10,10,10,10 86 | Syria,-7,7,-2,-7,-9,-9,-9,-9,-9 87 | Taiwan,-8,-8,-8,-8,-8,-7,-7,-1,7 88 | Tajikistan,-9,-7,-7,-7,-7,-7,-7,-7,-6 89 | Thailand,-6,-3,-7,-7,-7,-2,2,2,9 90 | Turkey,7,4,9,8,-2,9,-5,7,9 91 | Turkmenistan,-9,-7,-7,-7,-7,-7,-7,-7,-9 92 | Ukraine,-9,-7,-7,-7,-7,-7,-7,-7,6 93 | United Kingdom,10,10,10,10,10,10,10,10,10 94 | United States,10,10,10,10,10,10,10,10,10 95 | Uruguay,8,8,8,8,-3,-8,-7,9,10 96 | Uzbekistan,-9,-7,-7,-7,-7,-7,-7,-7,-9 97 | Venezuela,-3,-3,6,6,9,9,9,9,8 98 | --------------------------------------------------------------------------------