Skip to content

Commit c85756a

Browse files
MichaelSphannseman
andauthored
Bump versions (#37)
Co-authored-by: Hannes Ljungberg <[email protected]>
1 parent d70e13c commit c85756a

10 files changed

+18115
-37747
lines changed

dist/index.js

+13,085-32,608
Large diffs are not rendered by default.

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const core = require("@actions/core");
22
const github = require("@actions/github");
33
const { action } = require("./src/action");
44

5-
action(github.context.payload).catch(error => {
5+
action(github.context.payload).catch((error) => {
66
// Action threw an error. Fail the action with the error message.
77
core.setFailed(error.message);
88
});

package-lock.json

+4,949-5,059
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@
2929
],
3030
"license": "MIT",
3131
"dependencies": {
32-
"@actions/core": "^1.2.5",
33-
"@actions/github": "^2.2.0",
34-
"glob-promise": "^3.4.0",
32+
"@actions/core": "^1.2.6",
33+
"@actions/github": "^4.0.0",
34+
"glob-promise": "^4.0.1",
3535
"xml2js": "^0.4.23"
3636
},
3737
"devDependencies": {
3838
"@zeit/ncc": "^0.22.3",
39-
"eslint": "^6.8.0",
39+
"eslint": "^7.19.0",
4040
"eslint-config-prettier": "^6.11.0",
4141
"eslint-plugin-prettier": "^3.1.4",
42-
"jest": "^24.9.0",
43-
"nock": "^11.9.1",
44-
"prettier": "^1.19.1"
42+
"jest": "^26.6.3",
43+
"nock": "^13.0.7",
44+
"prettier": "^2.2.1"
4545
}
4646
}

src/action.js

+23-23
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const github = require("@actions/github");
33
const { escapeMarkdown } = require("./utils");
44
const { processCoverage } = require("./cobertura");
55

6-
const client = new github.GitHub(
6+
const client = new github.getOctokit(
77
core.getInput("repo_token", { required: true })
88
);
99
const credits = "Generated by :monkey: cobertura-action";
@@ -33,7 +33,7 @@ async function action(payload) {
3333
core.getInput("show_missing", { required: true })
3434
);
3535
let showMissingMaxLength = core.getInput("show_missing_max_length", {
36-
required: false
36+
required: false,
3737
});
3838
showMissingMaxLength = showMissingMaxLength
3939
? parseInt(showMissingMaxLength)
@@ -56,7 +56,7 @@ async function action(payload) {
5656
showMissing,
5757
showMissingMaxLength,
5858
filteredFiles: changedFiles,
59-
reportName
59+
reportName,
6060
});
6161
await addComment(pullRequestNumber, comment, reportName);
6262
}
@@ -70,16 +70,16 @@ function markdownReport(report, commit, options) {
7070
showMissing = false,
7171
showMissingMaxLength = -1,
7272
filteredFiles = null,
73-
reportName = "Coverage Report"
73+
reportName = "Coverage Report",
7474
} = options || {};
75-
const status = total =>
75+
const status = (total) =>
7676
total >= minimumCoverage ? ":white_check_mark:" : ":x:";
7777
const crop = (str, at) =>
7878
str.length > at ? str.slice(0, at).concat("...") : str;
7979
// Setup files
8080
const files = [];
8181
for (const file of report.files.filter(
82-
file => filteredFiles == null || filteredFiles.includes(file.filename)
82+
(file) => filteredFiles == null || filteredFiles.includes(file.filename)
8383
)) {
8484
const fileTotal = Math.round(file.total);
8585
const fileLines = Math.round(file.line);
@@ -94,7 +94,7 @@ function markdownReport(report, commit, options) {
9494
showLine ? `\`${fileLines}%\`` : undefined,
9595
showBranch ? `\`${fileBranch}%\`` : undefined,
9696
status(fileTotal),
97-
showMissing ? (fileMissing ? `\`${fileMissing}\`` : " ") : undefined
97+
showMissing ? (fileMissing ? `\`${fileMissing}\`` : " ") : undefined,
9898
]);
9999
}
100100
// Construct table
@@ -118,27 +118,27 @@ function markdownReport(report, commit, options) {
118118
showLine ? "Lines" : undefined,
119119
showBranch ? "Branches" : undefined,
120120
" ",
121-
showMissing ? "Missing" : undefined
121+
showMissing ? "Missing" : undefined,
122122
],
123123
[
124124
"-",
125125
":-:",
126126
showLine ? ":-:" : undefined,
127127
showBranch ? ":-:" : undefined,
128128
":-:",
129-
showMissing ? ":-:" : undefined
129+
showMissing ? ":-:" : undefined,
130130
],
131131
[
132132
"**All files**",
133133
`\`${total}%\``,
134134
showLine ? `\`${linesTotal}%\`` : undefined,
135135
showBranch ? `\`${branchTotal}%\`` : undefined,
136136
status(total),
137-
showMissing ? " " : undefined
137+
showMissing ? " " : undefined,
138138
],
139-
...files
139+
...files,
140140
]
141-
.map(row => {
141+
.map((row) => {
142142
return `| ${row.filter(Boolean).join(" | ")} |`;
143143
})
144144
.join("\n");
@@ -151,33 +151,33 @@ function markdownReport(report, commit, options) {
151151
async function addComment(pullRequestNumber, body, reportName) {
152152
const comments = await client.issues.listComments({
153153
issue_number: pullRequestNumber,
154-
...github.context.repo
154+
...github.context.repo,
155155
});
156156
const commentFilter = reportName ? reportName : credits;
157-
const comment = comments.data.find(comment =>
157+
const comment = comments.data.find((comment) =>
158158
comment.body.includes(commentFilter)
159159
);
160160
if (comment != null) {
161161
await client.issues.updateComment({
162162
comment_id: comment.id,
163163
body: body,
164-
...github.context.repo
164+
...github.context.repo,
165165
});
166166
} else {
167167
await client.issues.createComment({
168168
issue_number: pullRequestNumber,
169169
body: body,
170-
...github.context.repo
170+
...github.context.repo,
171171
});
172172
}
173173
}
174174

175175
async function listChangedFiles(pullRequestNumber) {
176176
const files = await client.pulls.listFiles({
177177
pull_number: pullRequestNumber,
178-
...github.context.repo
178+
...github.context.repo,
179179
});
180-
return files.data.map(file => file.filename);
180+
return files.data.map((file) => file.filename);
181181
}
182182

183183
/**
@@ -188,26 +188,26 @@ async function listChangedFiles(pullRequestNumber) {
188188
async function pullRequestInfo(payload = {}) {
189189
let commit = null;
190190
let pullRequestNumber = core.getInput("pull_request_number", {
191-
required: false
191+
required: false,
192192
});
193193

194194
if (pullRequestNumber) {
195195
// use the supplied PR
196196
pullRequestNumber = parseInt(pullRequestNumber);
197197
const { data } = await client.pulls.get({
198198
pull_number: pullRequestNumber,
199-
...github.context.repo
199+
...github.context.repo,
200200
});
201201
commit = data.head.sha;
202202
} else if (payload.workflow_run) {
203203
// fetch all open PRs and match the commit hash.
204204
commit = payload.workflow_run.head_commit.id;
205205
const { data } = await client.pulls.list({
206206
...github.context.repo,
207-
state: "open"
207+
state: "open",
208208
});
209209
pullRequestNumber = data
210-
.filter(d => d.head.sha == commit)
210+
.filter((d) => d.head.sha == commit)
211211
.reduce((n, d) => d.number, "");
212212
} else if (payload.pull_request) {
213213
// try to find the PR from payload
@@ -223,5 +223,5 @@ module.exports = {
223223
action,
224224
markdownReport,
225225
addComment,
226-
listChangedFiles
226+
listChangedFiles,
227227
};

src/action.test.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ const dummyReport = {
1313
total: 80,
1414
line: 80,
1515
branch: 0,
16-
missing: "24-26"
16+
missing: "24-26",
1717
},
1818
{
1919
name: "ClassBar",
2020
filename: "bar.py",
2121
total: 75,
2222
line: 80,
2323
branch: 0,
24-
missing: "23-24, 39-40"
24+
missing: "23-24, 39-40",
2525
},
2626
{
2727
name: "ClassMoo",
2828
filename: "foo.py",
2929
total: 75,
3030
line: 100,
3131
branch: 75,
32-
missing: ""
33-
}
34-
]
32+
missing: "",
33+
},
34+
],
3535
};
3636

3737
beforeEach(() => {
@@ -57,7 +57,7 @@ test("action", async () => {
5757
.get(`/repos/${owner}/${repo}/issues/${prNumber}/comments`)
5858
.reply(200, [{ body: "some body", id: 123 }]);
5959
await action({
60-
pull_request: { number: prNumber, head: { sha: "deadbeef" } }
60+
pull_request: { number: prNumber, head: { sha: "deadbeef" } },
6161
});
6262
await action();
6363
});
@@ -83,12 +83,12 @@ test("action triggered by workflow event", async () => {
8383
{
8484
number: 1,
8585
head: {
86-
sha: "deadbeef"
87-
}
88-
}
86+
sha: "deadbeef",
87+
},
88+
},
8989
]);
9090
await action({
91-
workflow_run: { head_commit: { id: "deadbeef" } }
91+
workflow_run: { head_commit: { id: "deadbeef" } },
9292
});
9393
});
9494

@@ -112,11 +112,11 @@ test("action passing pull request number directly", async () => {
112112
.get(`/repos/${owner}/${repo}/pulls/${prNumber}`)
113113
.reply(200, {
114114
head: {
115-
sha: "deadbeef"
116-
}
115+
sha: "deadbeef",
116+
},
117117
});
118118
await action({
119-
push: { ref: "master" }
119+
push: { ref: "master" },
120120
});
121121
});
122122

@@ -140,11 +140,11 @@ test("action only changes", async () => {
140140
.get(`/repos/${owner}/${repo}/pulls/${prNumber}/files`)
141141
.reply(200, [
142142
{
143-
filename: "file1.txt"
144-
}
143+
filename: "file1.txt",
144+
},
145145
]);
146146
await action({
147-
pull_request: { number: prNumber, head: { sha: "deadbeef" } }
147+
pull_request: { number: prNumber, head: { sha: "deadbeef" } },
148148
});
149149
await action();
150150
});
@@ -169,11 +169,11 @@ test("action with report name", async () => {
169169
.get(`/repos/${owner}/${repo}/pulls/${prNumber}/files`)
170170
.reply(200, [
171171
{
172-
filename: "file1.txt"
173-
}
172+
filename: "file1.txt",
173+
},
174174
]);
175175
await action({
176-
pull_request: { number: prNumber, head: { sha: "deadbeef" } }
176+
pull_request: { number: prNumber, head: { sha: "deadbeef" } },
177177
});
178178
await action();
179179
});
@@ -197,7 +197,7 @@ test("action with crop missing lines", async () => {
197197
.get(`/repos/${owner}/${repo}/issues/${prNumber}/comments`)
198198
.reply(200, [{ body: "some body", id: 123 }]);
199199
await action({
200-
pull_request: { number: prNumber, head: { sha: "deadbeef" } }
200+
pull_request: { number: prNumber, head: { sha: "deadbeef" } },
201201
});
202202
await action();
203203
});
@@ -210,7 +210,7 @@ test("markdownReport", () => {
210210
expect(
211211
markdownReport(dummyReport, commit, {
212212
minimumCoverage: 70,
213-
reportName: reportName
213+
reportName: reportName,
214214
})
215215
).toBe(`<strong>${reportName}</strong>
216216
@@ -257,7 +257,7 @@ _Minimum allowed coverage is \`70%\`_
257257
expect(
258258
markdownReport(dummyReport, commit, {
259259
minimumCoverage: 70,
260-
showBranch: true
260+
showBranch: true,
261261
})
262262
).toBe(`<strong>${defaultReportName}</strong>
263263
@@ -276,7 +276,7 @@ _Minimum allowed coverage is \`70%\`_
276276
markdownReport(dummyReport, commit, {
277277
minimumCoverage: 70,
278278
showLine: true,
279-
showBranch: true
279+
showBranch: true,
280280
})
281281
).toBe(`<strong>${defaultReportName}</strong>
282282
@@ -296,7 +296,7 @@ _Minimum allowed coverage is \`70%\`_
296296
minimumCoverage: 70,
297297
showLine: true,
298298
showBranch: true,
299-
showMissing: true
299+
showMissing: true,
300300
})
301301
).toBe(`<strong>${defaultReportName}</strong>
302302
@@ -317,7 +317,7 @@ _Minimum allowed coverage is \`70%\`_
317317
showLine: true,
318318
showBranch: true,
319319
showMissing: true,
320-
showMissingMaxLength: 5
320+
showMissingMaxLength: 5,
321321
})
322322
).toBe(`<strong>${defaultReportName}</strong>
323323
@@ -479,7 +479,7 @@ _Minimum allowed coverage is \`100%\`_
479479
.get(`/repos/${owner}/${repo}/issues/${prNumber}/comments`)
480480
.reply(200, [
481481
{ body: report1Comment, id: comment1Id },
482-
{ body: report2Comment, id: comment2Id }
482+
{ body: report2Comment, id: comment2Id },
483483
])
484484
.patch(`/repos/${owner}/${repo}/issues/comments/${comment2Id}`)
485485
.reply(200, [{ body: report2Comment, id: comment2Id }]);
@@ -493,8 +493,8 @@ test("listChangedFiles", async () => {
493493
.get(`/repos/${owner}/${repo}/pulls/${prNumber}/files`)
494494
.reply(200, [
495495
{
496-
filename: "file1.txt"
497-
}
496+
filename: "file1.txt",
497+
},
498498
]);
499499
await listChangedFiles(prNumber);
500500
});

0 commit comments

Comments
 (0)