generated from cyberbotics/competition-template
-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (141 loc) · 6.74 KB
/
verification.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
name: 'Repository link verification'
on:
issues:
types: [labeled]
issue_comment:
types: [created]
jobs:
verify-competitor:
if: > # Do the checks if there is a new registration or a 'retry' comment on a pending registration
(
join(github.event.issue.labels.*.name) == 'registration'
) || (
contains(github.event.issue.labels.*.name, 'registration') &&
contains(github.event.issue.labels.*.name, 'pending') &&
github.event.issue.user.login == github.event.comment.user.login &&
contains(github.event.comment.body, 'retry')
)
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.REPO_TOKEN }}
steps:
- name: Verification started message
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body: Verification started...
- name: Check out the repo
uses: actions/checkout@v3
- name: Isolate repo link to env.USER_REPO
run: bash .github/repo_regex.sh "${{ github.event.issue.body }}" "${{ github.event.issue.user.login }}"
continue-on-error: true
# First check | id: repo_check --N-> invites_check
- name: Is repo link actually a repo?
id: repo_check
run: |
gh api --silent \
-H "Accept: application/vnd.github+json" \
/repos/$USER_REPO
continue-on-error: true
- name: If repo not visible, is there a collaboration invite?
if: ${{ steps.repo_check.outcome == 'failure' }}
id: invites_check
run: |
invite_id=$( \
gh api \
-H "Accept: application/vnd.github+json" \
/user/repository_invitations | jq '.[] | select(.repository.full_name=="${{ env.USER_REPO }}") | .id' \
)
echo $invite_id
gh api --silent \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/user/repository_invitations/$invite_id
continue-on-error: true
- name: If no invites, problem with collab or link syntax
if: ${{ steps.invites_check.outcome == 'failure' }}
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body: |
There was a problem when checking your repository "${{ env.USER_REPO }}".
You haven't added the organizer as a collaborator or there is a typo in the link.
# Second check | id: benchmark_check
- name: Add competitor to file
if: ${{ steps.repo_check.outcome == 'success' || steps.invites_check.outcome == 'success' }}
run: echo "${{ github.event.issue.number }}:$USER_REPO" >> competitors.txt
- name: Is repo link a benchmark entry repo?
if: ${{ steps.repo_check.outcome == 'success' || steps.invites_check.outcome == 'success' }}
id: benchmark_check
uses: cyberbotics/benchmark-record-action@main
env:
INPUT_INDIVIDUAL_EVALUATION: "${{ github.event.issue.number }}:${{ env.USER_REPO }}"
INPUT_REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
continue-on-error: true
- name: If not a benchmark repo, feedback on registration issue
if: ${{ steps.benchmark_check.outcome == 'failure' }}
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body: |
There was a problem when checking your repository link.
The automated evaluation of your controller failed, your repository seems misconfigured. Look at the action logs for more details:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
# If there was any problem:
- name: Adding the "pending" label if there was any problem
id: if_error
if: >
steps.invites_check.outcome == 'failure' ||
steps.benchmark_check.outcome == 'failure'
run: |
gh api --silent \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels \
--input - <<< $(jq -n '{"labels":["pending"]}')
- name: Prompt on how to retry
if: ${{ steps.if_error.outcome == 'success' }}
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body: >
Please do the necessary to fix this problem.
When you have finished solving the issue, please try again by commenting "retry"
# Else everything is in order:
- name: Everything is in order, add feedback label
if: ${{ steps.benchmark_check.outcome == 'success' }}
run: |
gh api --silent \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels \
--input - <<< $(jq -n '{"labels":["accepted"]}')
gh api --silent \
--method DELETE \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/pending
continue-on-error: true
- name: Push competitor list update + animations
if: ${{ steps.benchmark_check.outcome == 'success' }}
run: |
git config --global user.name '${{ github.repository_owner }}'
git config --global user.email '${{ github.repository_owner }}@users.noreply.github.com'
git add .
git commit -m "Here comes a new challenger!"
git push
- name: Get leaderboard link
if: ${{ steps.benchmark_check.outcome == 'success' }}
run: |
echo LEADERBOARD_LINK="$( grep -oP '\[!\[webots\.cloud - Benchmark\]\(.+\)\]\(\K.+(?=\))' README.md )" >> "$GITHUB_ENV"
- name: Final feedback message
uses: peter-evans/close-issue@v1
if: ${{ steps.benchmark_check.outcome == 'success' }}
with:
comment: |
#### Here comes a new challenger!
You have been added to the benchmark [leaderboard](${{ env.LEADERBOARD_LINK }}).
Please note that your leaderboard score is **not** automatically updated.
If you want to run the evaluation of the last version of your controller that is in your repo's main branch,
add a new comment below containing the word "**run**".
If you want to unregister your repository from the list, add a new comment below containing the word "**unregister**".
Please note that the commands might take a few minutes before posting feedback messages. You can refresh the page to make recent comments appear.