-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (163 loc) · 6.54 KB
/
main.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# Analysis workflow code
name: Analysis CI # ===========================================================
on: # controls when the workflow will run
push: # trigger workflow on push events, but only for the master branch
branches: [ master ]
paths-ignore:
- "README.md" # don't rebuild on documentation changes
pull_request: # triggers workflow on pull request events (master branch only)
branches: [ master ] # ensure changes are "mergeable"
workflow_dispatch: # permits manual triggers from the Actions tab
jobs: # =======================================================================
# ---------------------------------------------------------------------------
fit: # fit Bayesian models and apply Horvitz–Thompson estimators
# ---------------------------------------------------------------------------
strategy:
matrix:
rfiles: [example-1/complete, example-1/null, example-1/ht,
example-2/hrs_wyppt_mm, example-2/wyppt_mm, example-2/ht,
example-3/canopy-gaps-2021, example-3/canopy-gaps-naive-2021,
example-3/ht]
runs-on: ubuntu-latest
steps:
# Checkout the repo so the workflow can access it
- name: Checkout this repo's action(s)
uses: actions/checkout@v2
# Pull the needed, protected data from the NPS Data Store
# At the moment this is VERY inefficient because it's repeated for each job
- name: Get protected data from the Data Store
run: |
./get-inputs.sh
ls -R
# Run analyses and compile results
- name: Fit models and compile results
id: compile
uses: ./.github/actions/call-r
with:
rfile: ${{ matrix.rfiles }}/calling-script.R
# # Replace slashes with dashes in rfile path (for valid artifact names)
# - name: Run find-and-replace to remove slashes
# uses: mad9000/actions-find-and-replace-string@1
# id: findandreplace
# with:
# source: ${{ matrix.rfiles }}
# find: '/'
# replace: '-'
# Each artifact behaves as a file share. Uploading to the same artifact
# multiple times in the same workflow can overwrite and append already
# uploaded files.
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: artifact-${{ github.sha }} # ${{ steps.findandreplace.outputs.value }}-artifact
path: output # ${{ github.workspace }}
retention-days: 1
# ---------------------------------------------------------------------------
design: # study area map and missingness concept figs
# ---------------------------------------------------------------------------
# strategy:
# matrix:
# rfiles: [map.R, panel-design/cartoon.R]
runs-on: ubuntu-latest
steps:
# Checkout the repo so the workflow can access it
- name: Checkout this repo's action(s)
uses: actions/checkout@v2
# Download and unpack NPS boundaries
- name: Download geospatial data
run: |
wget -P assets https://irma.nps.gov/DataStore/DownloadFile/662130
unzip assets/662130 -d assets/nps_boundary
rm assets/662130
# Use leaflet to create study area map
- name: Create map
uses: ./.github/actions/call-r
with:
rfile: map.R
# Create concept figure for revisit design
- name: Revisit schedule
uses: ./.github/actions/call-r
with:
rfile: panel-design/cartoon.R
# Push changes made to the repo during a workflow run
- name: Commit context figs
uses: EndBug/add-and-commit@v7
with:
default_author: github_actions
branch: master
add: "assets/*.jpg"
message: Automatic update of map
# ---------------------------------------------------------------------------
visualize: # use outputs from previous job to develop manuscript figures
# ---------------------------------------------------------------------------
needs: fit
strategy:
matrix:
plotters: [example-1, example-2, example-3]
runs-on: ubuntu-latest
steps:
# Checkout the repo so the workflow can access it
- name: Checkout this repo's action(s)
uses: actions/checkout@v2
with:
lfs: true
# Cache LFS assets
- name: generate lfs file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: restore lfs cache
uses: actions/cache@v2
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
- name: pull lfs files
run: git lfs pull
# Download artifacts
- name: Download file share
uses: actions/download-artifact@v2
with:
name: artifact-${{ github.sha }}
path: output
- name: Display structure of downloaded files
run: ls -R
# Use the cached results
- name: Use cached results
# id: publish
uses: ./.github/actions/call-r
with:
rfile: ${{ matrix.plotters }}/plotting.R
# # Delete temporary file store
# - uses: geekyeggo/delete-artifact@v1
# with:
# name: artifact-${{ github.sha }}
# # failOnError: false
# Upload results
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.plotters }}-results # was: ${{ steps.findandreplace.outputs.value }}-artifact
path: assets/${{ matrix.plotters }}
retention-days: 1
# Push changes made to the repo during a workflow run
- name: Commit changes
uses: EndBug/add-and-commit@v7
with:
default_author: github_actions
branch: master
add: "assets/${{ matrix.plotters }}/example-*-fig*.jpg" # --force
message: Automatic update of all tracked analysis assets
# push: origin assets --force
# # Use the output from the `publish` step
# - name: Get task completion time
# run: echo "The time was ${{ steps.publish.outputs.time }}"
# ---------------------------------------------------------------------------
cleanup: # misc housekeeping
# ---------------------------------------------------------------------------
needs: [fit, visualize]
runs-on: ubuntu-latest
steps:
# Delete temporary file store
- uses: geekyeggo/delete-artifact@v1
with:
name: artifact-${{ github.sha }}
# failOnError: false