Skip to content

Commit e59ab1e

Browse files
committed
WIP: chatops
1 parent 015ce49 commit e59ab1e

File tree

6 files changed

+462
-1
lines changed

6 files changed

+462
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Slash Command Dispatch
3+
on:
4+
issue_comment:
5+
types: [created]
6+
jobs:
7+
dispatch-command:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Slash Command Dispatch
11+
uses: peter-evans/slash-command-dispatch@v3
12+
with:
13+
token: ${{ secrets.PAT }}
14+
commands: |
15+
schedule-test-run
16+
cancel-tests
17+
print-result
18+
help
19+
issue-type: pull-request
20+
permission: none

.github/workflows/help-command.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: help-command
3+
on:
4+
repository_dispatch:
5+
types: [help-command]
6+
jobs:
7+
help:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Update comment
11+
uses: peter-evans/create-or-update-comment@v3
12+
with:
13+
token: ${{ secrets.PAT }}
14+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
15+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
16+
body: |
17+
> Command | Description
18+
> --- | ---
19+
> /help | Print this message
20+
> /schedule-test-run [distri={opensuse,fedora,sle,centos,ubuntu,debian,archlinux}] [version_distri={Tumbleweed+opensuse,Leap+opensuse,37+fedora,Rawhide+fedora,8+centos,9+centos,15+sle,22.04+ubuntu,10+debian,rolling+archlinux}] | Schedules a test run on openqa.opensuse.org
21+
> /cancel-tests | Cancel the current test run
22+
> /print-result | Pretty prints the result from the test run
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: schedule-test-run-command
3+
on:
4+
repository_dispatch:
5+
types: [schedule-test-run-command]
6+
jobs:
7+
schedule-test-run-on-o3:
8+
runs-on: ubuntu-latest
9+
container: registry.fedoraproject.org/fedora:latest
10+
11+
steps:
12+
- run: |
13+
dnf install -y git pipx python3
14+
PIPX_BIN_DIR=/usr/bin/ pipx install poetry
15+
16+
- uses: actions/checkout@v3
17+
18+
- uses: actions/cache@v3
19+
with:
20+
path: ~/.cache/pypoetry/virtualenvs
21+
key: poetry-${{ hashFiles('poetry.lock') }}
22+
23+
- name: fix the file permissions of the repository
24+
run: chown -R $(id -un):$(id -gn) .
25+
26+
- name: install python dependencies
27+
run: poetry install
28+
29+
- name: create a oscrc
30+
run: |
31+
mkdir -p ~/.config/osc/
32+
echo "[general]" > ~/.config/osc/oscrc
33+
echo "apiurl = https://api.opensuse.org" >> ~/.config/osc/oscrc
34+
echo "[https://api.opensuse.org]" >> ~/.config/osc/oscrc
35+
echo "user = defolos" >> ~/.config/osc/oscrc
36+
echo "pass = ${{ secrets.OSC_PASSWORD }}" >> ~/.config/osc/oscrc
37+
38+
- name: create the openQA client config file
39+
run: |
40+
mkdir -p ~/.config/openqa
41+
echo "[openqa.opensuse.org]" > ~/.config/openqa/client.conf
42+
echo "key = ${{ secrets.O3_KEY }}" >> ~/.config/openqa/client.conf
43+
echo "secret = ${{ secrets.O3_SECRET }}" >> ~/.config/openqa/client.conf
44+
45+
- name: schedule the actual test run
46+
run: |
47+
VERSION_DISTRI="${{ github.event.client_payload.slash_command.args.named.version_distri }}"
48+
DISTRI="${{ github.event.client_payload.slash_command.args.named.distri }}"
49+
CMD="poetry run schedule_test_run"
50+
eval "$CMD -vd $(echo $VERSION_DISTR | sed 's/,/ /g') -d $(echo $DISTRI | sed 's/,/ /g') --dry-run"
51+
json_state_file=$(ls -tr *json|tail -1)
52+
echo "json_state_file=$json_state_file" >> $GITHUB_ENV
53+
echo "json_b64_state=$(cat $json_state_file | base64 -w 0)"
54+
55+
- name: create a comment with the json state file
56+
uses: peter-evans/create-or-update-comment@v3
57+
id: create_comment
58+
with:
59+
issue-number: ${{ github.event.pull_request.number }}
60+
body: |
61+
Created the test run ${{ env.json_state_file }}.
62+
<details><summary>Internal state</summary>
63+
${{ env.json_b64_state }}
64+
</details>
65+
66+
- name: Add reaction to the original comment on success
67+
if: ${{ success() }}
68+
uses: peter-evans/create-or-update-comment@v3
69+
with:
70+
token: ${{ secrets.PAT }}
71+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
72+
reaction-type: "+1"
73+
74+
- name: generate the url to this workflow run
75+
if: ${{ failure() || cancelled() }}
76+
run: echo "run_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
77+
78+
- name: Add reaction and a link to the error to the original comment on failure
79+
if: ${{ failure() || cancelled() }}
80+
uses: peter-evans/create-or-update-comment@v3
81+
with:
82+
token: ${{ secrets.PAT }}
83+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
84+
reaction-type: "-1"
85+
body: Failed to schedule the test, see the [workflow run](${{ env.run_url }}) for further details.
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
{
2+
"build": "20230724",
3+
"server": "openqa.opensuse.org",
4+
"scheme": "https",
5+
"job_ids": [
6+
3449321,
7+
3449322,
8+
3449323,
9+
3449324,
10+
3449325,
11+
3449326,
12+
3449327,
13+
3449328,
14+
3449329,
15+
3449330,
16+
3449331,
17+
3449332,
18+
3449333,
19+
3449334,
20+
3449335,
21+
3449336,
22+
3449337,
23+
3449338,
24+
3449339,
25+
3449340,
26+
3449341,
27+
3449342,
28+
3449343,
29+
3449344,
30+
3449345,
31+
3449346,
32+
3449347,
33+
3449348,
34+
3449349,
35+
3449350,
36+
3449351,
37+
3449352,
38+
3449353,
39+
3449354,
40+
3449355,
41+
3449356,
42+
3449357,
43+
3449358,
44+
3449359,
45+
3449360,
46+
3449361,
47+
3449362,
48+
3449363,
49+
3449364,
50+
3449365,
51+
3449366,
52+
3449367,
53+
3449368,
54+
3449369,
55+
3449370,
56+
3449371,
57+
3449372,
58+
3449373,
59+
3449374,
60+
3449375,
61+
3449376,
62+
3449377,
63+
3449378,
64+
3449379,
65+
3449380,
66+
3449381,
67+
3449382,
68+
3449383,
69+
3449384,
70+
3449385,
71+
3449386,
72+
3449387,
73+
3449388,
74+
3449389,
75+
3449390,
76+
3449391,
77+
3449392,
78+
3449393,
79+
3449394,
80+
3449395,
81+
3449396,
82+
3449397,
83+
3449398,
84+
3449399,
85+
3449400,
86+
3449401,
87+
3449402,
88+
3449403,
89+
3449404,
90+
3449405,
91+
3449406,
92+
3449407,
93+
3449408,
94+
3449409,
95+
3449410,
96+
3449411,
97+
3449412,
98+
3449413,
99+
3449414,
100+
3449415,
101+
3449416,
102+
3449417,
103+
3449418,
104+
3449419,
105+
3449420,
106+
3449421,
107+
3449422,
108+
3449423,
109+
3449424,
110+
3449425,
111+
3449426,
112+
3449427,
113+
3449428,
114+
3449429,
115+
3449430,
116+
3449431,
117+
3449432,
118+
3449433,
119+
3449434,
120+
3449435,
121+
3449436,
122+
3449437,
123+
3449438,
124+
3449439,
125+
3449440,
126+
3449441,
127+
3449442,
128+
3449443,
129+
3449444,
130+
3449445,
131+
3449446,
132+
3449447,
133+
3449448,
134+
3449449,
135+
3449450,
136+
3449451,
137+
3449452,
138+
3449453,
139+
3449454,
140+
3449455,
141+
3449456,
142+
3449457,
143+
3449458,
144+
3449459,
145+
3449460,
146+
3449461,
147+
3449462,
148+
3449463,
149+
3449464,
150+
3449465,
151+
3449466,
152+
3449467,
153+
3449468,
154+
3449469,
155+
3449470,
156+
3449471,
157+
3449472,
158+
3449473,
159+
3449474,
160+
3449475,
161+
3449476,
162+
3449477,
163+
3449478,
164+
3449479,
165+
3449480,
166+
3449481,
167+
3449482
168+
]
169+
}

0 commit comments

Comments
 (0)