From 16c85b773bf3d5dedc9ff4fda3b578954b897150 Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Wed, 26 Jul 2023 16:39:42 -0400 Subject: [PATCH 01/12] Create demo.yml --- .github/workflows/demo.yml | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/demo.yml diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml new file mode 100644 index 000000000000..761c7ab146dc --- /dev/null +++ b/.github/workflows/demo.yml @@ -0,0 +1,67 @@ +# 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 + + - 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 }}/PSAGI -H issuebranch --title 'test PR' --body 'resolves https://github.com/${{ github.event.issue.user.login }}/PSAGI/issues/${{ github.event.issue.number }}' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_ENTERPRISE_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: setup python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + run: | + python -m pip install --upgrade pip + pip install flake8 + - name: execute py script # run file + run: | + python script/test.py From 6de27635ee2e91d5def1302b7fc9d77979e04c61 Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Thu, 27 Jul 2023 10:45:57 -0400 Subject: [PATCH 02/12] Update demo.yml --- .github/workflows/demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 761c7ab146dc..6c7e3184f149 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -50,7 +50,7 @@ jobs: - name: create pull request run: | - gh pr create -R ${{ github.event.issue.user.login }}/PSAGI -H issuebranch --title 'test PR' --body 'resolves https://github.com/${{ github.event.issue.user.login }}/PSAGI/issues/${{ github.event.issue.number }}' + 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 }} From 63c1975885b9aedf4c2456ce55d42b11b9c7160a Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:59:08 -0400 Subject: [PATCH 03/12] Create test.py --- .github/workflows/script/test.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/script/test.py diff --git a/.github/workflows/script/test.py b/.github/workflows/script/test.py new file mode 100644 index 000000000000..adf0c106a5df --- /dev/null +++ b/.github/workflows/script/test.py @@ -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) From bd22c33a4c584f78e5c39e6b1ba0f5a683643fa4 Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Mon, 31 Jul 2023 13:02:52 -0400 Subject: [PATCH 04/12] Update demo.yml --- .github/workflows/demo.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 6c7e3184f149..a8d79da46e9e 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -47,14 +47,7 @@ jobs: 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 }} - + - name: setup python uses: actions/setup-python@v2 with: @@ -65,3 +58,10 @@ jobs: - name: execute py script # run file run: | python script/test.py + + - 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 }} From d03b533818366b2e9d118eecc308c8bc4753d4a4 Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Mon, 31 Jul 2023 13:06:52 -0400 Subject: [PATCH 05/12] Update demo.yml --- .github/workflows/demo.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index a8d79da46e9e..eb8bba1b2dd1 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -27,10 +27,20 @@ jobs: message: "AI bot is preparing code suggestions." GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: setup python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + run: | + python -m pip install --upgrade pip + pip install flake8 + - name: execute py script # run file + run: | + python .github/workflows/script/test.py # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout Powershell repo - uses: actions/checkout@v2 + #uses: actions/checkout@v2 - uses: pacoxu/actions-comment-on-issue@1.0.3 name: Create Code Suggestions PR @@ -48,16 +58,6 @@ jobs: # The branch to create branch: issuebranch - - name: setup python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - run: | - python -m pip install --upgrade pip - pip install flake8 - - name: execute py script # run file - run: | - python script/test.py - name: create pull request run: | From f8cadf92ac832c3b46cdbcaf3a51419c90bcff1a Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Mon, 31 Jul 2023 13:08:21 -0400 Subject: [PATCH 06/12] Update demo.yml --- .github/workflows/demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index eb8bba1b2dd1..b7b4c49428bc 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -40,7 +40,7 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout Powershell repo - #uses: actions/checkout@v2 + uses: actions/checkout@v2 - uses: pacoxu/actions-comment-on-issue@1.0.3 name: Create Code Suggestions PR From 4c1a5b6c98e9bd228dc088dfa3de62bf0cab3231 Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Mon, 31 Jul 2023 13:12:03 -0400 Subject: [PATCH 07/12] Update demo.yml --- .github/workflows/demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index b7b4c49428bc..c211753a1f5a 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -36,7 +36,7 @@ jobs: pip install flake8 - name: execute py script # run file run: | - python .github/workflows/script/test.py + python script/test.py # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout Powershell repo From 17ac937b803a19be4c1f95343c5239fbb035ba6c Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Mon, 31 Jul 2023 13:19:49 -0400 Subject: [PATCH 08/12] Update demo.yml --- .github/workflows/demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index c211753a1f5a..af11c124aa49 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -36,7 +36,7 @@ jobs: pip install flake8 - name: execute py script # run file run: | - python script/test.py + python ./.github/workflows/script/test.py # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout Powershell repo From aa03ac29178b16710a077abf3ecccb4901d35684 Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:17:02 -0400 Subject: [PATCH 09/12] Update demo.yml --- .github/workflows/demo.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index af11c124aa49..bd1ef0fc1d87 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -26,6 +26,14 @@ jobs: 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 @@ -36,11 +44,8 @@ jobs: pip install flake8 - name: execute py script # run file run: | - python ./.github/workflows/script/test.py + python ${{ GITHUB_WORKSPACE }}/.github/workflows/script/test.py - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Checkout Powershell repo - uses: actions/checkout@v2 - uses: pacoxu/actions-comment-on-issue@1.0.3 name: Create Code Suggestions PR From 0f681a27a3f65858a6b14381551c81d32128d5e9 Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:19:58 -0400 Subject: [PATCH 10/12] Update demo.yml --- .github/workflows/demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index bd1ef0fc1d87..537d7e65a954 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -44,7 +44,7 @@ jobs: pip install flake8 - name: execute py script # run file run: | - python ${{ GITHUB_WORKSPACE }}/.github/workflows/script/test.py + python ./.github/workflows/script/test.py - uses: pacoxu/actions-comment-on-issue@1.0.3 From 4c39472bb0ae77ab10173023498ffec34fca3515 Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:26:24 -0400 Subject: [PATCH 11/12] Update demo.yml --- .github/workflows/demo.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 537d7e65a954..cbb7c84681a4 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -42,6 +42,7 @@ jobs: 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 From 838ce7831118e7b152d33ca3f8d2b87eecb35288 Mon Sep 17 00:00:00 2001 From: Haider Agha <64601174+haagha@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:26:42 -0400 Subject: [PATCH 12/12] Create requirements.txt --- .github/workflows/script/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/workflows/script/requirements.txt diff --git a/.github/workflows/script/requirements.txt b/.github/workflows/script/requirements.txt new file mode 100644 index 000000000000..f5df5c2bd549 --- /dev/null +++ b/.github/workflows/script/requirements.txt @@ -0,0 +1,2 @@ +openai==0.27.4 +requests==2.25.1