From 3e6375e9c2eab0de54037726c23edb48a7732969 Mon Sep 17 00:00:00 2001 From: Natchanon Nuntanirund Date: Wed, 1 Feb 2023 16:30:50 +0700 Subject: [PATCH] Fix exception name + add CI for pull requests (#24) --- .github/workflows/manual-publish-release.yml | 4 +-- .github/workflows/pull-request.yml | 34 +++++++++++++++++++ src/Agoda.Builds.Metrics/MeasureBuildTime.cs | 2 +- .../TimedStartupHostedService.cs | 2 +- .../TimedStartupMiddleware.cs | 2 +- 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/manual-publish-release.yml b/.github/workflows/manual-publish-release.yml index 1a21a81..18b09c7 100644 --- a/.github/workflows/manual-publish-release.yml +++ b/.github/workflows/manual-publish-release.yml @@ -2,9 +2,9 @@ name: .NET Core Build and Publish on: push: - + env: - NETCORE_VERSION: '3.1.x' + NETCORE_VERSION: '7.0' GIT_REPO_ROOT: src MAJOR_MINOR_VERSION: 1.0. SOLUTION_FILE: DotnetBuildMetrics.sln diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..47767d1 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,34 @@ +name: .NET Core Build + +on: + pull_request: + +env: + NETCORE_VERSION: '7.0' + GIT_REPO_ROOT: src + SOLUTION_FILE: DotnetBuildMetrics.sln + DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX: 2 + +jobs: + + build: + name: Build Package + runs-on: windows-latest # using windows agent for net472 build. + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET Core SDK ${{ env.NETCORE_VERSION }} + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.NETCORE_VERSION }} + + - name: Restore + working-directory: ${{ env.GIT_REPO_ROOT }} + run: dotnet restore ${{ env.SOLUTION_FILE }} + + - name: Add MSBuild to PATH + uses: microsoft/setup-msbuild@v1 + + - name: Build + working-directory: ${{ env.GIT_REPO_ROOT }} + run: dotnet build ${{ env.SOLUTION_FILE }} --configuration Debug --no-restore diff --git a/src/Agoda.Builds.Metrics/MeasureBuildTime.cs b/src/Agoda.Builds.Metrics/MeasureBuildTime.cs index e0bb6b0..695ddd2 100644 --- a/src/Agoda.Builds.Metrics/MeasureBuildTime.cs +++ b/src/Agoda.Builds.Metrics/MeasureBuildTime.cs @@ -52,7 +52,7 @@ public override bool Execute() DevFeedbackPublisher.Publish(ApiEndPoint, data); } - catch (GitContextNotFoundException ex) + catch (GitContextException ex) { Log.LogMessage($"The build time will not be published: {ex.Message}"); } diff --git a/src/Agoda.DevFeedback.AspNetStartup/TimedStartupHostedService.cs b/src/Agoda.DevFeedback.AspNetStartup/TimedStartupHostedService.cs index 7bb501a..6c49ba7 100644 --- a/src/Agoda.DevFeedback.AspNetStartup/TimedStartupHostedService.cs +++ b/src/Agoda.DevFeedback.AspNetStartup/TimedStartupHostedService.cs @@ -49,7 +49,7 @@ void OnStarted() { TimedStartupPublisher.Publish(type: ".AspNetStartup", timeTaken: diff); } - catch (GitContextNotFoundException ex) + catch (GitContextException ex) { _logger.LogInformation("The startup time will not be published: {reason}", ex.Message); } diff --git a/src/Agoda.DevFeedback.AspNetStartup/TimedStartupMiddleware.cs b/src/Agoda.DevFeedback.AspNetStartup/TimedStartupMiddleware.cs index bbdb49a..10a570e 100644 --- a/src/Agoda.DevFeedback.AspNetStartup/TimedStartupMiddleware.cs +++ b/src/Agoda.DevFeedback.AspNetStartup/TimedStartupMiddleware.cs @@ -45,7 +45,7 @@ public async Task Invoke(HttpContext httpContext) { TimedStartupPublisher.Publish(type: ".AspNetResponse", timeTaken: diff); } - catch (GitContextNotFoundException ex) + catch (GitContextException ex) { _logger.LogInformation("The startup time until first response will not be published: {reason}", ex.Message); }