Fix test run hang if an error occurs when trying to send test results to the server #57
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
branches: [ main ] | |
inputs: | |
prerelease: | |
description: 'Is this build a pre-release?' | |
required: true | |
default: 'true' | |
jobs: | |
build: | |
runs-on: windows-latest | |
env: | |
VERSION: 1.2.2 | |
strategy: | |
matrix: | |
Configuration: [Debug, Release] | |
steps: | |
- name: Set version number for pre-release | |
if: ${{ github.event.inputs.prerelease == '' || github.event.inputs.prerelease == 'true' }} | |
run: | | |
echo "SEM_VERSION=${{ env.VERSION }}-build-${{ github.RUN_NUMBER }}" >> $env:GITHUB_ENV | |
- name: Set version number for release | |
if: ${{ github.event.inputs.prerelease == 'false' }} | |
run: | | |
echo "SEM_VERSION=${{ env.VERSION }}" >> $env:GITHUB_ENV | |
- name: Read environmental variables | |
run: | | |
echo VERSION=${{ env.VERSION }} | |
echo GITHUB_RUN_NUMBER=${{ github.RUN_NUMBER }} | |
echo SEM_VERSION=${{ env.SEM_VERSION }} | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup .NET Core 2.1 | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 2.1 | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore --configuration ${{ matrix.Configuration }} -p:Version=${{ env.SEM_VERSION }} -p:AssemblyVersion=${{ env.VERSION }} -p:FileVersion=${{ env.VERSION }} | |
- name: Prepare for pack | |
run: | | |
mkdir .\src\AzurePipelines.TestLogger\contentFiles\any\any | |
copy ".\src\AzurePipelines.TestLogger\bin\${{ matrix.Configuration }}\netstandard1.5\*.dll" .\src\AzurePipelines.TestLogger\contentFiles\any\any | |
- name: Pack | |
run: dotnet pack .\src\AzurePipelines.TestLogger\AzurePipelines.TestLogger.csproj --configuration ${{ matrix.Configuration }} -p:NuspecProperties="Version=${{ env.SEM_VERSION }}" --no-restore --no-build --output:.\build -p:NuspecFile=AzurePipelines.TestLogger.nuspec | |
- name: Test | |
run: dotnet test --no-build --no-restore --verbosity normal --configuration ${{ matrix.Configuration }} | |
- name: Create zip | |
run: | | |
mkdir AzurePipelines.TestLogger.${{ env.SEM_VERSION }} | |
copy ".\src\AzurePipelines.TestLogger\bin\${{ matrix.Configuration }}\netstandard1.5\*.*" .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }} | |
copy ".\LICENSE" .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }} | |
copy ".\README.md" .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }} | |
copy ".\ReleaseNotes.md" .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }} | |
tar -cf AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.zip .\AzurePipelines.TestLogger.${{ env.SEM_VERSION }} | |
- name: Upload Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: AzurePipelines.TestLogger ${{ env.SEM_VERSION }} ${{ matrix.Configuration }} | |
path: AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.zip | |
if-no-files-found: error | |
- name: Publish GitHub Release | |
if: ${{ matrix.Configuration == 'Release' && github.event.inputs.prerelease == 'false' }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: v${{ env.SEM_VERSION }} | |
draft: true | |
prerelease: false | |
fail_on_unmatched_files: true | |
files: | | |
AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.zip | |
.\src\AzurePipelines.TestLogger\build\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.nupkg | |
- name: Upload NuGet Package | |
uses: actions/[email protected] | |
with: | |
name: AzurePipelines.TestLogger ${{ env.SEM_VERSION }} ${{ matrix.Configuration }}.nupkg | |
path: .\src\AzurePipelines.TestLogger\build\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.nupkg | |
if-no-files-found: error | |
- name: Publish NuGet Package | |
if: ${{ matrix.Configuration == 'Release' && github.event_name != 'pull_request' }} | |
run: dotnet nuget push .\src\AzurePipelines.TestLogger\build\AzurePipelines.TestLogger.${{ env.SEM_VERSION }}.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json |