From f6f45b1140195f3f8b6f2c1d86a0471bea1e8743 Mon Sep 17 00:00:00 2001 From: Michael Hallock Date: Thu, 21 Oct 2021 19:35:57 -0400 Subject: [PATCH] Fixes an issue where a failure to establish initial stream parsing could hang --- .github/workflows/build.yml | 47 +++++++++++++++ .github/workflows/release.yml | 101 +++++++++++++++++++++++++++++++++ README.md | 4 +- src/HarmonyHub/Client.cs | 2 +- src/HarmonyHub/StreamParser.cs | 3 + 5 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..97f8d2d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: build +on: + push: + branches: + - "**" + pull_request: + branches: + - "**" + +env: + DOTNETVERSION: "5.0.x" + APP: "HarmonyHub" + SOLUTION: "./src/HarmonyHub.sln" + BUILDOUTPUTPATH: "./src/HarmonyHub/bin/Release/netstandard2.0" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup .NET Core SDK ${{ env.DOTNETVERSION }} + uses: actions/setup-dotnet@v1.7.2 + with: + dotnet-version: ${{ env.DOTNETVERSION }} + + - name: Install dependencies + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build + run: dotnet build ${{ env.SOLUTION }} --configuration Release --no-restore + + - name: Upload app build artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.APP }} + path: ${{ env.BUILDOUTPUTPATH }} + + - name: Test + run: dotnet test ${{ env.SOLUTION }} --no-restore --verbosity normal --logger trx --results-directory "TestResults" + + - name: Upload TestResults build artifact + uses: actions/upload-artifact@v2 + with: + name: TestResults + path: TestResults \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..033a678 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,101 @@ +name: release +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+.[0-9]+" + +env: + DOTNETVERSION: "5.0.x" + APP: "HarmonyHub" + SOLUTION: "./src/HarmonyHub.sln" + BUILDOUTPUTPATH: "./src/HarmonyHub/bin/Release/netstandard2.0" + PACKOUTPUTPATH: "./out" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + ref: master + fetch-depth: 0 + + - name: Setup .NET Core SDK ${{ env.DOTNETVERSION }} + uses: actions/setup-dotnet@v1.7.2 + with: + dotnet-version: ${{ env.DOTNETVERSION }} + + - name: Get version + id: version + uses: battila7/get-version-action@v2 + + - name: Get previous release tag + id: previousTag + uses: sammcoe/get-previous-release-action@v1.0.3 + + - name: Install dependencies + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build + run: dotnet build ${{ env.SOLUTION }} --configuration Release --no-restore /p:Version=${{ steps.version.outputs.version-without-v }} + + - name: Test + run: dotnet test ${{ env.SOLUTION }} --no-restore --verbosity normal --logger trx --results-directory "TestResults" + + - name: Upload app build artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.APP }}-${{ steps.version.outputs.version-without-v }} + path: ${{ env.BUILDOUTPUTPATH }} + + - name: Upload TestResults build artifact + uses: actions/upload-artifact@v2 + with: + name: TestResults + path: TestResults + + - name: Build changelog + id: gitLog + uses: jarrodparkes/git-log-action@1.0.0 + with: + start: ${{ steps.previousTag.outputs.tag }} + end: ${{ github.ref }} + + - name: GitHub release + uses: actions/create-release@v1 + id: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + release_name: ${{ steps.version.outputs.version-without-v }} + tag_name: ${{ github.ref }} + body: ${{ env.LOG }} + draft: false + prerelease: false + + - name: ZIP release artifact + run: zip -r ${{ env.APP }}-${{ steps.version.outputs.version-without-v }}.zip ${{ env.BUILDOUTPUTPATH }} + + - name: GitHub release assets + uses: actions/upload-release-asset@v1 + id: release_assets + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release.outputs.upload_url }} + asset_path: ${{ env.APP }}-${{ steps.version.outputs.version-without-v }}.zip + asset_name: ${{ env.APP }}-${{ steps.version.outputs.version-without-v }}.zip + asset_content_type: application/zip + + - name: NuGet pack + run: dotnet pack ${{ env.SOLUTION }} --configuration Release --no-restore --include-symbols /p:Version=${{ steps.version.outputs.version-without-v }} -o ${{ env.PACKOUTPUTPATH }} + + - name: Upload NuGet build artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.APP }} NuGet Packages + path: ${{ env.PACKOUTPUTPATH }} + + - name: NuGet push + run: dotnet nuget push "./${{ env.PACKOUTPUTPATH }}/*.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }} diff --git a/README.md b/README.md index cfec48a..7641551 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # HarmonyHub -[![Build status](https://ci.appveyor.com/api/projects/status/e346wmks920k8ik7/branch/release?svg=true)](https://ci.appveyor.com/project/i8beef/harmonyhub/branch/release) -[![Build status](https://ci.appveyor.com/api/projects/status/e346wmks920k8ik7/branch/master?svg=true)](https://ci.appveyor.com/project/i8beef/harmonyhub/branch/master) +![Build](https://github.com/i8beef/HarmonyHub/actions/workflows/build.yml/badge.svg?branch=master) +![Release](https://github.com/i8beef/HarmonyHub/actions/workflows/release.yml/badge.svg) HarmonyHub is an event based .NET library for interacting with a Logitech Harmony Hub. diff --git a/src/HarmonyHub/Client.cs b/src/HarmonyHub/Client.cs index d5c4e2d..aec0f7f 100644 --- a/src/HarmonyHub/Client.cs +++ b/src/HarmonyHub/Client.cs @@ -320,7 +320,7 @@ private async Task RequestResponseAsync(XmlElement message, int time var messageId = message.Attributes["id"].Value; - // Prepate the TaskCompletionSource, which is used to await the result + // Prepare the TaskCompletionSource, which is used to await the result var resultTaskCompletionSource = new TaskCompletionSource(); _resultTaskCompletionSources[messageId] = resultTaskCompletionSource; diff --git a/src/HarmonyHub/StreamParser.cs b/src/HarmonyHub/StreamParser.cs index 8a3ca16..66248b6 100644 --- a/src/HarmonyHub/StreamParser.cs +++ b/src/HarmonyHub/StreamParser.cs @@ -162,6 +162,9 @@ private void ReadRootElement() throw new XmlException("Unexpected node: " + _reader.Name); } } + + // If we got this far, the stream failed to establish + throw new Exception("Failed to read root node"); } #region IDisposable interface implementation