Skip to content

Commit

Permalink
Add dotnet workflows (#222)
Browse files Browse the repository at this point in the history
For #210
- Workflow *dotnet-ci* on push - build/test/pack and upload artifacts.
- Workflow *dotnet-pr* on pull request - build/test and print test
coverage.
- Add `.editorconfig` file for lint and format. Use warning severity for
now and will change to error after fixing all source code.

Since GitHub detects workflows from the default branch. Actions will be
available after #223 is
merged.
I used my forked repo to test the workflow. See
https://github.com/swatDong/teams-ai/actions/runs/5441987419,
https://github.com/swatDong/teams-ai/actions/runs/5442299363
  • Loading branch information
swatDong authored Jul 4, 2023
1 parent 4d0557f commit bfe4412
Show file tree
Hide file tree
Showing 4 changed files with 477 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/dotnet-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# This workflow will build, run tests, and pack for the Microsoft.Bot.Builder.M365 .NET SDK.
#

name: dotnet-ci

on:
workflow_dispatch:
push:
branches:
- DOTNET
paths:
- 'dotnet/packages/**'

jobs:
dotnet-build-test-pack:
strategy:
matrix:
os: [windows-latest]
dotnet-version: ['6.0', '7.0']
configuration: [Release]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
SOLUTION_DIR: dotnet/packages/Microsoft.Bot.Builder.M365/
steps:
- name: Checkout source
uses: actions/checkout@v3
with:
clean: true

- name: Setup .NET SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Restore
shell: bash
working-directory: ${{ env.SOLUTION_DIR }}
run: dotnet restore Microsoft.Bot.Builder.M365.sln

- name: Build
shell: bash
working-directory: ${{ env.SOLUTION_DIR }}
run: dotnet build Microsoft.Bot.Builder.M365.sln --no-restore --configuration ${{ matrix.configuration }}

- name: Test
shell: bash
working-directory: ${{ env.SOLUTION_DIR }}
run: dotnet test Microsoft.Bot.Builder.M365.Tests/Microsoft.Bot.Builder.M365.Tests.csproj --no-restore --verbosity normal --logger trx --results-directory ./TestResults --collect:"XPlat Code Coverage" --configuration ${{ matrix.configuration }}

- name: Pack
shell: bash
working-directory: ${{ env.SOLUTION_DIR }}
run: dotnet pack --no-build --output . --configuration ${{ matrix.configuration }} Microsoft.Bot.Builder.M365/Microsoft.Bot.Builder.M365.csproj

- name: Upload package
uses: actions/upload-artifact@v3
with:
name: nupkg-dotnet-${{ matrix.dotnet-version }}
path: ${{ env.SOLUTION_DIR }}*.nupkg

- name: Generate coverage report
uses: danielpalme/ReportGenerator-GitHub-Action@5.1.22
with:
reports: ${{ env.SOLUTION_DIR }}TestResults/*/coverage.cobertura.xml
targetdir: ${{ env.SOLUTION_DIR }}TestResults/coverage
reporttypes: HtmlInline
toolpath: ${{ env.SOLUTION_DIR }}report-generator-tool

- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: testresults-dotnet-${{ matrix.dotnet-version }}
path: ${{ env.SOLUTION_DIR }}TestResults
61 changes: 61 additions & 0 deletions .github/workflows/dotnet-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# This workflow will build and run tests for the Microsoft.Bot.Builder.M365 .NET SDK.
#

name: dotnet-pr

on:
pull_request:
branches:
- DOTNET
paths:
- 'dotnet/packages/**'

jobs:
dotnet-build-test:
strategy:
matrix:
os: [windows-latest]
dotnet-version: ['6.0', '7.0']
configuration: [Release]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
SOLUTION_DIR: dotnet/packages/Microsoft.Bot.Builder.M365/
steps:
- name: Checkout source
uses: actions/checkout@v3
with:
clean: true

- name: Setup .NET SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Restore
shell: bash
working-directory: ${{ env.SOLUTION_DIR }}
run: dotnet restore Microsoft.Bot.Builder.M365.sln

- name: Build
shell: bash
working-directory: ${{ env.SOLUTION_DIR }}
run: dotnet build Microsoft.Bot.Builder.M365.sln --no-restore --configuration ${{ matrix.configuration }}

- name: Test
shell: bash
working-directory: ${{ env.SOLUTION_DIR }}
run: dotnet test Microsoft.Bot.Builder.M365.Tests/Microsoft.Bot.Builder.M365.Tests.csproj --no-restore --verbosity normal --logger trx --results-directory ./TestResults --collect:"XPlat Code Coverage" --configuration ${{ matrix.configuration }}

- name: Generate coverage report
uses: danielpalme/ReportGenerator-GitHub-Action@5.1.22
with:
reports: ${{ env.SOLUTION_DIR }}TestResults/*/coverage.cobertura.xml
targetdir: ${{ env.SOLUTION_DIR }}TestResults/coverage
reporttypes: TextSummary
toolpath: ${{ env.SOLUTION_DIR }}report-generator-tool

- name: Show coverage
shell: bash
run: cat ${{ env.SOLUTION_DIR }}TestResults/coverage/*.txt
Loading

0 comments on commit bfe4412

Please sign in to comment.