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

[Compute] Autogen PR Issue 51 #42

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
73 changes: 73 additions & 0 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This is a basic workflow to help you get started with Actions

name: demo

on:
issues:
types:
- reopened
- opened

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions: write-all
defaults:
run:
shell: bash # Specify the shell you want to use (e.g., bash, pwsh, sh, etc.)

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: pacoxu/actions-comment-on-issue@1.0.3
name : Bot Init
with:
message: "AI bot is preparing code suggestions."
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Powershell repo
uses: actions/checkout@v2

- name: Get directory
run: ls

- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.8
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r .github/workflows/script/requirements.txt
- name: execute py script # run file
run: |
python ./.github/workflows/script/test.py


- uses: pacoxu/actions-comment-on-issue@1.0.3
name: Create Code Suggestions PR
with:
message: "Here are the suggested code change: Edit the testfile.js"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Branch
# You may pin to the exact commit or the version.
# uses: peterjgrainger/action-create-branch@b48b0ca0e307c9b56f059b70274984ffeaa90a43
uses: peterjgrainger/action-create-branch@v2.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# The branch to create
branch: issuebranch


- name: create pull request
run: |
gh pr create -R ${{ github.event.issue.user.login }}/azure-powershell -H issuebranch --title 'test PR' --body 'resolves https://github.com/${{ github.event.issue.user.login }}/azure-powershell/issues/${{ github.event.issue.number }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_ENTERPRISE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/script/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
openai==0.27.4
requests==2.25.1
25 changes: 25 additions & 0 deletions .github/workflows/script/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import requests
import subprocess

print("im here")
url = f"https://raw.githubusercontent.com/Azure/azure-powershell/main/src/Compute/Compute/Extension/CustomScript/SetAzureVMCustomScriptExtensionCommand.cs"
response = requests.get(url)
if response.status_code == 200:
content = response.content
content_str = content.decode('utf-8')
print(content_str)

code = content_str.split('public override void ExecuteCmdlet()')[1]

out = subprocess.run(['gh', 'issue', 'view','-R', 'Azure/azure-powershell-cmdlet-review-pr', '1352'], capture_output=True)

# parse stdout to get the issue body
issue_body = out.stdout.decode('utf-8').split('---')[0]

# find the string 'Sample of end-to-end usage' and then the immediate next line
sample_code = issue_body.split('### Changed cmdlet')[1]

# find the string '## Specific test cases' and then the previous line
test_case = sample_code.split('##')[0]

print(test_case)
6 changes: 6 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

-->
## Upcoming Release
* Added new parameter `-SharingProfile` to `New-AzCapacityReservationGroup` and `Update-AzCapacityReservationGroup` cmdlets.
- The `SharingProfile` parameter is an array of strings that contains an array of Arm resource ids of subscriptions.
- Example: "/subscriptions/{subscriptionId1}", "/subscriptions/{subscriptionId2}"
* Fixed the `Update-AzVmss` cmdlet so the `AutomaticRepairGracePeriod`, `AutomaticRepairAction`, and `EnableAutomaticRepair` parameters function correctly.
* Updated help doc for `New-AzVM`, `New-AzVMConfig`, `New-AzVmss`, `New-AzVmssConfig`, `Update-AzVM`, and `Update-AzVmss` to include parameters that were previously added for Trusted Launch features.
* Updated Azure.Core to 1.33.0.
* Fixed the `Update-AzVmss` cmdlet so the `AutomaticRepairGracePeriod`, `AutomaticRepairAction`, and `EnableAutomaticRepair` parameters function correctly.
* Updated help doc for `New-AzVM`, `New-AzVMConfig`, `New-AzVmss`, `New-AzVmssConfig`, `Update-AzVM`, and `Update-AzVmss` to include parameters that were previously added for Trusted Launch features.
* Updated Azure.Core to 1.33.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -70,6 +70,10 @@ public class NewAzureCapacityReservationGroup : ComputeAutomationBaseCmdlet
Mandatory = false)]
public string[] Zone { get; set; }

[Parameter(
Mandatory = false)]
public string[] SharingProfile { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Expand All @@ -88,6 +92,10 @@ public override void ExecuteCmdlet()
{
capacityReservationGroup.Zones = this.Zone;
}
if (this.IsParameterBound(c => c.SharingProfile))
{
capacityReservationGroup.SharingProfile = this.SharingProfile;
}

var result = CapacityReservationGroupClient.CreateOrUpdate(this.ResourceGroupName, this.Name, capacityReservationGroup);
var psObject = new PSCapacityReservationGroup();
Expand All @@ -98,3 +106,4 @@ public override void ExecuteCmdlet()
}
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Microsoft.Azure.Management.Compute.Models;
Expand All @@ -16,5 +16,6 @@ public class PSCapacityReservationGroup
public IList<SubResourceReadOnly> VirtualMachinesAssociated { get; set; }
public CapacityReservationGroupInstanceView InstanceView { get; set; }
public IList<string> Zones { get; set; }
public string[] SharingProfile { get; set; }
}
}
}