Skip to content

Commit

Permalink
Merge branch 'master' into ansibleRemoveRole
Browse files Browse the repository at this point in the history
  • Loading branch information
amolpati30 authored Apr 17, 2024
2 parents 507d6a6 + dd2eaac commit 35f3b80
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 13 deletions.
212 changes: 212 additions & 0 deletions .github/workflows/auto_branching.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
### The auto-branching workflow triggered through a dispatch request from the CI
name: auto-branching

# Run on workflow dispatch from CI
on:
workflow_dispatch:
inputs:
target_branch:
type: string
description: branch to be created from the master
stream_version:
type: string
description: new stream version of satellite

jobs:
check-group-membership:
runs-on: ubuntu-latest
outputs:
member: ${{steps.check_membership.outputs.member}}

steps:
- name: Check if the user is a member of repository-admins group
id: check_membership
run: |
# Use GitHub API to check if the user triggering the workflow is a member of satellite-admin group
MEMBER=$(curl -s -H "Authorization: token ${{ secrets._REPO_ADMIN_TOKEN }}" \
"https://api.github.com/orgs/satelliteQE/teams/repository-admins/memberships/${{ github.actor }}")
if [[ $(echo "$MEMBER" | jq -r '.state') == "active" ]]; then
echo "User is a member of satellite-admin group."
echo "member=true" >> $GITHUB_OUTPUT
else
echo "User is not a member of satellite-admin group."
echo "member=false" >> $GITHUB_OUTPUT
exit 1
fi
auto-branching-new-downstream-release:
name: ${{ github.event.inputs.target_branch }} - raise PR with changes
runs-on: ubuntu-latest
needs: check-group-membership
if: ${{ needs.check-group-membership.outputs.member == 'true' }}

steps:
- name: Checkout Robottelo
uses: actions/checkout@v4

- name: Create the ${{ github.event.inputs.target_branch }} branch
id: create-branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets._REPO_ADMIN_TOKEN }}
with:
branch: ${{ github.event.inputs.target_branch }}

