Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Codacy Bootstrap Issues
name: Sync Codacy Issues

on:
workflow_dispatch:
Expand Down Expand Up @@ -99,3 +99,71 @@ jobs:
await new Promise(resolve => setTimeout(resolve, 2000));
}
}

- name: Close Resolved GitHub Issues
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const dryRun = "${{ github.event.inputs.dry_run }}" === "true";
const rawIssues = JSON.parse(fs.readFileSync('filtered_issues.json', 'utf8'));

// Build current Codacy set (only *active* issues, not ignored)
const currentCodacyIds = new Set(
rawIssues.filter(i => !i.ignored).map(i => i.issueId)
);

// Build ignored Codacy set
const ignoredCodacyIds = new Set(
rawIssues.filter(i => i.ignored).map(i => i.issueId)
);

// Fetch ALL GitHub issues with codacy label
const allIssues = await github.paginate(
github.rest.issues.listForRepo,
{
owner: context.repo.owner,
repo: context.repo.repo,
state: "all",
labels: ["codacy"]
}
);

for (const ghIssue of allIssues) {
const matches = ghIssue.body?.match(/codacy-issue-([a-f0-9]+)/g);
if (!matches) continue;

for (const match of matches) {
const issueId = match.replace("codacy-issue-", "");

// Close if not active OR explicitly ignored
if ((!currentCodacyIds.has(issueId) || ignoredCodacyIds.has(issueId))
&& ghIssue.state === "open") {
if (dryRun) {
console.log(`[DRY RUN] Would close issue #${ghIssue.number} (Codacy issueId ${issueId})`);
} else {
// Add comment before closing
const reason = ignoredCodacyIds.has(issueId)
? "Auto closed because Codacy issue is marked as *ignored*"
: "Auto closed as not found in last analysis";

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ghIssue.number,
body: reason
});

await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ghIssue.number,
state: "closed"
});
console.log(`❌ Closed GitHub issue #${ghIssue.number} for Codacy issueId ${issueId}`);
}
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@

public async Task<Result> UpdateMessageStatus(EmailCommands.UpdateMessageStatusCommand command,
CancellationToken cancellationToken) {
Result result = await ApplyEmailUpdates(async (EmailAggregate emailAggregate) => {

Check warning on line 242 in MessagingService.BusinessLogic/Services/MessagingDomainService.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
switch (command.Status) {
case EmailServices.MessageStatus.Bounced:
emailAggregate.MarkMessageAsBounced(command.Description, command.Timestamp);
Expand All @@ -257,6 +257,10 @@
case EmailServices.MessageStatus.Spam:
emailAggregate.MarkMessageAsSpam(command.Description, command.Timestamp);
break;
default:
// Unknown status - treat as failed
emailAggregate.MarkMessageAsFailed(command.Description, command.Timestamp);
break;
}

return Result.Success();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Security.Authentication;
using System.Text;

namespace MessagingService.BusinessLogic.Services.SMSServices.TheSMSWorks
Expand Down Expand Up @@ -115,7 +116,7 @@ public async Task<MessageStatusResponse> GetMessageStatus(String providerReferen
}
}
else {
throw new Exception("Authentication Error");
throw new AuthenticationException("Authentication Error");
}

return response;
Expand Down
6 changes: 4 additions & 2 deletions MessagingService/Controllers/DomainEventController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace MessagingService.Controllers
using Shared.Exceptions;

namespace MessagingService.Controllers
{
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -107,7 +109,7 @@ private async Task<IDomainEvent> GetDomainEvent(Object domainEvent) {
Type type = TypeMap.GetType(eventType);

if (type == null)
throw new Exception($"Failed to find a domain event with type {eventType}");
throw new NotFoundException($"Failed to find a domain event with type {eventType}");

JsonIgnoreAttributeIgnorerContractResolver jsonIgnoreAttributeIgnorerContractResolver = new();
JsonSerializerSettings jsonSerialiserSettings = new() {
Expand Down
Loading