This repository has been archived on 2022-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
DevOpsOpenHack/.github/workflows/poi-tests.yml

76 lines
2.2 KiB
YAML
Raw Normal View History

2022-11-03 20:41:13 +00:00
name: 'POI API - Unit Tests'
# this is triggered when there is a pull request on the below path, where the PR type is opened or reopened
on:
pull_request:
types: [opened, reopened]
branches:
- main
paths:
- 'apis/poi/**'
workflow_dispatch:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#permissions:
# contents: read
defaults:
run:
shell: bash
working-directory: ./apis/poi/tests/UnitTests
jobs:
Build:
name: 'Build'
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET Core SDK 3.1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.x
- name: Build
run: dotnet build
- name: Run UnitTest
run: dotnet test --filter "FullyQualifiedName~UnitTest" --logger "trx;LogFileName=UnitTestResults.trx" --results-directory ./TestResults
- name: Create Issue
if: failure() && github.event_name != 'pull_request'
run: |
body='### Unit Test `failure`
<details>
<summary>Workflow details</summary>
Workflow name: `${{ github.workflow }}`
Action: `${{ github.event_name }}`
Job: `${{ github.job }}`
</details>
Test details: [Run #${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
Pusher: @${{ github.actor }}'
title='Unit Tests failure'
gh issue create --title "${title}" --body "${body}" --label bug --assignee ${{ github.actor }}
- name: "Create a PR comment"
if: failure() && github.event_name == 'pull_request'
run: |
body='### Unit Test `failure`
<details>
<summary>Workflow details</summary>
Workflow name: `${{ github.workflow }}`
Action: `${{ github.event_name }}`
Job: `${{ github.job }}`
PR: #${{ github.event.number }}
</details>
Test details: [Run #${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
Pusher: @${{ github.actor }}'
gh pr comment ${{ github.event.number }} --body "${body}"