-
Notifications
You must be signed in to change notification settings - Fork 29
227 lines (221 loc) · 8.97 KB
/
diff.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: 'Create ROBOT diffs on Pull requests'
on:
issue_comment:
types: [created]
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
branch_status:
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- uses: khan/[email protected]
id: check
with:
trigger: '#gogoeditdiff'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
# Checks-out current branch
- uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
- uses: actions/checkout@v4
if: steps.check.outputs.triggered == 'true'
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
# Checks-out master branch under "master" directory
- uses: actions/checkout@v4
if: steps.check.outputs.triggered == 'true'
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
fetch-depth: 0
- name: Check current branch status
if: steps.check.outputs.triggered == 'true'
id: info
run: |
echo "status=$(git rev-list --left-right --count origin/$DEFAULT_BRANCH...origin/`git branch --show-current` | awk '{print $1}')"
echo "status=$(git rev-list --left-right --count origin/$DEFAULT_BRANCH...origin/`git branch --show-current` | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Warn users with a comment
if: steps.info.outputs.status >= 1
run: echo "Your branch is ${{ steps.info.outputs.status }} commit/s behind, please update your branch." > warncomment.md
- name: Post comment
if: steps.info.outputs.status >= 1 && steps.check.outputs.triggered == 'true'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
uses: NejcZdovc/comment-pr@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
file: "../../warncomment.md"
- name: Fail step if branch is behind
if: steps.info.outputs.status >= 1 && steps.check.outputs.triggered == 'true'
run: |
echo "Your branch is ${{ steps.info.outputs.status }} commit/s behind, please update your branch."
exit 1
edit_file:
needs: [branch_status]
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5.3
steps:
- uses: khan/[email protected]
id: check
with:
trigger: '#gogoeditdiff'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
- uses: actions/checkout@v4
if: steps.check.outputs.triggered == 'true'
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
path: branch
- uses: actions/checkout@v4
if: steps.check.outputs.triggered == 'true'
with:
ref: master
path: master
- name: Diff classification
if: steps.check.outputs.triggered == 'true'
run: export ROBOT_JAVA_ARGS='-Xmx9G'; robot diff --labels True --left master/src/ontology/uberon-edit.obo --left-catalog master/src/ontology/catalog-v001.xml --right branch/src/ontology/uberon-edit.obo --right-catalog branch/src/ontology/catalog-v001.xml -f markdown -o edit-diff.md
- name: Upload diff
if: steps.check.outputs.triggered == 'true'
uses: actions/upload-artifact@v4
with:
name: edit-diff.md
path: edit-diff.md
classify_branch:
needs: [branch_status]
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5.3
steps:
- uses: khan/[email protected]
id: check
with:
trigger: '#gogoeditdiff'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
- uses: actions/checkout@v4
if: steps.check.outputs.triggered == 'true'
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
- name: Classify ontology PR branch
if: steps.check.outputs.triggered == 'true'
run: export ROBOT_JAVA_ARGS='-Xmx9G'; cd src/ontology; make BRI=false MIR=false PAT=false IMP=false COMP=false uberon-base.owl > TESTLOG.log
- name: Upload classified ontology in PR branch
if: steps.check.outputs.triggered == 'true'
uses: actions/upload-artifact@v4
with:
name: uberon-base-pr.owl
path: src/ontology/uberon-base.owl
retention-days: 1
classify_main:
needs: [branch_status]
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5.3
steps:
- uses: khan/[email protected]
id: check
with:
trigger: '#gogoeditdiff'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- uses: actions/checkout@v4
if: steps.check.outputs.triggered == 'true'
with:
ref: master
- name: Classify ontology main branch
if: steps.check.outputs.triggered == 'true'
run: export ROBOT_JAVA_ARGS='-Xmx9G'; cd src/ontology; make BRI=false MIR=false PAT=false IMP=false COMP=false uberon-base.owl > TESTLOG.log
- name: Upload classified ontology main branch
if: steps.check.outputs.triggered == 'true'
uses: actions/upload-artifact@v4
with:
name: uberon-base-main.owl
path: src/ontology/uberon-base.owl
retention-days: 1
diff_classification:
needs: [classify_branch, classify_main]
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5.3
steps:
- uses: khan/[email protected]
id: check
with:
trigger: '#gogoeditdiff'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- uses: actions/checkout@v4
if: steps.check.outputs.triggered == 'true'
- name: Download classified ontology main branch
if: steps.check.outputs.triggered == 'true'
uses: actions/download-artifact@v4
with:
name: uberon-base-main.owl
path: src/ontology/uberon-base-main.owl
- name: Download classified ontology in PR branch
if: steps.check.outputs.triggered == 'true'
uses: actions/download-artifact@v4
with:
name: uberon-base-pr.owl
path: src/ontology/uberon-base-pr.owl
- name: Diff classification
if: steps.check.outputs.triggered == 'true'
run: export ROBOT_JAVA_ARGS='-Xmx9G'; cd src/ontology; robot diff --labels True --left uberon-base-main.owl/uberon-base.owl --left-catalog catalog-v001.xml --right uberon-base-pr.owl/uberon-base.owl --right-catalog catalog-v001.xml -f markdown -o classification-diff.md
- name: Upload diff
if: steps.check.outputs.triggered == 'true'
uses: actions/upload-artifact@v4
with:
name: classification-diff.md
path: src/ontology/classification-diff.md
post_comment:
needs: [edit_file, diff_classification]
runs-on: ubuntu-latest
steps:
- uses: khan/[email protected]
id: check
with:
trigger: '#gogoeditdiff'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- uses: actions/checkout@v4
if: steps.check.outputs.triggered == 'true'
- name: Download reasoned diff
if: steps.check.outputs.triggered == 'true'
uses: actions/download-artifact@v4
with:
name: classification-diff.md
- name: Prepare reasoned comment
if: steps.check.outputs.triggered == 'true'
run: "echo \"<details>\n <summary> Here's a diff of how these changes impact the classified ontology (on -base file): </summary> \n\" > comment.md; cat classification-diff.md >> comment.md"
- name: Post reasoned comment
if: steps.check.outputs.triggered == 'true'
uses: NejcZdovc/[email protected]
with:
file: "../../comment.md"
identifier: "REASONED"
github_token: ${{secrets.GITHUB_TOKEN}}
- uses: actions/checkout@v4
if: steps.check.outputs.triggered == 'true'
- name: Download edit diff
if: steps.check.outputs.triggered == 'true'
uses: actions/download-artifact@v4
with:
name: edit-diff.md
- name: Prepare edit file comment
if: steps.check.outputs.triggered == 'true'
run: "echo \"<details>\n <summary> Here's a diff of your edit file (unreasoned) </summary> \n\" > edit-comment.md; cat edit-diff.md >> edit-comment.md"
- name: Post comment
if: steps.check.outputs.triggered == 'true'
uses: NejcZdovc/[email protected]
with:
file: "../../edit-comment.md"
identifier: "UNREASONED"
github_token: ${{secrets.GITHUB_TOKEN}}