Skip to content

Commit

Permalink
Set up a GitHub Actions workflow to run on some example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kdorheim committed Jun 11, 2024
1 parent e8a758d commit c4a05e3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/run-r-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run R Test

on:
push:
branches:
- main
pull_request:
branches:
- '**'

jobs:
run-r-script:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: '4.3.3' # specify the version of R you need

- name: Install R packages
run: |
Rscript -e 'install.packages(c("here", "assertthat"))' # Add any packages your script needs
- name: Run R script
run: |
Rscript scripts/ex_test.R
8 changes: 8 additions & 0 deletions scripts/ex_fxns.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
hello_world <- function(){
return("hello world")
}

my_sum <- function(a, b){
return(sum(a,b))
}

15 changes: 15 additions & 0 deletions scripts/ex_test.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# load the functions
source(here::here("scripts", "ex_fxns.R"))

library(assertthat)


# Let's test to see if the right things are returne
assert_that(is.string(hello_world()))
assert_that(is.numeric(my_sum(1, 2)))

# Checking to see if the expected value is returned
assert_that(my_sum(1, 2) == 9)


0 comments on commit c4a05e3

Please sign in to comment.