-
Notifications
You must be signed in to change notification settings - Fork 7
178 lines (154 loc) · 5.6 KB
/
test_fredi.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
### https://github.com/actions/upload-artifact
### https://github.blog/changelog/2021-11-10-github-actions-input-types-for-manual-workflows/
### https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows
### https://github.com/r-lib/actions/tree/v2/setup-r-dependencies
### https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution
### For uploading artifacts:
### "path:" is the output path where Pandoc will write the compiled PDF.
### Note, this should be the same directory as the input paper.md
name: Test FrEDI Package
# on: [workflow_dispatch]
on:
workflow_dispatch:
inputs:
run_tests:
type: choice
description: Run general tests
required: true
options:
- no
- yes
make_figures:
type: choice
description: Create report figures
required: true
options:
- no
- yes
jobs:
compile_data:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
name: Load Package Code
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Send input status
run: |
echo "${{ inputs.run_tests }} ${{ inputs.make_figures }}"
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Setup R package dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
cache: true
cache-version: 1
packages: |
any::tidyverse
any::ggpubr
any::openxlsx
any::devtools
- name: Install FrEDI
run: |
Rscript -e '
devtools::install_github(
repo = "https://github.com/USEPA/FrEDI",
ref = "${{ github.ref_name }}",
subdir = "FrEDI",
dependencies = FALSE,
upgrade = "never",
force = TRUE,
type = "source"
)'
- name: Run create_DoW_results
run: |
Rscript -e '
### Which tests to do
do_tests <- "${{ inputs.run_tests }}" == "true"
do_figs <- "${{ inputs.make_figures }}" == "true"
### Main repo path, FrEDI project path, scripts path
rPath0 <- ".";
pPath0 <- rPath0 |> file.path("FrEDI")
sPath0 <- pPath0 |> file.path("scripts")
rPath0 |> list.files() |> print()
pPath0 |> list.files() |> print()
sPath0 |> list.files() |> print()
### Load FrEDI
pPath0 |> devtools::load_all()
### Where to save results
oPath0 <- pPath0 |> file.path("data_tests")
oPath1 <- oPath0 |> file.path("general")
oPath2 <- oPath0 |> file.path("report_figures")
### Test results
if(do_tests){
### Check if path exists and, if not, create it
exists0 <- oPath1 |> dir.exists()
if(!exists0){oPath1 |> dir.create(recursive = TRUE)}
### Run FrEDI
results0 <- run_fredi()
### Run tests
tests0 <- results0 |> general_fredi_test(
outPath = oPath1,
save = TRUE,
return = TRUE,
overwrite = TRUE
)
### Create plot totals
listResults <- create_default_tablePlot()
save0 <- listResults |> save(file= oPath1 |> file.path("defaultScenarioTotals.rda")) |> try()
### Remove results
rm(results0, tests0, listResults)
}
### Create report results
if(do_figs){
### Load source
sPath0 |> file.path("create_DoW_results.R") |> source()
### Check if path exists and, if not, create it
exists0 <- oPath2 |> dir.exists()
if(!exists0){oPath2 |> dir.create(recursive = TRUE)}
### Create report figures
reports0 <- create_DoW_results(
outPath = oPath2,
saveFile = TRUE,
loadCode = "project",
silent = FALSE,
testing = TRUE,
return = FALSE,
fpath = pPath0
)
### Figure H results
results0 <- run_fredi(aggLevels=c("modelaverage", "national"))
results0 <- results0 |> filter(year %in% seq(2010, 2090, by=5))
save0 <- write.csv(results0, file=oPath1 |> file.path("FigH_results.csv", row.names=F)) |> try()
}
'
- name: Upload Tests
if: |
inputs.run_tests == 'true'
uses: actions/upload-artifact@v3
with:
name: Test Data
path: |
./FrEDI/data_tests/general/defaultScenarioTotals.rda
./FrEDI/data_tests/general/testResults_fredi_general.xlsx
- name: Upload Report Figures
if: |
inputs.make_figures == 'true'
uses: actions/upload-artifact@v3
with:
name: Report Data
path: |
./FrEDI/data_tests/report_figures/
./FrEDI/data_tests/general/FigH_results.csv
# #
# - name: Commit results
# run: |
# git config --local core.autocrlf false
# git config --local user.email "${{ github.actor }}@users.noreply.github.com"
# git config --local user.name "${{ github.actor }}"
# git add data/tmp_sysdata.rda
# git add data_tests/**.xlsx
# git pull origin ${{ github.head_ref }} --autostash --rebase -X ours
# git commit -a -m "Updated temporary system data and tests"
# git push