Skip to content

Commit

Permalink
Fix workflows (#2)
Browse files Browse the repository at this point in the history
* Fix git URL
* Fix re-running pending workflows
  • Loading branch information
spetrosi authored Aug 2, 2024
1 parent 6ac64af commit 5bec114
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
uses: sclorg/testing-farm-as-github-action@v3
if: contains(needs.prepare_vars.outputs.supported_platforms, matrix.platform)
with:
git_url: linux-system-roles/tft-tests
git_url: https://github.com/linux-system-roles/tft-tests
git_ref: main
pipeline_settings: '{ "type": "tmt-multihost" }'
variables: "ANSIBLE_VER=${{ matrix.ansible_version }};\
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/tft_citest_bad.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: Rerun failed testing farm tests
name: Re-run failed testing farm tests
on:
issue_comment:
types:
- created
permissions:
contents: read
jobs:
retest:
citest_bad_rerun:
if: |
github.event.issue.pull_request
&& github.event.comment.body == '[citest_bad]'
Expand All @@ -21,10 +21,13 @@ jobs:
REPO: ${{ github.repository }}
PR_TITLE: ${{ github.event.issue.title }}
run: |
RUN_ID=$(gh api "repos/$REPO/actions/workflows/tft.yml/runs?event=issue_comment" \
| jq -r '[.workflow_runs[] | select( .conclusion == "pending" ) | select ( .display_title="$PR_TITLE" ) | .id][0]')
if [ -z $RUN_ID ]; then # if pending run don't exist, take the last run with failure state
PENDING_RUN=$(gh api "repos/$REPO/actions/workflows/tft.yml/runs?event=issue_comment" \
| jq -r '[.workflow_runs[] | select(.display_title="$PR_TITLE") | select(.status == "pending" or .status == "queued" or .status == "in_progress") | .id][0]')
if [ "$RUN_ID" = "null" ]; then # if pending run don't exist, take the last run with failure state
RUN_ID=$(gh api "repos/$REPO/actions/workflows/tft.yml/runs?event=issue_comment" \
| jq -r '[.workflow_runs[] | select( .conclusion == "failure" ) | select ( .display_title="$PR_TITLE" ) | .id][0]')
echo "Re-running workflow $RUN_ID"
gh api --method POST repos/$REPO/actions/runs/$RUN_ID/rerun-failed-jobs
else
echo "The workflow $PENDING_RUN is still running, wait for it to finish to re-run"
fi
gh api --method POST repos/$REPO/actions/runs/$RUN_ID/rerun-failed-jobs

0 comments on commit 5bec114

Please sign in to comment.