From 84df9034a38cc6634eafdc9048d7993b20893db2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 26 Jun 2023 16:41:16 -0400 Subject: [PATCH 1/6] Prevent autoapprove firing if there are open tasks --- .github/workflows/auto-approve-dominions-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-approve-dominions-prs.yml b/.github/workflows/auto-approve-dominions-prs.yml index c404c41b32..d119f525d3 100644 --- a/.github/workflows/auto-approve-dominions-prs.yml +++ b/.github/workflows/auto-approve-dominions-prs.yml @@ -16,7 +16,7 @@ concurrency: jobs: approve-pr-if-dominion-is-author: name: Approve PR if Dominion is Author - if: github.event.pull_request.user.login == 'Cyberboss' && !github.event.pull_request.draft && (github.event.pull_request.base.repo.owner.login == 'tgstation' || github.event.pull_request.base.repo.owner.login == 'Cyberboss') + if: github.event.pull_request.user.login == 'Cyberboss' && !(github.event.pull_request.draft || github.event.pull_request.body.contains('- [ ]')) && (github.event.pull_request.base.repo.owner.login == 'tgstation' || github.event.pull_request.base.repo.owner.login == 'Cyberboss') runs-on: ubuntu-latest steps: - name: GitHub API Call From b24f1674d5d5c5048eb3ded2c823de032906a51a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 26 Jun 2023 20:13:11 -0400 Subject: [PATCH 2/6] Fix auto-approve workflow --- .github/workflows/auto-approve-dominions-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-approve-dominions-prs.yml b/.github/workflows/auto-approve-dominions-prs.yml index d119f525d3..a6e8315f32 100644 --- a/.github/workflows/auto-approve-dominions-prs.yml +++ b/.github/workflows/auto-approve-dominions-prs.yml @@ -16,7 +16,7 @@ concurrency: jobs: approve-pr-if-dominion-is-author: name: Approve PR if Dominion is Author - if: github.event.pull_request.user.login == 'Cyberboss' && !(github.event.pull_request.draft || github.event.pull_request.body.contains('- [ ]')) && (github.event.pull_request.base.repo.owner.login == 'tgstation' || github.event.pull_request.base.repo.owner.login == 'Cyberboss') + if: github.event.pull_request.user.login == 'Cyberboss' && !github.event.pull_request.draft && !github.event.pull_request.body.contains('- [ ]') && (github.event.pull_request.base.repo.owner.login == 'tgstation' || github.event.pull_request.base.repo.owner.login == 'Cyberboss') runs-on: ubuntu-latest steps: - name: GitHub API Call From 9c82fb2881ea34eb820400518e83b0cd21b5a746 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 27 Jun 2023 18:47:45 -0400 Subject: [PATCH 3/6] Fix auto approve workflow for real this time --- .github/workflows/auto-approve-dominions-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-approve-dominions-prs.yml b/.github/workflows/auto-approve-dominions-prs.yml index a6e8315f32..287e09f376 100644 --- a/.github/workflows/auto-approve-dominions-prs.yml +++ b/.github/workflows/auto-approve-dominions-prs.yml @@ -16,7 +16,7 @@ concurrency: jobs: approve-pr-if-dominion-is-author: name: Approve PR if Dominion is Author - if: github.event.pull_request.user.login == 'Cyberboss' && !github.event.pull_request.draft && !github.event.pull_request.body.contains('- [ ]') && (github.event.pull_request.base.repo.owner.login == 'tgstation' || github.event.pull_request.base.repo.owner.login == 'Cyberboss') + if: github.event.pull_request.user.login == 'Cyberboss' && !github.event.pull_request.draft && !contains(github.event.pull_request.body, '- [ ]') && (github.event.pull_request.base.repo.owner.login == 'tgstation' || github.event.pull_request.base.repo.owner.login == 'Cyberboss') runs-on: ubuntu-latest steps: - name: GitHub API Call From 678f9e2270a64e5bdb4867510691150f1242862a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 29 Jun 2023 14:47:55 -0400 Subject: [PATCH 4/6] Better error handling in RemoteDeploymentManagers --- .../Remote/GitHubRemoteDeploymentManager.cs | 31 ++++++++++++------- .../Remote/GitLabRemoteDeploymentManager.cs | 23 +++++++++----- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs index d0cf3471ad..769ddaec69 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs @@ -129,9 +129,9 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote Logger.LogTrace("In-progress deployment status created"); } - catch (ApiException ex) + catch (Exception ex) when (ex is not OperationCanceledException) { - Logger.LogWarning(ex, "Unable to create deployment!"); + Logger.LogWarning(ex, "Unable to create GitHub deployment!"); } } @@ -257,9 +257,9 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote { await gitHubService.CommentOnIssue(remoteRepositoryOwner, remoteRepositoryName, comment, testMergeNumber, cancellationToken); } - catch (ApiException e) + catch (Exception ex) when (ex is not OperationCanceledException) { - Logger.LogWarning(e, "Error posting GitHub comment!"); + Logger.LogWarning(ex, "Error posting GitHub comment!"); } } @@ -342,14 +342,21 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote var gitHubService = gitHubServiceFactory.CreateService(gitHubAccessToken); - await gitHubService.CreateDeploymentStatus( - new NewDeploymentStatus(deploymentState) - { - Description = description, - }, - compileJob.GitHubRepoId.Value, - compileJob.GitHubDeploymentId.Value, - cancellationToken); + try + { + await gitHubService.CreateDeploymentStatus( + new NewDeploymentStatus(deploymentState) + { + Description = description, + }, + compileJob.GitHubRepoId.Value, + compileJob.GitHubDeploymentId.Value, + cancellationToken); + } + catch (Exception ex) when (ex is not OperationCanceledException) + { + Logger.LogWarning(ex, "Error updating GitHub deployment!"); + } } } } diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs index 62c6e31ccd..ef57b93ea7 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs @@ -123,7 +123,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote CancellationToken cancellationToken) => Task.CompletedTask; /// - protected override Task CommentOnTestMergeSource( + protected override async Task CommentOnTestMergeSource( RepositorySettings repositorySettings, string remoteRepositoryOwner, string remoteRepositoryName, @@ -135,13 +135,20 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote ? new GitLabClient(GitLabRemoteFeatures.GitLabUrl, repositorySettings.AccessToken) : new GitLabClient(GitLabRemoteFeatures.GitLabUrl); - return client - .MergeRequests - .CreateNoteAsync( - $"{remoteRepositoryOwner}/{remoteRepositoryName}", - testMergeNumber, - new CreateMergeRequestNoteRequest(comment)) - .WithToken(cancellationToken); + try + { + await client + .MergeRequests + .CreateNoteAsync( + $"{remoteRepositoryOwner}/{remoteRepositoryName}", + testMergeNumber, + new CreateMergeRequestNoteRequest(comment)) + .WithToken(cancellationToken); + } + catch (Exception ex) when (ex is not OperationCanceledException) + { + Logger.LogWarning(ex, "Error posting GitHub comment!"); + } } /// From 2bef7f76b7c2d8a3595e500b676f354c7daaffbc Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 29 Jun 2023 15:30:32 -0400 Subject: [PATCH 5/6] Version bump to 5.12.7 --- build/Version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Version.props b/build/Version.props index f3666b8777..c674fd9d73 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,7 +3,7 @@ - 5.12.6 + 5.12.7 4.6.0 9.10.2 10.4.1 From f2f9872376cf606e05e61921749816c434c6726c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 29 Jun 2023 15:36:59 -0400 Subject: [PATCH 6/6] Clean up Exception handling when setting repo ID --- .../Deployment/Remote/GitHubRemoteDeploymentManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs index 769ddaec69..f4f8fb7f4c 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs @@ -140,7 +140,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote compileJob.GitHubRepoId = await repositoryIdTask; Logger.LogTrace("Set GitHub ID as {gitHubRepoId}", compileJob.GitHubRepoId); } - catch (RateLimitExceededException ex) when (!repositorySettings.CreateGitHubDeployments.Value) + catch (Exception ex) when (ex is not OperationCanceledException) { Logger.LogWarning(ex, "Unable to set compile job repository ID!"); }