Skip to content

Commit 03a8c8e

Browse files
Merge pull request #226 from TransactionProcessing/codacy/high_fixes
workflow changes
2 parents 20e64c3 + 9ccf990 commit 03a8c8e

2 files changed

Lines changed: 82 additions & 6 deletions

File tree

.github/workflows/codacy.yml

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Codacy Bootstrap Issues
1+
name: Sync Codacy Issues
22

33
on:
44
workflow_dispatch:
@@ -10,7 +10,7 @@ on:
1010
push:
1111
# branches to consider in the event; optional, defaults to all
1212
branches:
13-
- main
13+
- master
1414
jobs:
1515
sync-codacy-issues:
1616
runs-on: ubuntu-latest
@@ -99,3 +99,71 @@ jobs:
9999
await new Promise(resolve => setTimeout(resolve, 2000));
100100
}
101101
}
102+
103+
- name: Close Resolved GitHub Issues
104+
uses: actions/github-script@v7
105+
with:
106+
script: |
107+
const fs = require('fs');
108+
const dryRun = "${{ github.event.inputs.dry_run }}" === "true";
109+
const rawIssues = JSON.parse(fs.readFileSync('filtered_issues.json', 'utf8'));
110+
111+
// Build current Codacy set (only *active* issues, not ignored)
112+
const currentCodacyIds = new Set(
113+
rawIssues.filter(i => !i.ignored).map(i => i.issueId)
114+
);
115+
116+
// Build ignored Codacy set
117+
const ignoredCodacyIds = new Set(
118+
rawIssues.filter(i => i.ignored).map(i => i.issueId)
119+
);
120+
121+
// Fetch ALL GitHub issues with codacy label
122+
const allIssues = await github.paginate(
123+
github.rest.issues.listForRepo,
124+
{
125+
owner: context.repo.owner,
126+
repo: context.repo.repo,
127+
state: "all",
128+
labels: ["codacy"]
129+
}
130+
);
131+
132+
for (const ghIssue of allIssues) {
133+
const matches = ghIssue.body?.match(/codacy-issue-([a-f0-9]+)/g);
134+
if (!matches) continue;
135+
136+
for (const match of matches) {
137+
const issueId = match.replace("codacy-issue-", "");
138+
139+
// Close if not active OR explicitly ignored
140+
if ((!currentCodacyIds.has(issueId) || ignoredCodacyIds.has(issueId))
141+
&& ghIssue.state === "open") {
142+
if (dryRun) {
143+
console.log(`[DRY RUN] Would close issue #${ghIssue.number} (Codacy issueId ${issueId})`);
144+
} else {
145+
// Add comment before closing
146+
const reason = ignoredCodacyIds.has(issueId)
147+
? "Auto closed because Codacy issue is marked as *ignored*"
148+
: "Auto closed as not found in last analysis";
149+
150+
await github.rest.issues.createComment({
151+
owner: context.repo.owner,
152+
repo: context.repo.repo,
153+
issue_number: ghIssue.number,
154+
body: reason
155+
});
156+
157+
await github.rest.issues.update({
158+
owner: context.repo.owner,
159+
repo: context.repo.repo,
160+
issue_number: ghIssue.number,
161+
state: "closed"
162+
});
163+
console.log(`❌ Closed GitHub issue #${ghIssue.number} for Codacy issueId ${issueId}`);
164+
}
165+
}
166+
}
167+
}
168+
169+

.github/workflows/nightlybuild.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,19 @@ jobs:
3434
dotnet test "EstateManagementUI.BusinessLogic.Tests\EstateManagementUI.BusinessLogic.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov1.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov"
3535
dotnet test "EstateManagementUI.UITests\EstateManagementUI.UITests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov2.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov"
3636
37-
- name: Upload coverage reports to Codecov
38-
uses: codecov/codecov-action@v3
37+
- name: Install LCOV merger
38+
run: npm install -g lcov-result-merger
39+
40+
- name: Merge LCOV reports
41+
run: |
42+
mkdir -p coverage
43+
lcov-result-merger "*.info" > lcov.info
44+
45+
- name: Upload merged coverage to Codacy
46+
uses: codacy/codacy-coverage-reporter-action@v1
3947
with:
40-
token: ${{ secrets.CODECOV_TOKEN }}
41-
files: ./lcov1.info,./lcov2.info
48+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
49+
coverage-reports: ./lcov.info
4250

4351
chrometests:
4452
name: "Nightly Build - Chrome"

0 commit comments

Comments
 (0)