diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..8c6dd4f --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,48 @@ +# This is a basic workflow to help you get started with Actions +name: R Conda (with codecov) + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ master] + pull_request: + branches: [ master] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -l {0} + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + - name: Create conda environment + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: mfassignr-dev + auto-update-conda: true + environment-file: conda/environment-dev.yaml + auto-activate-base: false + - run: | + conda init bash + conda env list + + - name: Test coverage + run: | + conda activate mfassignr-dev + cd MFAssignR/ + Rscript -e "covr::codecov(quiet = FALSE)" diff --git a/MFAssignR/data/CHNOS_ML_Ex.rda b/MFAssignR/inst/data/CHNOS_ML_Ex.rda similarity index 100% rename from MFAssignR/data/CHNOS_ML_Ex.rda rename to MFAssignR/inst/data/CHNOS_ML_Ex.rda diff --git a/MFAssignR/data/Raw_Neg_ML.rda b/MFAssignR/inst/data/Raw_Neg_ML.rda similarity index 100% rename from MFAssignR/data/Raw_Neg_ML.rda rename to MFAssignR/inst/data/Raw_Neg_ML.rda diff --git a/MFAssignR/data/Short_CHO_neg.rda b/MFAssignR/inst/data/Short_CHO_neg.rda similarity index 100% rename from MFAssignR/data/Short_CHO_neg.rda rename to MFAssignR/inst/data/Short_CHO_neg.rda diff --git a/MFAssignR/data/Short_CHO_pos.rda b/MFAssignR/inst/data/Short_CHO_pos.rda similarity index 100% rename from MFAssignR/data/Short_CHO_pos.rda rename to MFAssignR/inst/data/Short_CHO_pos.rda diff --git a/MFAssignR/tests/testthat/test-HistNoise.R b/MFAssignR/tests/testthat/test-HistNoise.R index ded2a86..2d25736 100644 --- a/MFAssignR/tests/testthat/test-HistNoise.R +++ b/MFAssignR/tests/testthat/test-HistNoise.R @@ -1,6 +1,9 @@ test_that("HistNoise works", { - load("../../data/Raw_Neg_ML.rda") + load(system.file("data", "Raw_Neg_ML.rda", + package = "MFAssignR", + mustWork = TRUE + )) actual <- HistNoise(Raw_Neg_ML) expect_equal(actual$Noise, 317.3483, tolerance = 1e-4) }) diff --git a/MFAssignR/tests/testthat/test-IsoFiltR.R b/MFAssignR/tests/testthat/test-IsoFiltR.R index 07f6cc7..088fec0 100644 --- a/MFAssignR/tests/testthat/test-IsoFiltR.R +++ b/MFAssignR/tests/testthat/test-IsoFiltR.R @@ -1,5 +1,8 @@ test_that("Isotope filtering works", { - load("../../data/Raw_Neg_ML.rda") + load(system.file("data", "Raw_Neg_ML.rda", + package = "MFAssignR", + mustWork = TRUE + )) expected <- readRDS("test-data/isotopes.rda") actual <- IsoFiltR(Raw_Neg_ML) diff --git a/MFAssignR/tests/testthat/test-KMDNoise.R b/MFAssignR/tests/testthat/test-KMDNoise.R index b0295df..5176f09 100644 --- a/MFAssignR/tests/testthat/test-KMDNoise.R +++ b/MFAssignR/tests/testthat/test-KMDNoise.R @@ -1,5 +1,8 @@ test_that("KMDNoise works", { - load("../../data/Raw_Neg_ML.rda") + load(system.file("data", "Raw_Neg_ML.rda", + package = "MFAssignR", + mustWork = TRUE + )) names(Raw_Neg_ML) <- c("mass", "intensity") actual <- KMDNoise(Raw_Neg_ML) expect_equal(actual$Noise, 346.0706, tolerance = 1e-4) diff --git a/environment.yaml b/conda/environment-dev.yaml similarity index 95% rename from environment.yaml rename to conda/environment-dev.yaml index c50b46b..45d4b31 100644 --- a/environment.yaml +++ b/conda/environment-dev.yaml @@ -12,3 +12,4 @@ dependencies: - r-devtools - r-languageserver - radian +- r-covr