Skip to content

Commit 2332946

Browse files
committed
tmp
1 parent 107a3c9 commit 2332946

File tree

5 files changed

+8425
-67
lines changed

5 files changed

+8425
-67
lines changed

__tests__/DiffChecker.test.ts

+65-39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DiffChecker } from '../src/DiffChecker'
1+
import {DiffChecker} from '../src/DiffChecker'
22

33
describe('DiffChecker', () => {
44
const mock100Coverage = {
@@ -77,9 +77,9 @@ describe('DiffChecker', () => {
7777
' :x: | ~~file4~~ | ~~100~~ | ~~100~~ | ~~100~~ | ~~100~~'
7878
])
7979
})
80-
describe("testing checkIfTestCoverageFallsBelowDelta", () => {
81-
describe("respects total_delta for total and delta for other files", () => {
82-
it("returns true because delta diff is too high, even if total_delta is okay", () => {
80+
describe('testing checkIfTestCoverageFallsBelowDelta', () => {
81+
describe('respects total_delta for total and delta for other files', () => {
82+
it('returns true because delta diff is too high, even if total_delta is okay', () => {
8383
const codeCoverageOld = {
8484
total: mock100CoverageFile,
8585
file1: mock100CoverageFile
@@ -89,10 +89,13 @@ describe('DiffChecker', () => {
8989
file1: mock98CoverageFile
9090
}
9191
const diffChecker = new DiffChecker(codeCoverageNew, codeCoverageOld)
92-
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(1, 50)
93-
expect(isTestCoverageFallsBelowDelta).toBeTruthy();
92+
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(
93+
1,
94+
50
95+
)
96+
expect(isTestCoverageFallsBelowDelta).toBeTruthy()
9497
})
95-
it("returns true because total_delta diff is too high, even if delta is okay", () => {
98+
it('returns true because total_delta diff is too high, even if delta is okay', () => {
9699
const codeCoverageOld = {
97100
total: mock100CoverageFile,
98101
file1: mock100CoverageFile
@@ -102,10 +105,13 @@ describe('DiffChecker', () => {
102105
file1: mock98CoverageFile
103106
}
104107
const diffChecker = new DiffChecker(codeCoverageNew, codeCoverageOld)
105-
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(50, 1)
106-
expect(isTestCoverageFallsBelowDelta).toBeTruthy();
108+
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(
109+
50,
110+
1
111+
)
112+
expect(isTestCoverageFallsBelowDelta).toBeTruthy()
107113
})
108-
it("returns true if delta diff is too high - total_delta is not defined", () => {
114+
it('returns true if delta diff is too high - total_delta is not defined', () => {
109115
const codeCoverageOld = {
110116
total: mock100CoverageFile,
111117
file1: mock100CoverageFile
@@ -115,10 +121,13 @@ describe('DiffChecker', () => {
115121
file1: mock98CoverageFile
116122
}
117123
const diffChecker = new DiffChecker(codeCoverageNew, codeCoverageOld)
118-
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(1, null)
119-
expect(isTestCoverageFallsBelowDelta).toBeTruthy();
124+
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(
125+
1,
126+
null
127+
)
128+
expect(isTestCoverageFallsBelowDelta).toBeTruthy()
120129
})
121-
it("returns false if total_delta and delta are okay", () => {
130+
it('returns false if total_delta and delta are okay', () => {
122131
const codeCoverageOld = {
123132
total: mock100CoverageFile,
124133
file1: mock100CoverageFile
@@ -128,10 +137,13 @@ describe('DiffChecker', () => {
128137
file1: mock98CoverageFile
129138
}
130139
const diffChecker = new DiffChecker(codeCoverageNew, codeCoverageOld)
131-
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(50, 50)
132-
expect(isTestCoverageFallsBelowDelta).toBeFalsy();
140+
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(
141+
50,
142+
50
143+
)
144+
expect(isTestCoverageFallsBelowDelta).toBeFalsy()
133145
})
134-
it("returns false if delta is okay - total_delta is not defined", () => {
146+
it('returns false if delta is okay - total_delta is not defined', () => {
135147
const codeCoverageOld = {
136148
total: mock100CoverageFile,
137149
file1: mock100CoverageFile
@@ -141,54 +153,68 @@ describe('DiffChecker', () => {
141153
file1: mock98CoverageFile
142154
}
143155
const diffChecker = new DiffChecker(codeCoverageNew, codeCoverageOld)
144-
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(50, null)
145-
expect(isTestCoverageFallsBelowDelta).toBeFalsy();
156+
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(
157+
50,
158+
null
159+
)
160+
expect(isTestCoverageFallsBelowDelta).toBeFalsy()
146161
})
147162
})
148-
it("detects that total coverage dropped below total_delta", () => {
163+
it('detects that total coverage dropped below total_delta', () => {
149164
const codeCoverageOld = {
150-
total: mock100CoverageFile,
165+
total: mock100CoverageFile
151166
}
152167
const codeCoverageNew = {
153-
total: mock98CoverageFile,
168+
total: mock98CoverageFile
154169
}
155170
const diffChecker = new DiffChecker(codeCoverageNew, codeCoverageOld)
156-
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(2, 1)
157-
expect(isTestCoverageFallsBelowDelta).toBeTruthy();
171+
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(
172+
2,
173+
1
174+
)
175+
expect(isTestCoverageFallsBelowDelta).toBeTruthy()
158176
})
159-
it("detects that total coverage did not drop below total_delta", () => {
177+
it('detects that total coverage did not drop below total_delta', () => {
160178
const codeCoverageOld = {
161-
total: mock100CoverageFile,
179+
total: mock100CoverageFile
162180
}
163181
const codeCoverageNew = {
164-
total: mock98CoverageFile,
182+
total: mock98CoverageFile
165183
}
166184
const diffChecker = new DiffChecker(codeCoverageNew, codeCoverageOld)
167-
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(1, 5)
168-
expect(isTestCoverageFallsBelowDelta).toBeFalsy();
185+
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(
186+
1,
187+
5
188+
)
189+
expect(isTestCoverageFallsBelowDelta).toBeFalsy()
169190
})
170-
it("detects that total coverage dropped below delta", () => {
191+
it('detects that total coverage dropped below delta', () => {
171192
const codeCoverageOld = {
172-
total: mock100CoverageFile,
193+
total: mock100CoverageFile
173194
}
174195
const codeCoverageNew = {
175-
total: mock98CoverageFile,
196+
total: mock98CoverageFile
176197
}
177198
const diffChecker = new DiffChecker(codeCoverageNew, codeCoverageOld)
178-
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(1, null)
179-
expect(isTestCoverageFallsBelowDelta).toBeTruthy();
199+
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(
200+
1,
201+
null
202+
)
203+
expect(isTestCoverageFallsBelowDelta).toBeTruthy()
180204
})
181-
it("detects that total coverage did not drop below delta", () => {
205+
it('detects that total coverage did not drop below delta', () => {
182206
const codeCoverageOld = {
183-
total: mock100CoverageFile,
207+
total: mock100CoverageFile
184208
}
185209
const codeCoverageNew = {
186-
total: mock98CoverageFile,
210+
total: mock98CoverageFile
187211
}
188212
const diffChecker = new DiffChecker(codeCoverageNew, codeCoverageOld)
189-
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(2, null)
190-
expect(isTestCoverageFallsBelowDelta).toBeFalsy();
213+
const isTestCoverageFallsBelowDelta = diffChecker.checkIfTestCoverageFallsBelowDelta(
214+
2,
215+
null
216+
)
217+
expect(isTestCoverageFallsBelowDelta).toBeFalsy()
191218
})
192-
193219
})
194220
})

dist/index.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,6 @@ function run() {
20312031
const githubToken = core.getInput('accessToken');
20322032
const fullCoverage = JSON.parse(core.getInput('fullCoverageDiff'));
20332033
const commandToRun = core.getInput('runCommand');
2034-
const commandAfterSwitch = core.getInput('afterSwitchCommand');
20352034
const delta = Number(core.getInput('delta'));
20362035
const rawTotalDelta = core.getInput('total_delta');
20372036
const githubClient = github.getOctokit(githubToken);
@@ -2042,20 +2041,20 @@ function run() {
20422041
const commentIdentifier = `<!-- codeCoverageDiffComment -->`;
20432042
const deltaCommentIdentifier = `<!-- codeCoverageDeltaComment -->`;
20442043
let totalDelta = null;
2044+
console.log('>>>>>>1');
20452045
if (rawTotalDelta !== null) {
20462046
totalDelta = Number(rawTotalDelta);
20472047
}
2048+
console.log('>>>>>>2');
20482049
let commentId = null;
2049-
child_process_1.execSync(commandToRun);
2050+
child_process_1.execSync(`${commandToRun}`);
2051+
console.log('>>>>>>3');
20502052
const codeCoverageNew = (JSON.parse(fs_1.default.readFileSync('coverage-summary.json').toString()));
2051-
child_process_1.execSync('/usr/bin/git fetch');
2052-
child_process_1.execSync('/usr/bin/git stash');
2053-
child_process_1.execSync(`/usr/bin/git checkout --progress --force ${branchNameBase}`);
2054-
if (commandAfterSwitch) {
2055-
child_process_1.execSync(commandAfterSwitch);
2056-
}
2057-
child_process_1.execSync(commandToRun);
2058-
const codeCoverageOld = (JSON.parse(fs_1.default.readFileSync('coverage-summary.json').toString()));
2053+
// execSync('/usr/bin/git fetch')
2054+
// execSync('/usr/bin/git stash')
2055+
// execSync(`/usr/bin/git checkout --progress --force ${branchNameBase}`)
2056+
const codeCoverageOld = (JSON.parse(fs_1.default.readFileSync('develop-coverage-summary.json').toString()));
2057+
console.log(codeCoverageOld);
20592058
const currentDirectory = child_process_1.execSync('pwd')
20602059
.toString()
20612060
.trim();
@@ -6754,7 +6753,8 @@ class DiffChecker {
67546753
this.diffCoverageReport = {};
67556754
const reportNewKeys = Object.keys(coverageReportNew);
67566755
const reportOldKeys = Object.keys(coverageReportOld);
6757-
const reportKeys = new Set([...reportNewKeys, ...reportOldKeys]);
6756+
// const reportKeys = new Set([...reportNewKeys, ...reportOldKeys])
6757+
const reportKeys = new Set([...reportNewKeys]);
67586758
for (const filePath of reportKeys) {
67596759
this.diffCoverageReport[filePath] = {
67606760
branches: {

0 commit comments

Comments
 (0)