Skip to content

Commit

Permalink
Merge branch '6.11.z' into cherry-pick-pr-815
Browse files Browse the repository at this point in the history
  • Loading branch information
omkarkhatavkar authored Jun 23, 2023
2 parents 1c4341d + 3124c38 commit 753ce09
Show file tree
Hide file tree
Showing 17 changed files with 263 additions and 52 deletions.
1 change: 1 addition & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addAssignees: author
21 changes: 21 additions & 0 deletions .github/workflows/auto_assignment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Auto Assign'

on:
pull_request_target:
types:
- opened
- ready_for_review
- reopened
- synchronize


jobs:
add-assignees: # This needed to create the gh issue in case of failed auto-cherry-pick
name: Add author to assignee
if: "!contains(github.event.pull_request.labels.*.name, 'Auto_Cherry_Picked')"
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/[email protected]
with:
repo-token: "${{ secrets.CHERRYPICK_PAT || github.token }}"
configuration-path: ".github/auto_assign.yml"
105 changes: 85 additions & 20 deletions .github/workflows/auto_cherry_pick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,103 @@ on:
types:
- closed

# Github & Parent PR Env vars
env:
assignee: ${{ github.event.pull_request.assignee.login }}
title: ${{ github.event.pull_request.title }}
number: ${{ github.event.number }}

jobs:
branch-matrix:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CherryPick')
name: Generate a branch matrix to apply cherrypicks

# Pre-Requisites for Auto Cherrypicking
find-the-parent-prt-comment:
name: Find & Save last PRT comment of Parent PR
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.set-matrix.outputs.branches }}
prt_comment: ${{steps.fc.outputs.comment-body}}
steps:
- uses: actions/checkout@v3
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
fetch-depth: 0
- id: set-matrix
run: echo "::set-output name=branches::$(git branch -rl --sort=-authordate 'origin/6.*.z' --format='%(refname:lstrip=-1)' | head -n2 | jq -cnR '[inputs | select(length>0)]')"
auto_cherry_picking:
issue-number: ${{ env.number }}
body-includes: "trigger: test-robottelo"

# Auto CherryPicking and Failure Recording
auto-cherry-pick:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CherryPick')
name: Auto Cherry picking
needs: branch-matrix
name: Auto Cherry Pick to labeled branches
needs: find-the-parent-prt-comment
runs-on: ubuntu-latest
strategy:
matrix:
to_branch: ${{ fromJson(needs.branch-matrix.outputs.branches) }}
label: ${{ github.event.pull_request.labels.*.name }}

steps:
- name: Checkout Airgun
uses: actions/checkout@v3
## Airgun Repo Checkout
- uses: actions/checkout@v3
if: ${{ startsWith(matrix.label, '6.') && matrix.label != github.base_ref }}
with:
fetch-depth: 0
if: matrix.to_branch != github.base_ref
- name: Cherry pick into ${{ matrix.to_branch }}
uses: carloscastrojumo/[email protected]

## CherryPicking and AutoMerging
- name: Cherrypicking to zStream branch
id: cherrypick
if: ${{ startsWith(matrix.label, '6.') && matrix.label != github.base_ref }}
uses: jyejare/github-cherry-pick-action@main
with:
branch: ${{ matrix.to_branch }}
token: ${{ secrets.CHERRYPICK_PAT }}
branch: ${{ matrix.label }}
labels: |
Auto_Cherry_Picked
# skipping PRs remote target_branch from cherrypicking into itself
if: matrix.to_branch != github.base_ref
${{ matrix.label }}
No-CherryPick
assignees: ${{ env.assignee }}

- name: Add Parent PR's PRT comment to Auto_Cherry_Picked PR's
id: add-parent-prt-comment
if: ${{ always() && steps.cherrypick.outcome == 'success' }}
uses: mshick/add-pr-comment@v2
with:
issue: ${{ steps.cherrypick.outputs.number }}
message: ${{ needs.find-the-parent-prt-comment.outputs.prt_comment }}
repo-token: ${{ secrets.CHERRYPICK_PAT }}

