From a9c0fc0cbdc038704d991afd42e39390558ccefb Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Mon, 11 Dec 2023 17:03:13 -0800 Subject: [PATCH 01/11] update --- .github/workflows/dotnet/build.yml | 37 ++++++++++++++++++++++++++++++ .github/workflows/pre-commit.yml | 9 +++++--- 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/dotnet/build.yml diff --git a/.github/workflows/dotnet/build.yml b/.github/workflows/dotnet/build.yml new file mode 100644 index 000000000000..249aca474db7 --- /dev/null +++ b/.github/workflows/dotnet/build.yml @@ -0,0 +1,37 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: dotnet-ci + +on: + pull_request: + branches: [ "main" ] + paths: + - 'dotnet/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +permissions: + contents: read + +jobs: + build: + name: CI + runs-on: ubuntu-latest + defaults: + run: + working-directory: dotnet + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Unit Test + run: dotnet test --no-build --verbosity normal \ No newline at end of file diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index b3abaf8b6c17..2fff9d9df012 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -2,9 +2,12 @@ name: Code formatting # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows on: # Trigger the workflow on push or pull request, but only for the main branch - push: - branches: [main] - pull_request: {} + pull_request: + branches: [ "main" ] + paths: + - '.pre-commit-config.yaml' + - 'autogen/**' + - 'samples/**' defaults: run: From a37c35bc5598bc1e0be96d4d2da5d959f7d20af2 Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Mon, 11 Dec 2023 17:15:24 -0800 Subject: [PATCH 02/11] add openai workflow --- .../dotnet/run_openai_test_and_notebooks.yml | 53 +++++++++++++++ dotnet/.config/dotnet-tools.json | 12 ++++ dotnet/.tools/run_all_notebook.ps1 | 64 +++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 .github/workflows/dotnet/run_openai_test_and_notebooks.yml create mode 100644 dotnet/.config/dotnet-tools.json create mode 100644 dotnet/.tools/run_all_notebook.ps1 diff --git a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml new file mode 100644 index 000000000000..03f6d95d2040 --- /dev/null +++ b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml @@ -0,0 +1,53 @@ +name: run-openai-test-and-notebooks + +on: + pull_request_target: + branches: [ "main" ] + paths: + - 'dotnet/**' +env: + BUILD_CONFIGURATION: Release # set this to the appropriate build configuration + +jobs: + build: + environment: openai1 + name: run-openai-test-and-notebooks + runs-on: ubuntu-latest + defaults: + run: + working-directory: dotnet + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + + - name: Restore dependencies + run: dotnet restore + - name: Restore tool + run: dotnet tool restore + - name: Build + run: dotnet build --no-restore -p:VersionSuffix=$GITHUB_RUN_ID --configuration '${{ env.BUILD_CONFIGURATION }}' + - name: Pack + run: dotnet pack --no-restore -p:VersionSuffix=$GITHUB_RUN_ID --no-build --configuration '${{ env.BUILD_CONFIGURATION }}' --output ./artifacts + - name: run all tests + run: dotnet test --no-restore --no-build --configuration '${{ env.BUILD_CONFIGURATION }}' + env: + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} + AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} + AZURE_GPT_35_MODEL_ID: ${{ secrets.AZURE_GPT_35_MODEL_ID }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + + - name: Add local feed + run: dotnet nuget add source --name local artifacts --configfile NuGet.config + - name: Perform a Pester test from the .tools/run_all_notebooks.ps1 + shell: pwsh + run: | + Invoke-Pester .tools/run_all_notebook.ps1 -Passthru + env: + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} + AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} + AZURE_GPT_35_MODEL_ID: ${{ secrets.AZURE_GPT_35_MODEL_ID }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + \ No newline at end of file diff --git a/dotnet/.config/dotnet-tools.json b/dotnet/.config/dotnet-tools.json new file mode 100644 index 000000000000..5b341cff736a --- /dev/null +++ b/dotnet/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-repl": { + "version": "0.1.205", + "commands": [ + "dotnet-repl" + ] + } + } + } \ No newline at end of file diff --git a/dotnet/.tools/run_all_notebook.ps1 b/dotnet/.tools/run_all_notebook.ps1 new file mode 100644 index 000000000000..d1001064d599 --- /dev/null +++ b/dotnet/.tools/run_all_notebook.ps1 @@ -0,0 +1,64 @@ +# cd to the directory of this script +$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition +$rootPath = Split-Path -Parent $scriptPath +$outputFolder = "$rootPath/output" +if (Test-Path $outputFolder) { + Remove-Item $outputFolder -Recurse -Force +} +New-Item -ItemType Directory -Path $outputFolder + +Set-Location $rootPath + +# list all notebooks under notebook folder +$notebooks = Get-ChildItem -Path "$rootPath/notebook" -Recurse -Include *.ipynb | ForEach-Object { $_.FullName } +# skip those notebooks with the same name as the following +$skip_notebooks = @( + 'TwoAgentChat_UserProxy.ipynb' # require user input +) + +# for each notebook, run it using dotnet perl. Check the exit code and print out the result +# if the exit code is not 0, exit the script with exit code 1 +$failNotebooks = @() +$exitCode = 0 +$LASTEXITCODE = 0 +foreach ($notebook in $notebooks) { + Write-Host "Running $notebook" + # get notebook name with extension + $name = Split-Path -Leaf $notebook + + if ($skip_notebooks -contains $name) { + Write-Host "Skipping $name" + continue + } + Write-Host "Name: $name" + $notebookFolder = Split-Path -Parent $notebook + $outputPath = "$outputFolder\$notebookFolder" + Set-Location $notebookFolder + $proc = Start-Process -FilePath dotnet -ArgumentList "repl --run $name --exit-after-run" -PassThru -NoNewWindow + $timeout = $null + $proc | Wait-Process -Timeout 180 -ErrorAction SilentlyContinue -ErrorVariable $timeout + if ($timeout) { + Write-Host "Timeout when running $notebook" + $LASTEXITCODE = 1 + } + else { + $LASTEXITCODE = $proc.ExitCode + } + Write-Host "Exit code: $LASTEXITCODE" + if ($LASTEXITCODE -ne 0) { + Write-Host "Failed to run $notebook" + $failNotebooks += $notebook + $exitCode = 1 + } + else{ + Write-Host "Successfully ran $notebook" + } + Set-Location $rootPath +} + +Write-Host "Failed notebooks:" +foreach ($notebook in $failNotebooks) { + Write-Host $notebook +} + +$failNotebooks | Should -BeNullOrEmpty \ No newline at end of file From 064684955eb304140f2ddaf5f5730eec26ffa2d1 Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Tue, 19 Dec 2023 14:18:08 -0800 Subject: [PATCH 03/11] Update pre-commit.yml --- .github/workflows/pre-commit.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 2fff9d9df012..6c5087bf23c7 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -3,7 +3,6 @@ name: Code formatting # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows on: # Trigger the workflow on push or pull request, but only for the main branch pull_request: - branches: [ "main" ] paths: - '.pre-commit-config.yaml' - 'autogen/**' From 4e60f1685bce21f109c4053c1f48685415445d87 Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Tue, 19 Dec 2023 14:19:14 -0800 Subject: [PATCH 04/11] Update run_openai_test_and_notebooks.yml --- .github/workflows/dotnet/run_openai_test_and_notebooks.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml index 03f6d95d2040..214958d05f59 100644 --- a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml +++ b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml @@ -17,7 +17,10 @@ jobs: run: working-directory: dotnet steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Setup .NET uses: actions/setup-dotnet@v3 with: @@ -50,4 +53,4 @@ jobs: AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} AZURE_GPT_35_MODEL_ID: ${{ secrets.AZURE_GPT_35_MODEL_ID }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - \ No newline at end of file + From efa42fb6ef6ac44f957285457177867fb18356b4 Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Thu, 21 Dec 2023 11:05:15 -0800 Subject: [PATCH 05/11] Update pre-commit.yml --- .github/workflows/pre-commit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 6c5087bf23c7..948d79310a4f 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -7,6 +7,8 @@ on: # Trigger the workflow on push or pull request, but only for the main branc - '.pre-commit-config.yaml' - 'autogen/**' - 'samples/**' + merge_group: + types: [checks_requested] defaults: run: From 2c8bdedb823bece94bdd5529df87dbf5d1e64c11 Mon Sep 17 00:00:00 2001 From: Eric Zhu Date: Mon, 25 Dec 2023 12:07:35 -0800 Subject: [PATCH 06/11] Update .github/workflows/pre-commit.yml Co-authored-by: Chi Wang --- .github/workflows/pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 948d79310a4f..db83b5fdbac4 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,7 +1,7 @@ name: Code formatting # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows -on: # Trigger the workflow on push or pull request, but only for the main branch +on: # Trigger the workflow on pull request or merge pull_request: paths: - '.pre-commit-config.yaml' From fc3dbf8aeeefcd70abc08e28ff082b95028784fa Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Wed, 27 Dec 2023 10:21:08 -0800 Subject: [PATCH 07/11] Update run_openai_test_and_notebooks.yml --- .github/workflows/dotnet/run_openai_test_and_notebooks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml index 214958d05f59..239c82cf4fd3 100644 --- a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml +++ b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml @@ -10,7 +10,7 @@ env: jobs: build: - environment: openai1 + environment: dotnet_openai name: run-openai-test-and-notebooks runs-on: ubuntu-latest defaults: From e3eeeca3a69e986dac66f5f2e62d8faceed56f86 Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Wed, 27 Dec 2023 10:23:03 -0800 Subject: [PATCH 08/11] Update run_openai_test_and_notebooks.yml --- .github/workflows/dotnet/run_openai_test_and_notebooks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml index 239c82cf4fd3..8c6b36b0c5b0 100644 --- a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml +++ b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml @@ -10,7 +10,7 @@ env: jobs: build: - environment: dotnet_openai + environment: dotnet name: run-openai-test-and-notebooks runs-on: ubuntu-latest defaults: From 08d27e8fa58728c29e265f49fe8367908739152a Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Fri, 29 Dec 2023 11:05:59 -0800 Subject: [PATCH 09/11] Update run_openai_test_and_notebooks.yml --- .github/workflows/dotnet/run_openai_test_and_notebooks.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml index 8c6b36b0c5b0..0f01eb80cc1f 100644 --- a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml +++ b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml @@ -40,7 +40,6 @@ jobs: AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} AZURE_GPT_35_MODEL_ID: ${{ secrets.AZURE_GPT_35_MODEL_ID }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Add local feed run: dotnet nuget add source --name local artifacts --configfile NuGet.config @@ -52,5 +51,4 @@ jobs: AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} AZURE_GPT_35_MODEL_ID: ${{ secrets.AZURE_GPT_35_MODEL_ID }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} From 3c35e4ff97322dd1f4f1f16556527fa3295534d1 Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Fri, 29 Dec 2023 15:31:45 -0800 Subject: [PATCH 10/11] Update pre-commit.yml --- .github/workflows/pre-commit.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index db83b5fdbac4..70ff6009979b 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -3,10 +3,6 @@ name: Code formatting # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows on: # Trigger the workflow on pull request or merge pull_request: - paths: - - '.pre-commit-config.yaml' - - 'autogen/**' - - 'samples/**' merge_group: types: [checks_requested] From cf60e7c06b38504d7ca06f85be2b4d6ee5debcf1 Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Fri, 29 Dec 2023 15:32:20 -0800 Subject: [PATCH 11/11] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b13a94996b1..859b86547274 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ default_language_version: python: python3 - +exclude: 'dotnet' ci: autofix_prs: true autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'