Skip to content

Commit ef744ca

Browse files
committed
WIP: chatops
1 parent 3142086 commit ef744ca

File tree

5 files changed

+283
-1
lines changed

5 files changed

+283
-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: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- uses: actions/cache@v3
13+
with:
14+
path: ~/.cache/pypoetry/virtualenvs
15+
key: poetry-${{ hashFiles('poetry.lock') }}
16+
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.x'
20+
21+
- name: install python dependencies
22+
run: |
23+
# need to remove distro-info as it has an invalid python version
24+
sudo apt remove -y python3-distro-info
25+
pipx install poetry
26+
poetry install
27+
28+
- name: create the openQA client config file
29+
run: |
30+
mkdir -p ~/.config/openqa
31+
echo "[openqa.opensuse.org]" > ~/.config/openqa/client.conf
32+
echo "key = ${{ secrets.O3_KEY }}" >> ~/.config/openqa/client.conf
33+
echo "secret = ${{ secrets.O3_SECRET }}" >> ~/.config/openqa/client.conf
34+
35+
- name: schedule the actual test run
36+
run: |
37+
VERSION_DISTRI="${{ github.event.client_payload.slash_command.args.named.version_distri }}"
38+
DISTRI="${{ github.event.client_payload.slash_command.args.named.distri }}"
39+
CMD="poetry run schedule_test_run"
40+
eval "$CMD -vd $(echo $VERSION_DISTR | sed 's/,/ /g') -d $(echo $DISTRI | sed 's/,/ /g') --dry-run"
41+
json_state_file=$(ls -tr *json|tail -1)
42+
echo "json_state_file=$json_state_file" >> $GITHUB_ENV
43+
echo "json_b64_state=$(cat $json_state_file | base64 -w 0)"
44+
45+
- name: create a comment with the json state file
46+
uses: peter-evans/create-or-update-comment@v3
47+
id: create_comment
48+
with:
49+
issue-number: ${{ github.event.pull_request.number }}
50+
body: |
51+
Created the test run ${{ env.json_state_file }}.
52+
<details><summary>Internal state</summary>
53+
${{ env.json_b64_state }}
54+
</details>
55+
56+
- name: Add reaction to the original comment on success
57+
if: ${{ success() }}
58+
uses: peter-evans/create-or-update-comment@v3
59+
with:
60+
token: ${{ secrets.PAT }}
61+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
62+
reaction-type: "+1"
63+
64+
- name: generate the url to this workflow run
65+
if: ${{ failure() || cancelled() }}
66+
run: echo "run_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
67+
68+
- name: Add reaction and a link to the error to the original comment on failure
69+
if: ${{ failure() || cancelled() }}
70+
uses: peter-evans/create-or-update-comment@v3
71+
with:
72+
token: ${{ secrets.PAT }}
73+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
74+
reaction-type: "-1"
75+
body: Failed to schedule the test, see the [workflow run](${{ env.run_url }}) for further details.

0 commit comments

Comments
 (0)