diff --git a/.github/workflows/test_fredi.yml b/.github/workflows/test_fredi.yml index 0c3405a2..2ce66829 100644 --- a/.github/workflows/test_fredi.yml +++ b/.github/workflows/test_fredi.yml @@ -74,9 +74,10 @@ jobs: upgrade = "never", force = TRUE, type = "source" - )' + ) + ' - - name: Set paths and load FrEDI + - name: Run tests & create figures run: | Rscript -e ' ### Main repo path, FrEDI project path, scripts path @@ -92,6 +93,9 @@ jobs: tFiles0 <- tPath0 |> list.files(full.names=TRUE) for(file_i in tFiles0){file_i |> source(); rm(file_i)} + ### Load source + sPath0 |> file.path("create_DoW_results.R") |> source() + ### Which tests to do do_tests <- "${{ inputs.run_tests }}" == "true" do_figH <- "${{ inputs.figH_results }}" == "true" @@ -111,11 +115,7 @@ jobs: if(!exists0){ oPath0 |> dir.create(recursive = TRUE)} if(!exists1){ oPath1 |> dir.create(recursive = TRUE)} if(!exists2){ oPath2 |> dir.create(recursive = TRUE)} - ' - - name: Run tests - run: | - Rscript -e ' ### Test results if(do_tests){ ### Run FrEDI @@ -136,6 +136,34 @@ jobs: ### Remove results rm(exists0, results0, tests0, listResults, save0) } ### End if(do_tests) + + ### Create Fig H results + if(do_figH){ + ### Figure H results + results0 <- run_fredi(aggLevels=c("modelaverage", "national", "impactYear")) + results0 <- results0 |> filter(year %in% seq(2010, 2090, by=5)) + save0 <- results0 |> write.csv(file=oPath2 |> file.path("FigH_results.csv"), row.names=F) |> try() + + ### Remove reslts + rm(results0, save0) + } ### End if(do_figH) + + ### Create report figures + if(do_figs){ + ### Load source + sPath0 |> file.path("create_DoW_results.R") |> source() + + ### Create report figures + reports0 <- create_DoW_results( + outPath = oPath2, + saveFile = TRUE, + loadCode = "project", + silent = FALSE, + testing = TRUE, + return = FALSE, + fpath = pPath0 + ) + } ### End if(do_figs) ' - name: Upload Tests @@ -148,57 +176,23 @@ jobs: ./FrEDI/data_tests/general/defaultScenarioTotals.rda ./FrEDI/data_tests/general/testResults_fredi_general.xlsx - - name: Get FigH results - run: | - Rscript -e ' - ### Create report results - if(do_figH){ - ### Figure H results - results0 <- run_fredi(aggLevels=c("modelaverage", "national", "impactYear")) - results0 <- results0 |> filter(year %in% seq(2010, 2090, by=5)) - save0 <- results0 |> write.csv(file=oPath2 |> file.path("FigH_results.csv"), row.names=F) |> try() - - ### Remove reslts - rm(results0, save0) - } - ' - - name: Upload Report Figures + - name: Upload FigH Results if: | inputs.figH_results == 'true' uses: actions/upload-artifact@v3 with: - name: Fig H results + name: FigH results path: | ./FrEDI/data_tests/report_figures/ - - name: Run create_DoW_results - run: | - Rscript -e ' - ### Create report results - if(do_figs){ - ### Load source - sPath0 |> file.path("create_DoW_results.R") |> source() - - ### Create report figures - reports0 <- create_DoW_results( - outPath = oPath2, - saveFile = TRUE, - loadCode = "project", - silent = FALSE, - testing = TRUE, - return = FALSE, - fpath = pPath0 - ) - } - ' - - name: Upload Report Figures + - name: Upload Other Report Figures if: | inputs.make_figures == 'true' uses: actions/upload-artifact@v3 with: - name: Report Data + name: Other Report Figures & Data path: | ./FrEDI/data_tests/report_figures/ # ./FrEDI/data_tests/general/FigH_results.csv