mirror of
https://github.com/microsoft/autogen.git
synced 2025-11-01 18:29:49 +00:00
[Dotnet] Add dotnet build workflow (#946)
* update * add openai workflow * Update pre-commit.yml * Update run_openai_test_and_notebooks.yml * Update pre-commit.yml * Update .github/workflows/pre-commit.yml Co-authored-by: Chi Wang <wang.chi@microsoft.com> * Update run_openai_test_and_notebooks.yml * Update run_openai_test_and_notebooks.yml * Update run_openai_test_and_notebooks.yml * Update pre-commit.yml * Update .pre-commit-config.yaml --------- Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com> Co-authored-by: Chi Wang <wang.chi@microsoft.com>
This commit is contained in:
parent
16b1723c74
commit
2d3ed96f46
37
.github/workflows/dotnet/build.yml
vendored
Normal file
37
.github/workflows/dotnet/build.yml
vendored
Normal file
@ -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
|
||||
54
.github/workflows/dotnet/run_openai_test_and_notebooks.yml
vendored
Normal file
54
.github/workflows/dotnet/run_openai_test_and_notebooks.yml
vendored
Normal file
@ -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 }}
|
||||
|
||||
8
.github/workflows/pre-commit.yml
vendored
8
.github/workflows/pre-commit.yml
vendored
@ -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:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
default_language_version:
|
||||
python: python3
|
||||
|
||||
exclude: 'dotnet'
|
||||
ci:
|
||||
autofix_prs: true
|
||||
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
|
||||
|
||||
12
dotnet/.config/dotnet-tools.json
Normal file
12
dotnet/.config/dotnet-tools.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-repl": {
|
||||
"version": "0.1.205",
|
||||
"commands": [
|
||||
"dotnet-repl"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
64
dotnet/.tools/run_all_notebook.ps1
Normal file
64
dotnet/.tools/run_all_notebook.ps1
Normal file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user