Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for PENDING_RUN and GITHUB_ORG #5

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/tft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ permissions:
contents: read
# This is required for the ability to create/update the Pull request status
statuses: write
# The concurrency key is used to prevent multiple workflows from running at the same time
concurrency:
# group name contains reponame-pr_num to allow simualteneous runs in different PRs
group: testing-farm-${{ github.event.repository.name }}-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
prepare_vars:
name: Get info from role and PR to determine if and how to test
# The concurrency key is used to prevent multiple workflows from running at the same time
concurrency:
# group name contains reponame-pr_num to allow simualteneous runs in different PRs
group: testing-farm-${{ github.event.repository.name }}-${{ github.event.issue.number }}
cancel-in-progress: true
# Let's schedule tests only on user request. NOT automatically.
# Only repository owner or member can schedule tests
if: |
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
pipeline_settings: '{ "type": "tmt-multihost" }'
variables: "ANSIBLE_VER=${{ matrix.ansible_version }};\
REPO_NAME=${{ github.event.repository.name }};\
GITHUB_ORG=linux-system-roles;\
GITHUB_ORG=${{ github.repository_owner }};\
PR_NUM=${{ github.event.issue.number }};\
ARTIFACTS_DIR=${{ steps.set_vars.outputs.ARTIFACTS_DIR }};\
ARTIFACTS_URL=${{ steps.set_vars.outputs.ARTIFACTS_URL }};\
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/tft_citest_bad.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ jobs:
PR_TITLE: ${{ github.event.issue.title }}
run: |
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
| jq -r "[.workflow_runs[] | select( .display_title == \"$PR_TITLE\") | \
select(.status == \"pending\" or .status == \"queued\" or .status == \"in_progress\") | .id][0]")
# if pending run don't exist, take the last run with failure state
if [ "$PENDING_RUN" != "null" ]; then
echo "The workflow $PENDING_RUN is still running, wait for it to finish to re-run"
exit 1
fi
RUN_ID=$(gh api "repos/$REPO/actions/workflows/tft.yml/runs?event=issue_comment" \
| jq -r "[.workflow_runs[] | select( .display_title == \"$PR_TITLE\" ) | select( .conclusion == \"failure\" ) | .id][0]")
if [ "$RUN_ID" = "null" ]; then
echo "Failed workflow not found, exitting"
exit 1
fi
echo "Re-running workflow $RUN_ID"
gh api --method POST repos/$REPO/actions/runs/$RUN_ID/rerun-failed-jobs
Loading