forked from european-modelling-hubs/RespiCompass
-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (129 loc) · 5.35 KB
/
validate_submission.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
name: Validate Submissions
# Activate the validation process on pull-requests for model-output data submissions or on meta-data changes
on:
pull_request_target:
branches:
- main
paths:
- 'model-output/**'
- 'model-metadata/*'
- '!**README**'
- '!**.md'
- '!**.MD'
jobs:
validate-submission_job:
runs-on: ubuntu-latest
outputs:
changed_files: ${{ steps.get_changed_files.outputs.all_changed_files }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
# Setup R env
# ---------------------------------
- uses: r-lib/actions/setup-r@v2
with:
install-r: false
use-public-rspm: true
# Install hubValidations package from HubVerse
# ----------------------------------------------
- uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: hubverse-org/hubValidations, any::sessioninfo
# Install System dependencies
# ---------------------------------
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev libv8-dev
# Install Pyton env and lib
# ---------------------------
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install pandas pyarrow
# checkout the repository with reference to the SHA of the HEAD
# commit of the branch that is being merged into the Base
# ------------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1
# Get changes from pull request for later use
# --------------------------------------------
- name: Get changes
id: get_changed_files
uses: tj-actions/changed-files@v41
# Checkout the python tools repo
# -------------------------------------------
- name: checkout python tools repo
uses: actions/checkout@v3
with:
repository: 'european-modelling-hubs/hub-tools'
ref: 'main'
path: './tools/'
# Trace changes
# ---------------------------------
- name: List all changed files
run: |
for file in ${{ steps.get_changed_files.outputs.all_changed_files }}; do
echo "$file was changed"
done
# Validate data submission
# ---------------------------------
- name: Run validations
env:
files: ${{ steps.get_changed_files.outputs.all_changed_files }}
PR_NUMBER: ${{ github.event.number }}
run: |
library("hubValidations")
v <- hubValidations::validate_pr(
gh_repo = Sys.getenv("GITHUB_REPOSITORY"),
pr_number = Sys.getenv("PR_NUMBER"),
skip_submit_window_check = FALSE,
derived_task_ids = c("target_end_date", "pop_group")
)
hubValidations::check_for_errors(v, verbose = TRUE)
shell: Rscript {0}
# Validate derived_task_ids since their validation
# is currently skipped in the validate_pr
- name: Validate derived task ids
env:
input_list: ${{ steps.get_changed_files.outputs.all_changed_files }}
run: |
python ./tools/code/validate_derived_task_ids.py
# Eventually comment on it
# ---------------------------
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
All validation checks completed successfully.
pr_number: ${{ github.event.pull_request.number }}
# Approve the pull request
# ---------------------------
- name: Approve Pull Request
uses: juliangruber/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
# And then finally do the merge
# -------------------------------
- name: Merge the pull request
id: merge_pr
run: |
echo ">>> Merging PR URL: ${{ github.event.pull_request.html_url }}"
gh pr merge --auto --squash $PR_URL
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ github.token }}
# As a last step, call a job that persists changes from the pull-request
# to a json db for further upload to the web-server platform
call-persisting-wf_job:
needs: validate-submission_job
uses: european-modelling-hubs/RespiCompass/.github/workflows/persist_changes.yml@main
with:
changes-list: ${{ needs.validate-submission_job.outputs.changed_files }}
secrets:
envPAT: ${{ secrets.GITHUB_TOKEN }}