Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/SatelliteQE/airgun into c…
Browse files Browse the repository at this point in the history
…v-ui-publish
  • Loading branch information
sambible committed Sep 4, 2024
2 parents d072780 + 228fa76 commit 0972c34
Show file tree
Hide file tree
Showing 178 changed files with 5,632 additions and 2,064 deletions.
31 changes: 31 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This is the configuration file for Dependabot. You can find configuration information below.
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# Note: Dependabot has a configurable max open PR limit of 5

version: 2
updates:
# Maintain dependencies for Airgun itself
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
labels:
- '6.16.z'
- "CherryPick"
- "dependencies"
- "6.15.z"
- "6.14.z"
- "6.13.z"

# Maintain dependencies for our GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- '6.16.z'
- "CherryPick"
- "dependencies"
- "6.15.z"
- "6.14.z"
- "6.13.z"
2 changes: 1 addition & 1 deletion .github/workflows/auto_assignment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
if: "!contains(github.event.pull_request.labels.*.name, 'Auto_Cherry_Picked')"
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/auto-assign-action@v1.2.4
- uses: kentaro-m/auto-assign-action@v2.0.0
with:
repo-token: "${{ secrets.CHERRYPICK_PAT || github.token }}"
configuration-path: ".github/auto_assign.yml"
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"]
})
17 changes: 12 additions & 5 deletions .github/workflows/auto_cherry_pick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: auto_cherry_pick_commits

on:
pull_request_target:
types: [closed, labeled]
types: [closed]

# Github & Parent PR Env vars
env:
Expand All @@ -22,11 +22,12 @@ jobs:
prt_comment: ${{steps.fc.outputs.comment-body}}
steps:
- name: Find Comment
uses: peter-evans/find-comment@v2
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ env.number }}
body-includes: "trigger: test-robottelo"
direction: last

# Auto CherryPicking and Failure Recording
auto-cherry-pick:
Expand All @@ -39,8 +40,14 @@ jobs:
label: ${{ github.event.pull_request.labels.*.name }}

steps:
# Needed to avoid out-of-memory error
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10

## Airgun Repo Checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4
if: ${{ startsWith(matrix.label, '6.') && matrix.label != github.base_ref }}
with:
fetch-depth: 0
Expand Down Expand Up @@ -70,7 +77,7 @@ jobs:

- 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
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CHERRYPICK_PAT }}
script: |
Expand All @@ -84,7 +91,7 @@ jobs:
## Failure Logging to issues and GChat Group
- name: Create Github issue on cherrypick failure
id: create-issue
if: ${{ always() && steps.cherrypick.outcome == 'failure' }}
if: ${{ always() && steps.cherrypick.outcome != 'success' && startsWith(matrix.label, '6.') && matrix.label != github.base_ref }}
uses: dacbd/create-issue-action@main
with:
token: ${{ secrets.CHERRYPICK_PAT }}
Expand Down
Loading

0 comments on commit 0972c34

Please sign in to comment.