- name: Create label for the ${{ github.event.inputs.target_branch }} branch
id: create-label
run: |
curl -X POST \
-H "Authorization: token ${{ secrets._REPO_ADMIN_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/labels \
-d "{\"name\":\"${{ github.event.inputs.target_branch }}\",\"color\":\"fbca04\"}"
- name: Switch to ${{ github.event.inputs.target_branch }} branch
run: git checkout -b "${{ github.event.inputs.target_branch }}"

- name: Checkout from ${{ github.event.inputs.target_branch }} branch for auto-branching changes
id: checkout-to-auto-branch
run: |
branch_name="auto-branching-${{ github.event.inputs.target_branch }}-$(date '+%s')"
git checkout -b "$branch_name"
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
- name: Update target branch label in dependabot yml file
id: update-dependabot
run: |
# Read the dependabot.yml file
FILE_PATH="./.github/dependabot.yml"
TARGET_BRANCH="${{ github.event.inputs.target_branch }}"
# Append the target branch label to the labels node
awk -v target="'$TARGET_BRANCH'" '/^ *labels:/ {$0 = $0 "\n - " target} 1' "$FILE_PATH" > temp.yml && mv temp.yml "$FILE_PATH"
- name: Remove the dispatch release GHA
id: remove-dispatch-release-gha
run: |
rm -rf ./.github/workflows/dispatch_release.yml
rm -rf ./.github/workflows/auto_branching.yml
- name: git status
run: git status

- name: git diff
run: git diff

- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add ./.github/*
git commit -m "Changes for new ${{ github.event.inputs.target_branch }} branch"
git remote -vvv
git push origin ${{steps.checkout-to-auto-branch.outputs.branch_name}}
- name: Create pull request
id: create_pr
run: |
title="[${{ github.event.inputs.target_branch }}]: Changes for ${{ github.event.inputs.target_branch }} new branch"
body="
### Problem Statement
New ${{ github.event.inputs.target_branch }} branch
### Solution
- Dependabot labels are updated for new branch
- Removed dispatch release GHA from ${{ github.event.inputs.target_branch }} as we are releasing only master changes
"
pr_number=$(gh pr create --title "$title" --body "$body" --base "${{ github.event.inputs.target_branch }}" | awk -F'/' '{print $NF}')
echo "$pr_number"
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets._REPO_ADMIN_TOKEN }}

- name: Add the prt comment for running the sanity tests
id: add-parent-prt-comment
uses: thollander/actions-comment-pull-request@v2
with:
message: |
trigger: test-robottelo
pr_number: ${{ steps.create_pr.outputs.pr_number }}
GITHUB_TOKEN: ${{ secrets._REPO_ADMIN_TOKEN }}

- name: add the no-cherrypick label
uses: actions/github-script@v7
with:
github-token: ${{ secrets._REPO_ADMIN_TOKEN }}
script: |
github.rest.issues.addLabels({
issue_number: ${{ steps.create_pr.outputs.pr_number }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["No-CherryPick"]
})
auto-branching-master:
name: master - raise PR with changes
runs-on: ubuntu-latest
needs: check-group-membership
if: ${{ needs.check-group-membership.outputs.member == 'true' }}

steps:
- uses: actions/checkout@v4

- name: Update target branch label in dependabot yml file
id: update-dependabot
run: |
# Read the dependabot.yml file
FILE_PATH="./.github/dependabot.yml"
TARGET_BRANCH="${{ github.event.inputs.target_branch }}"
# Append the target branch label to the labels node
awk -v target="'$TARGET_BRANCH'" '/^ *labels:/ {$0 = $0 "\n - " target} 1' "$FILE_PATH" > temp.yml && mv temp.yml "$FILE_PATH"
- name: git status
run: git status

- name: git diff
run: git diff

- name: Commit changes
run: |
git config --local user.email "Satellite-QE.satqe.com"
git config --local user.name "Satellite-QE"
branch_name="auto-branching-${{ github.event.inputs.target_branch }}-$(date '+%s')"
git checkout -b "$branch_name"
git add ./.github/*
git commit -m "Changes for ${{ github.event.inputs.target_branch }} new branch"
git push origin "$branch_name"
- name: Create pull request
id: create_pr
run: |
title="[master]: Changes for ${{ github.event.inputs.target_branch }} new branch"
body="
### Problem Statement
New ${{ github.event.inputs.target_branch }} downstream and master points to stream that is ${{ github.event.inputs.stream_version }}
### Solution
- Dependabot.yaml cherrypicks to ${{ github.event.inputs.target_branch }}
"
pr_number=$(gh pr create --title "$title" --body "$body" --base "master" | awk -F'/' '{print $NF}')
echo "$pr_number"
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets._REPO_ADMIN_TOKEN }}

- name: Add the prt comment for running the sanity tests
id: add-parent-prt-comment
uses: thollander/actions-comment-pull-request@v2
with:
message: |
trigger: test-robottelo
pr_number: ${{ steps.create_pr.outputs.pr_number }}
GITHUB_TOKEN: ${{ secrets._REPO_ADMIN_TOKEN }}


- name: add the no-cherrypick label
uses: actions/github-script@v7
with:
github-token: ${{ secrets._REPO_ADMIN_TOKEN }}
script: |
github.rest.issues.addLabels({
issue_number: ${{ steps.create_pr.outputs.pr_number }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["No-CherryPick"]
})
4 changes: 2 additions & 2 deletions .github/workflows/auto_cherry_pick_merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Wait for other status checks to Pass
id: waitforstatuschecks
uses: lewagon/[email protected].3
uses: lewagon/[email protected].4
with:
ref: ${{ github.head_ref }}
repo-token: ${{ secrets.CHERRYPICK_PAT }}
Expand All @@ -67,7 +67,7 @@ jobs:
- id: automerge
name: Auto merge of cherry-picked PRs.
uses: "pascalgn/[email protected].2"
uses: "pascalgn/[email protected].3"
env:
GITHUB_TOKEN: "${{ secrets.CHERRYPICK_PAT }}"
MERGE_LABELS: "AutoMerge_Cherry_Picked, Auto_Cherry_Picked"
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ ci:

repos:
- repo: https://github.com/psf/black
rev: 24.2.0
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
rev: v0.3.5
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: debug-statements
3 changes: 2 additions & 1 deletion airgun/entities/contenthost.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def read_all(self, widget_names=None):
def read(self, entity_name, widget_names=None):
"""Read content host details, optionally read only the widgets in widget_names."""
view = self.navigate_to(self, 'Edit', entity_name=entity_name)
view.is_displayed
view.wait_displayed()
self.browser.plugin.ensure_page_safe()
return view.read(widget_names=widget_names)

def read_legacy_ui(self, entity_name, widget_names=None):
Expand Down
1 change: 1 addition & 0 deletions airgun/entities/redhat_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def search(self, value, category='Available', types=None):
eg: RPM, OSTree ...
"""
view = self.navigate_to(self, 'All')
wait_for(lambda: view.search_box.is_displayed, timeout=10, delay=1)
return view.search(value, category=category, types=types)

def read(self, entity_name=None, category='Available', recommended_repo=None):
Expand Down
2 changes: 1 addition & 1 deletion airgun/views/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def is_displayed(self):

@View.nested
class discovered_repos(View):
discover_action = Text("//button[@type='submit']")
discover_action = Text("//button[@type='submit' and contains(., 'Discover')]")
cancel_discovery = Text("//button[@ng-click='cancelDiscovery()']")
repos = CreateDiscoveredReposView()

Expand Down
8 changes: 6 additions & 2 deletions airgun/views/redhat_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ class RedHatRepositoriesView(BaseLoggedInView):

title = Text("//h1[contains(., 'Red Hat Repositories')]")
search_category = RepositorySearchCategory(".//div[button[@id='search-list-select']]")
search_box = TextInput(locator=".//input[@aria-label='Search input']")
search_button = Text(".//button[@aria-label='Search']")
search_box = TextInput(
locator='//*[@id="redhatRepositoriesPage"]//following::input[@aria-label="Search input"]'
)
search_button = Text(
'//*[@id="redhatRepositoriesPage"]//following::button[@aria-label="Search"]'
)
search_types = RepositorySearchTypes(".//div[button[@data-id='formControlsSelectMultiple']]")
search_clear = Text(".//span[@class = 'fa fa-times']")
recommended_repos = Text(".//div[contains(@class, 'bootstrap-switch wrapper')]")
Expand Down
3 changes: 1 addition & 2 deletions airgun/views/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from airgun.views.common import (
BaseLoggedInView,
SearchableViewMixin,
SearchableViewMixinPF4,
)
from airgun.widgets import (
ActionsDropdown,
Expand All @@ -26,7 +25,7 @@
)


class RepositoriesView(BaseLoggedInView, SearchableViewMixinPF4):
class RepositoriesView(BaseLoggedInView, SearchableViewMixin):
breadcrumb = BreadCrumb()
new = Text("//button[contains(@href, '/repositories/new')]")
sync = Text("//button[contains(@ng-click, 'syncSelectedRepositories')]")
Expand Down
2 changes: 1 addition & 1 deletion airgun/views/rhsso_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def is_displayed(self):


class RhssoTotpView(View, ClickableMixin):
totp = TextInput(id='totp')
totp = TextInput(id='otp')
submit = Text('//input[@name="login"]')

@property
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'pytest',
'wait_for',
'webdriver-kaifuku',
'selenium==4.18.1',
'selenium==4.19.0',
'widgetastic.core',
'widgetastic.patternfly',
'widgetastic.patternfly4',
Expand Down

0 comments on commit 35f3b80

Please sign in to comment.