Skip to content

Commit cfb6d45

Browse files
committed
Add some debug log & pack
1 parent 37db05d commit cfb6d45

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

dist/index.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ var Inputs;
113113
Inputs["Title"] = "title";
114114
Inputs["Path"] = "path";
115115
Inputs["Token"] = "token";
116-
Inputs["Token"] = "token";
116+
Inputs["ChangedSince"] = "changed-since";
117117
})(Inputs = exports.Inputs || (exports.Inputs = {}));
118118

119119

@@ -185,15 +185,20 @@ function run() {
185185
const name = core.getInput(constants_1.Inputs.Name);
186186
const title = core.getInput(constants_1.Inputs.Title);
187187
const commit = core.getInput(constants_1.Inputs.Commit);
188+
const changedSince = core.getInput(constants_1.Inputs.ChangedSince);
189+
const filter = yield getFilter(commit, changedSince);
190+
core.debug(`Got the filter of ${filter} files, e.g. ${filter.slice(0, 3)}`);
188191
const searchResult = yield search_1.findResults(path);
189192
if (searchResult.filesToUpload.length === 0) {
190193
core.warning(`No files were found for the provided path: ${path}. No results will be uploaded.`);
191194
}
192195
else {
193196
core.info(`With the provided path, there will be ${searchResult.filesToUpload.length} results uploaded`);
194197
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`);
195-
const annotations = ramda_1.chain(annotations_1.annotationsForPath, searchResult.filesToUpload);
196-
core.debug(`Grouping ${annotations.length} annotations into chunks of ${MAX_ANNOTATIONS_PER_REQUEST}`);
198+
const allAnnotations = ramda_1.chain(annotations_1.annotationsForPath, searchResult.filesToUpload);
199+
const annotations = filter.length == 0 ? allAnnotations :
200+
allAnnotations.filter(annotation => filter.includes(annotation.path));
201+
core.debug(`Grouping ${annotations.length} filtered out of ${allAnnotations.length} annotations into chunks of ${MAX_ANNOTATIONS_PER_REQUEST}`);
197202
const groupedAnnotations = annotations.length > MAX_ANNOTATIONS_PER_REQUEST
198203
? ramda_1.splitEvery(MAX_ANNOTATIONS_PER_REQUEST, annotations)
199204
: [annotations];
@@ -226,6 +231,20 @@ function getConclusion(annotations) {
226231
}
227232
return 'success';
228233
}
234+
function getFilter(commit, changedSince) {
235+
return __awaiter(this, void 0, void 0, function* () {
236+
if (changedSince == "") {
237+
return [];
238+
}
239+
const octokit = github_2.getOctokit(core.getInput(constants_1.Inputs.Token));
240+
const head_sha = commit ||
241+
(github_2.context.payload.pull_request && github_2.context.payload.pull_request.head.sha) ||
242+
github_2.context.sha;
243+
const req = Object.assign(Object.assign({}, github_2.context.repo), { head: head_sha, base: changedSince });
244+
const compare = yield octokit.repos.compareCommits(req);
245+
return compare.data.files.map(file => file.filename);
246+
});
247+
}
229248
function createCheck(name, commit, title, annotations, processedErrors, numErrors, conclusion) {
230249
return __awaiter(this, void 0, void 0, function* () {
231250
const head_sha = commit ||

src/main.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ async function run(): Promise<void> {
1717
const changedSince = core.getInput(Inputs.ChangedSince)
1818

1919
const filter = await getFilter(commit, changedSince)
20+
core.debug(`Got the filter of ${filter} files, e.g. ${filter.slice(0, 3)}`)
2021
const searchResult = await findResults(path)
2122
if (searchResult.filesToUpload.length === 0) {
2223
core.warning(
@@ -28,13 +29,15 @@ async function run(): Promise<void> {
2829
)
2930
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
3031

31-
const annotations: Annotation[] = chain(
32+
const allAnnotations: Annotation[] = chain(
3233
annotationsForPath,
3334
searchResult.filesToUpload
34-
).filter(annotation => filter.length == 0 || filter.includes(annotation.path))
35+
)
36+
const annotations = filter.length == 0 ? allAnnotations :
37+
allAnnotations.filter(annotation => filter.includes(annotation.path))
3538

3639
core.debug(
37-
`Grouping ${annotations.length} annotations into chunks of ${MAX_ANNOTATIONS_PER_REQUEST}`
40+
`Grouping ${annotations.length} filtered out of ${allAnnotations.length} annotations into chunks of ${MAX_ANNOTATIONS_PER_REQUEST}`
3841
)
3942

4043
const groupedAnnotations: Annotation[][] =

0 commit comments

Comments
 (0)