Skip to content

Commit e43e90a

Browse files
authored
Merge pull request #1081 from cmu-delphi/fb-package-automate-tests
Add workflow to automate fb package testing
2 parents 528353b + a4b435f commit e43e90a

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

.github/workflows/python-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Python package
55

66
on:
77
push:
8-
branches: [ main, prod, 'release/*' ]
8+
branches: [ main, prod ]
99
pull_request:
1010
types: [ opened, synchronize, reopened, ready_for_review ]
1111
branches: [ main, prod ]

.github/workflows/r-ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
#
6+
# See https://github.com/r-lib/actions/tree/master/examples#readme for
7+
# additional example workflows available for the R community.
8+
9+
name: R facebook survey
10+
11+
on:
12+
push:
13+
branches: [ main, prod ]
14+
pull_request:
15+
types: [ opened, synchronize, reopened, ready_for_review ]
16+
branches: [ main, prod ]
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-20.04
21+
if: github.event.pull_request.draft == false
22+
strategy:
23+
matrix:
24+
r-version: [4.0]
25+
defaults:
26+
run:
27+
working-directory: facebook/delphiFacebook
28+
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Set up R ${{ matrix.r-version }}
32+
uses: r-lib/actions/setup-r@v1
33+
with:
34+
r-version: ${{ matrix.r-version }}
35+
- name: Install linux dependencies
36+
run: |
37+
sudo apt-get install libcurl4-openssl-dev
38+
- name: Get month
39+
id: get-month
40+
run: |
41+
echo "::set-output name=month::$(/bin/date -u "+%Y%m")"
42+
- name: Cache R packages
43+
uses: actions/cache@v2
44+
with:
45+
path: ${{ env.R_LIBS_USER }}
46+
key: ${{ runner.os }}-r-facebook-survey-${{ steps.get-month.outputs.month }}
47+
restore-keys: |
48+
${{ runner.os }}-r-facebook-survey-
49+
- name: Install R dependencies
50+
run: |
51+
install.packages("remotes")
52+
remotes::update_packages(c("rcmdcheck", "mockr"), dependencies=TRUE, upgrade="always")
53+
dependency_list <- remotes::dev_package_deps(dependencies=TRUE)
54+
remotes::update_packages(dependency_list$package, dependencies=TRUE, upgrade="always")
55+
shell: Rscript {0}
56+
- name: Check
57+
run: |
58+
rcmdcheck::rcmdcheck(args = c("--no-manual", "--test-dir=unit-tests"), error_on = "error")
59+
shell: Rscript {0}

facebook/delphiFacebook/unit-tests/testthat/test-variables.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ test_that("mask items correctly coded", {
8686
input_data$c_mask_often_7d <- NA
8787
input_data$c_others_masked <- c(TRUE, NA, NA, FALSE, TRUE, FALSE)
8888
input_data$c_others_masked_public <- NA
89+
input_data$c_others_distanced_public <- NA
8990
input_data$c_work_outside_5d <- NA
9091

9192
expect_equal(out, input_data)
@@ -105,6 +106,7 @@ test_that("mask items correctly coded", {
105106
input_data$c_mask_often_7d <- c(NA, TRUE, FALSE, NA, TRUE, FALSE)
106107
input_data$c_others_masked <- c(TRUE, NA, NA, FALSE, TRUE, FALSE)
107108
input_data$c_others_masked_public <- NA
109+
input_data$c_others_distanced_public <- NA
108110
input_data$c_work_outside_5d <- NA
109111

110112
expect_equal(out, input_data)
@@ -125,6 +127,7 @@ test_that("mask items correctly coded", {
125127
input_data$c_mask_often_7d <- NA
126128
input_data$c_others_masked <- c(TRUE, NA, NA, FALSE, TRUE, FALSE)
127129
input_data$c_others_masked_public <- NA
130+
input_data$c_others_distanced_public <- NA
128131
input_data$c_work_outside_5d <- NA
129132

130133
expect_equal(out, input_data)
@@ -133,6 +136,7 @@ test_that("mask items correctly coded", {
133136
input_data <- data.frame(
134137
C14 = c(NA, 1, 3, 6, 2, 4),
135138
H2 = c(1, NA, 6, 3, 2, 5),
139+
H1 = c(1, NA, 6, 3, 2, 5),
136140
C6a = 1
137141
)
138142

@@ -145,6 +149,7 @@ test_that("mask items correctly coded", {
145149
input_data$c_mask_often_7d <- NA
146150
input_data$c_others_masked <- NA
147151
input_data$c_others_masked_public <- c(FALSE, NA, NA, FALSE, FALSE, TRUE)
152+
input_data$c_others_distanced_public <- c(FALSE, NA, NA, FALSE, FALSE, TRUE)
148153
input_data$c_work_outside_5d <- NA
149154

150155
expect_equal(out, input_data)

0 commit comments

Comments
 (0)