Skip to content

Commit

Permalink
WIP: chatops
Browse files Browse the repository at this point in the history
  • Loading branch information
dcermak committed Jul 26, 2023
1 parent 3142086 commit cfa89c8
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/command-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Slash Command Dispatch
on:
issue_comment:
types: [created]
jobs:
dispatch-command:
runs-on: ubuntu-latest
steps:
- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.PAT }}
commands: |
schedule-test-run
cancel-tests
print-result
help
issue-type: pull-request
permission: none
22 changes: 22 additions & 0 deletions .github/workflows/help-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: help-command
on:
repository_dispatch:
types: [help-command]
jobs:
help:
runs-on: ubuntu-latest
steps:
- name: Update comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> Command | Description
> --- | ---
> /help | Print this message
> /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
> /cancel-tests | Cancel the current test run
> /print-result | Pretty prints the result from the test run
70 changes: 70 additions & 0 deletions .github/workflows/schedule-test-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
name: schedule-test-run-command
on:
repository_dispatch:
types: [schedule-test-run-command]
jobs:
schedule-test-run-on-o3:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('poetry.lock') }}

- name: install python dependencies
run: |
sudo apt remove -y python3-distro-info
pipx install poetry
poetry install
- name: create the openQA client config file
run: |
mkdir -p ~/.config/openqa
echo "[openqa.opensuse.org]" > ~/.config/openqa/client.conf
echo "key = ${{ secrets.O3_KEY }}" >> ~/.config/openqa/client.conf
echo "secret = ${{ secrets.O3_SECRET }}" >> ~/.config/openqa/client.conf
- name: schedule the actual test run
run: |
VERSION_DISTRI="${{ github.event.client_payload.slash_command.args.named.version_distri }}"
DISTRI="${{ github.event.client_payload.slash_command.args.named.distri }}"
CMD="poetry run schedule_test_run"
eval "$CMD -vd $(echo $VERSION_DISTR | sed 's/,/ /g') -d $(echo $DISTRI | sed 's/,/ /g') --dry-run"
json_state_file=$(ls -tr *json|tail -1)
echo "json_state_file=$json_state_file" >> $GITHUB_ENV
echo "json_b64_state=$(cat $json_state_file | base64 -w 0)"
- name: create a comment with the json state file
uses: peter-evans/create-or-update-comment@v3
id: create_comment
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Created the test run ${{ env.json_state_file }}.
<details><summary>Internal state</summary>
${{ env.json_b64_state }}
</details>
- name: Add reaction to the original comment on success
if: ${{ success() }}
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.PAT }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reaction-type: "+1"

- name: generate the url to this workflow run
if: ${{ failure() || cancelled() }}
run: echo "run_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV

- name: Add reaction and a link to the error to the original comment on failure
if: ${{ failure() || cancelled() }}
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.PAT }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reaction-type: "-1"
body: Failed to schedule the test, see the [workflow run](${{ env.run_url }}) for further details.

0 comments on commit cfa89c8

Please sign in to comment.