|
| 1 | +--- |
| 2 | +name: schedule-test-run-command |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [schedule-test-run-command] |
| 6 | +jobs: |
| 7 | + help: |
| 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 | + - name: install python dependencies |
| 18 | + run: | |
| 19 | + pip install --upgrade poetry |
| 20 | + poetry install |
| 21 | +
|
| 22 | + - name: create the openQA client config file |
| 23 | + run: | |
| 24 | + mkdir -p ~/.config/openqa |
| 25 | + echo "[openqa.opensuse.org]" > ~/.config/openqa/client.conf |
| 26 | + echo "key = ${{ secrets.O3_KEY }}" >> ~/.config/openqa/client.conf |
| 27 | + echo "secret = ${{ secrets.O3_SECRET }}" >> ~/.config/openqa/client.conf |
| 28 | +
|
| 29 | + - name: schedule the actual test run |
| 30 | + run: | |
| 31 | + VERSION_DISTRI="${{ github.event.client_payload.slash_command.args.named.version_distri }}" |
| 32 | + DISTRI="${{ github.event.client_payload.slash_command.args.named.distri }}" |
| 33 | + CMD="poetry run schedule_test_run" |
| 34 | + eval "$CMD -vd $(echo $VERSION_DISTR | sed 's/,/ /g') -d $(echo $DISTRI | sed 's/,/ /g') --dry-run" |
| 35 | + json_state_file=$(ls -tr *json|tail -1) |
| 36 | + echo "json_state_file=$json_state_file" >> $GITHUB_ENV |
| 37 | + echo "json_b64_state=$(cat $json_state_file | base64 -w 0)" |
| 38 | +
|
| 39 | + - name: create a comment with the json state file |
| 40 | + uses: peter-evans/create-or-update-comment@v3 |
| 41 | + id: create_comment |
| 42 | + with: |
| 43 | + issue-number: ${{ github.event.pull_request.number }} |
| 44 | + body: | |
| 45 | + Created the test run ${{ env.json_state_file }}. |
| 46 | + <details><summary>Internal state</summary> |
| 47 | + ${{ env.json_b64_state }} |
| 48 | + </details> |
| 49 | +
|
| 50 | + - name: Add reaction to the original comment on success |
| 51 | + if: ${{ success() }} |
| 52 | + uses: peter-evans/create-or-update-comment@v3 |
| 53 | + with: |
| 54 | + token: ${{ secrets.PAT }} |
| 55 | + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} |
| 56 | + reaction-type: "+1" |
| 57 | + |
| 58 | + - name: generate the url to this workflow run |
| 59 | + if: ${{ failure() || cancelled() }} |
| 60 | + run: echo "run_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV |
| 61 | + |
| 62 | + - name: Add reaction and a link to the error to the original comment on failure |
| 63 | + if: ${{ failure() || cancelled() }} |
| 64 | + uses: peter-evans/create-or-update-comment@v3 |
| 65 | + with: |
| 66 | + token: ${{ secrets.PAT }} |
| 67 | + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} |
| 68 | + reaction-type: "-1" |
| 69 | + body: Failed to schedule the test, see the [workflow run](${{ env.run_url }}) for further details. |
0 commit comments