From 55b550ceb48a24395d5e5f203e8d4a8fa7f6637c Mon Sep 17 00:00:00 2001 From: Marcin Torba Date: Thu, 29 Aug 2024 10:02:03 +0200 Subject: [PATCH] [CI/CD] Update pipelines (#22) * Update cd.yml * Update ci.yml * Fix exceptions --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 8 ++++++-- .../AzureDevOps.cs | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index c83896c..5e66d7f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -24,7 +24,7 @@ jobs: run: dotnet restore - name: Build - run: dotnet build --no-restore + run: dotnet build --no-restore -c Release - name: Pack run: dotnet pack -p:PackageVersion=$PACKAGE_VERSION -c Release diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 922a174..e8a1220 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,13 +13,17 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x + - name: Restore dependencies run: dotnet restore + - name: Build - run: dotnet build --no-restore + run: dotnet build --no-restore -c Release + - name: Test - run: dotnet test --no-build --verbosity normal + run: dotnet test --no-build -c Release --verbosity normal diff --git a/src/DependencyUpdated.Repositories.AzureDevOps/AzureDevOps.cs b/src/DependencyUpdated.Repositories.AzureDevOps/AzureDevOps.cs index a78d66e..5a7820a 100644 --- a/src/DependencyUpdated.Repositories.AzureDevOps/AzureDevOps.cs +++ b/src/DependencyUpdated.Repositories.AzureDevOps/AzureDevOps.cs @@ -22,7 +22,7 @@ public void SwitchToDefaultBranch(string repositoryPath) logger.Information("Switching {Repository} to branch {Branch}", repositoryPath, branchName); using var repo = new Repository(repositoryPath); var branch = repo.Branches[branchName] ?? - throw new Exception($"Branch {branchName} doesn't exists"); + throw new InvalidOperationException($"Branch {branchName} doesn't exists"); Commands.Checkout(repo, branch); } @@ -102,7 +102,7 @@ public async Task SubmitPullRequest(IReadOnlyCollection updates, s if (result.StatusCode == HttpStatusCode.NonAuthoritativeInformation) { - throw new Exception("Invalid PAT token provided"); + throw new InvalidOperationException("Invalid PAT token provided"); } var response = await result.Content.ReadAsStringAsync(); @@ -111,7 +111,7 @@ public async Task SubmitPullRequest(IReadOnlyCollection updates, s PropertyNameCaseInsensitive = true, }; var responseObject = JsonSerializer.Deserialize(response, options) ?? - throw new Exception("Missing response from API"); + throw new InvalidOperationException("Missing response from API"); logger.Information("New PR created {Id}", responseObject.PullRequestId); if (configValue.AutoComplete)