[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:
Xiaoyun Zhang
2023-12-29 18:23:12 -08:00
committed by GitHub
parent 16b1723c74
commit 2d3ed96f46
6 changed files with 172 additions and 5 deletions

37
.github/workflows/dotnet/build.yml vendored Normal file
View 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

View 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 }}