- name: is autoMerging enabled for Auto CherryPicked PRs ?
if: ${{ always() && steps.cherrypick.outcome == 'success' && contains(github.event.pull_request.labels.*.name, 'AutoMerge_Cherry_Picked') }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.CHERRYPICK_PAT }}
script: |
github.rest.issues.addLabels({
issue_number: ${{ steps.cherrypick.outputs.number }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["AutoMerge_Cherry_Picked"]
})
## Failure Logging to issues and GChat Group
- name: Create Github issue on cherrypick failure
id: create-issue
if: ${{ always() && steps.cherrypick.outcome == 'failure' }}
uses: dacbd/create-issue-action@main
with:
token: ${{ secrets.CHERRYPICK_PAT }}
title: "[Failed-AutoCherryPick] - ${{ env.title }}"
body: |
#### Auto-Cherry-Pick WorkFlow Failure:
- To Branch: ${{ matrix.label }}
- [Failed Cherrypick Action](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
- [Parent Pull Request](https://github.com/${{ github.repository }}/pull/${{ github.event.number }})
labels: Failed_AutoCherryPick,${{ matrix.label }}
assignees: ${{ env.assignee }}
- name: Send Google Chat notification on cherrypick failure
id: google-chat-notification
if: ${{ always() && steps.cherrypick.outcome == 'failure' }}
uses: omkarkhatavkar/google-chat-notification@master
with:
name: ${{ env.title }}
url: ${{ secrets.GCHAT_REVIEWERS_WEBHOOK }}
issue_url: ${{ steps.create-issue.outputs.html_url }}
author: ${{ env.assignee }}
status: failure
123 changes: 123 additions & 0 deletions .github/workflows/automerge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: automerge auto-cherry-picked pr's
on:
pull_request_target:
types:
- labeled
- unlabeled
- edited
- ready_for_review
branches-ignore:
- master
pull_request_review:
types:
- submitted
branches-ignore:
- master
check_suite:
types:
- completed
branches-ignore:
- master


jobs:
automerge:
name: Automerge auto-cherry-picked pr
if: contains(github.event.pull_request.labels.*.name, 'AutoMerge_Cherry_Picked') && contains(github.event.pull_request.labels.*.name, 'Auto_Cherry_Picked')
runs-on: ubuntu-latest
steps:
- id: find-prt-comment
name: Find the prt comment
uses: peter-evans/find-comment@v2
with:
issue-number: ${{ github.event.number }}
body-includes: "trigger: test-robottelo"
direction: last

- name: Fail automerge if PRT was not initiated
if: steps.find-prt-comment.outputs.comment-body == ''
run: |
echo "::error PRT comment not added the PR"
- name: Wait for PRT checks to get initiated
run: |
echo "Waiting for ~ 10 mins, PRT to be initiated." && sleep 600
- name: Wait for other status checks to Pass
id: waitforstatuschecks
uses: lewagon/[email protected]
with:
ref: ${{ github.head_ref }}
repo-token: ${{ secrets.CHERRYPICK_PAT }}
wait-interval: 60
running-workflow-name: 'Automerge auto-cherry-picked pr'
allowed-conclusions: success,skipped

- name: is PRT check Passed ?
run: |
api_endpoint="https://api.github.com/repos/${{github.repository}}/statuses/${{ github.head_ref }}"
function get_status() {
curl -s "$api_endpoint" | jq '[.[] | .state] | .[0]'
}
function get_context() {
curl -s "$api_endpoint" | jq '[.[] | .context] | .[0]'
}
statuses_length=$(curl -s $api_endpoint | jq 'length')
if [ $statuses_length -eq 0 ]; then
echo "PRT failed to start ! Stopping."
exit 1
fi
status=$(get_status)
context=$(get_context)
if [ "$context" != "Robottelo-Runner" ]; then
echo "::error Failed to get Robottelo-Runner status"
exit 1
fi
counter=0
echo "Waiting for PRT to complete....."
while [ "$status" != "success" ] && [ "$status" != "failure" ]; do
if [ $counter -gt 20 ]; then
echo "PRT Timeout"
exit 1
fi
sleep 300
status=$(get_status)
echo "Robottelo-Runner : $status"
counter=$((counter+1))
done
if [ "$status" == "success" ]; then
echo "PRT Passed Successfully!"
else
echo "Robottelo-Runner : $status"
echo "::error PRT failed"
exit 1
fi
- id: automerge
name: Auto merge of cherry-picked PRs.
uses: "pascalgn/[email protected]"
if: steps.waitforstatuschecks.outputs.status == 'success'
env:
GITHUB_TOKEN: "${{ secrets.CHERRYPICK_PAT }}"
MERGE_LABELS: "AutoMerge_Cherry_Picked, Auto_Cherry_Picked"
MERGE_METHOD: "squash"
MERGE_RETRIES: 5
MERGE_RETRY_SLEEP: 900000
BASE_BRANCHES: "master" # avoid automerge branch

- name: Auto Merge Status
run: |
if [ "${{ steps.automerge.outputs.mergeResult }}" == 'merged' ]; then
echo "Pull request ${{ steps.automerge.outputs.pullRequestNumber }} is Auto Merged !"
else
echo "::error Auto Merge for Pull request failed !"
exit 1
fi
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
rev: 22.3.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
Expand Down
2 changes: 0 additions & 2 deletions airgun/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ def _get_remote_browser(self):
Note: should not be called directly, use :meth:`get_browser` instead.
"""
desired_capabilities = self.web_kaifuku['webdriver_options']['desired_capabilities']
desired_capabilities.update({'name': self.test_name})
manager = BrowserManager.from_conf(self.web_kaifuku)
self._webdriver = manager.start()
self._set_session_cookie()
Expand Down
2 changes: 1 addition & 1 deletion airgun/entities/cloud_insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def remediate(self, entity_name):
view = self.navigate_to(self, 'All')
view.search(entity_name)
view.select_all.fill(True)
# view.select_all_hits.click() skip till BZ#1975321 is fixed.
view.select_all_hits.click()
view.remediate.click()
view.remediation_window.remediate.click()
self.run_job()
Expand Down
5 changes: 3 additions & 2 deletions airgun/entities/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,16 @@ def get_webconsole_content(self, entity_name, rhel_version=7):

# switch to the last opened tab,
self.browser.switch_to_window(self.browser.window_handles[-1])
self.browser.plugin.ensure_page_safe()
self.browser.wait_for_element(locator='//div[@id="content"]/iframe', exception=True)
# the remote host content is loaded in an iframe, let's switch to it
self.browser.switch_to_frame(locator='//div[@id="content"]/iframe')

self.browser.wait_for_element(
locator=f'//{hostname_element}[@id="{hostname_id}"]', exception=True, visible=True
)
hostname_button_view = self.browser.selenium.find_elements_by_id(hostname_id)
hostname = hostname_button_view[0].text
hostname_button = self.browser.selenium.find_elements("id", hostname_id)
hostname = hostname_button[0].text
self.browser.switch_to_main_frame()
self.browser.switch_to_window(self.browser.window_handles[0])
self.browser.close_window(self.browser.window_handles[-1])
Expand Down
11 changes: 11 additions & 0 deletions airgun/entities/hostgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ def create(self, values):
view.flash.assert_no_error()
view.flash.dismiss()

def clone(self, entity_name, values):
"""Clone an existing host group entity"""
view = self.navigate_to(self, 'All')
view.search(entity_name)
view.table.row(name=entity_name)['Actions'].widget.fill('Clone')
view = HostGroupCreateView(self.browser)
view.fill(values)
view.submit.click()
view.flash.assert_no_error()
view.flash.dismiss()

def search(self, value):
"""Search for existing host group entity"""
view = self.navigate_to(self, 'All')
Expand Down
4 changes: 1 addition & 3 deletions airgun/views/contenthost.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class errata(View):
bug_fix = Text(".//span[contains(@ng-class, 'errataCounts.bugfix')]")
enhancement = Text(".//span[contains(@ng-class, 'errataCounts.enhancement')]")

packages = Text("./a[contains(@ui-sref, 'packages.applicable')]")


class ContentHostsView(BaseLoggedInView, SearchableViewMixin):
title = Text("//h2[contains(., 'Content Hosts')]")
Expand Down Expand Up @@ -236,7 +234,7 @@ class packages_applicable(SatTabWithDropdown, SearchableViewMixin):
class errata(SatTab):
lce_filter = Select(locator='.//select[@ng-model="selectedErrataOption"]')
searchbox = Search()
apply_selected = ActionsDropdown(".//span[contains(@class, 'btn-group')]")
apply_selected = ActionsDropdown(".//span[contains(@class, 'btn-group dropdown')]")
recalculate = Button('Recalculate')
table = SatTable(
'.//table',
Expand Down
2 changes: 1 addition & 1 deletion airgun/views/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class general(Tab):
)
ROOT = '//section[@id="generalSection"]'

orgnization = FormSelect('OUIA-Generated-FormSelect-default-1')
organization = FormSelect('OUIA-Generated-FormSelect-default-1')
location = FormSelect('OUIA-Generated-FormSelect-default-2')
host_group = FormSelect('OUIA-Generated-FormSelect-default-3')
operating_system = FormSelect('OUIA-Generated-FormSelect-default-4')
Expand Down
3 changes: 1 addition & 2 deletions airgun/views/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
class LoginView(View, ClickableMixin):
username = TextInput(id="login_login")
password = TextInput(id="login_password")
login_text = Text('//*[@id="login-footer-text"]')
login_text = Text(".//footer[contains(@class,'login-pf-page-footer')]")
logo = Text('//img[@alt="logo"]')
submit = Text('//button[@type="submit"]')
version = Text('//*[@id="version"]')

@property
def is_displayed(self):
Expand Down
3 changes: 1 addition & 2 deletions airgun/views/provisioning_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class TemplateHostEnvironmentAssociation(GenericRemovableWidgetItem):

remove_button = Text(".//a[@title='Remove Combination']")
host_group = Select(locator=".//select[contains(@name, '[hostgroup_id]')]")
environment = Select(locator=".//select[contains(@name, '[environment_id]')]")


class ProvisioningTemplatesView(BaseLoggedInView, SearchableViewMixin):
Expand Down Expand Up @@ -81,7 +80,7 @@ class association(SatTab):
applicable_os = MultiSelect(id='ms-provisioning_template_operatingsystem_ids')

@View.nested
class hg_environment_combination(RemovableWidgetsItemsListView):
class valid_hostgroups(RemovableWidgetsItemsListView):
ROOT = "//div[@id='association']"
ITEMS = ".//fieldset[@id='template_combination']/div"
ITEM_WIDGET_CLASS = TemplateHostEnvironmentAssociation
Expand Down
Loading

0 comments on commit 753ce09

Please sign in to comment.