A programming framework for agentic AI
[Dotnet] Add dotnet build workflow (#946)
Xiaoyun Zhang2d3ed96f46a2
diff --git a/.github/workflows/dotnet/build.yml b/.github/workflows/dotnet/build.ymlnew file mode 100644index 000000000..249aca474--- /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 filediff --git a/.github/workflows/dotnet/run_openai_test_and_notebooks.yml b/.github/workflows/dotnet/run_openai_test_and_notebooks.ymlnew file mode 100644index 000000000..0f01eb80c--- /dev/null+++ b/.github/workflows/dotnet/run_openai_test_and_notebooks.yml@@ -0,0 +1,54 @@+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: dotnet+ name: run-openai-test-and-notebooks+ runs-on: ubuntu-latest+ defaults:+ run:+ working-directory: dotnet+ steps:+ - name: Checkout+ uses: actions/checkout@v3+ with:+ ref: ${{ github.event.pull_request.head.sha }}+ - 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 }}++ - 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 }}+diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.ymlindex b3abaf8b6..70ff60099 100644--- a/.github/workflows/pre-commit.yml+++ b/.github/workflows/pre-commit.yml@@ -1,10 +1,10 @@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: {}+on: # Trigger the workflow on pull request or merge+ pull_request:+ merge_group:+ types: [checks_requested]defaults:run:diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 1b13a9499..859b86547 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: trueautoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'diff --git a/dotnet/.config/dotnet-tools.json b/dotnet/.config/dotnet-tools.jsonnew file mode 100644index 000000000..5b341cff7--- /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 filediff --git a/dotnet/.tools/run_all_notebook.ps1 b/dotnet/.tools/run_all_notebook.ps1new file mode 100644index 000000000..d1001064d--- /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