Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Add check-name options #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ inputs:
default: "."
diff-against-branch:
description: "Only check files that have been modified from the given branch"
check-name:
description: >-
The name of the check to add annotations to.
Useful to distinguish between Python versions in a build matrix.
default: Mypy
outputs:
num-errors:
description: 'Number of errors reported'
Expand Down
19 changes: 14 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ function typeToAnnotationLevel(type) {
}
}

async function submitResult(githubToken, octokit, conclusion, annotations) {
async function submitResult(octokit, checkName, conclusion, annotations) {
const output = {
title: "Mypy",
summary: `There are ${annotations.length} mypy warnings`
Expand All @@ -819,7 +819,7 @@ async function submitResult(githubToken, octokit, conclusion, annotations) {
// Create the check run and the first 50 annotations
const result = await octokit.checks.create({
...github.context.repo,
name: "Mypy",
name: checkName,
head_sha: github.context.sha,
completed_at: new Date().toISOString(),
conclusion: conclusion,
Expand Down Expand Up @@ -873,6 +873,8 @@ async function run() {
10
);

const checkName = core.getInput("check-name", { required: true });

// Initialize the octokit library
const githubToken = core.getInput("github-token", { required: true });
const octokit = new github.GitHub(githubToken);
Expand Down Expand Up @@ -938,7 +940,7 @@ async function run() {

const conclusion = numErrors > maxErrors ? "failure" : "success";

await submitResult(githubToken, octokit, conclusion, annotations);
await submitResult(octokit, checkName,conclusion, annotations);
} catch (error) {
console.log(error);
core.setFailed(error.message);
Expand Down Expand Up @@ -6152,6 +6154,12 @@ function convertBody(buffer, headers) {
// html4
if (!res && str) {
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
if (!res) {
res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str);
if (res) {
res.pop(); // drop last quote
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR really, but my browser shows me tabs-vs-spaces in github diffs, and this file has a [un]healthy mix of both. Could be nice to add an .editorconfig or something that keeps things consistent, perhaps?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change comes from the ce733af commit and was generated by running yarnpkg run package. You don't think I should be fixing whitespace in the generated dist/index.js file do you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I certainly don't 😉


if (res) {
res = /charset=(.*)/i.exec(res.pop());
Expand Down Expand Up @@ -7159,7 +7167,7 @@ function fetch(url, opts) {
// HTTP fetch step 5.5
switch (request.redirect) {
case 'error':
reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));
finalize();
return;
case 'manual':
Expand Down Expand Up @@ -7198,7 +7206,8 @@ function fetch(url, opts) {
method: request.method,
body: request.body,
signal: request.signal,
timeout: request.timeout
timeout: request.timeout,
size: request.size
};

// HTTP-redirect fetch step 9
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function typeToAnnotationLevel(type) {
}
}

async function submitResult(githubToken, octokit, conclusion, annotations) {
async function submitResult(octokit, checkName, conclusion, annotations) {
const output = {
title: "Mypy",
summary: `There are ${annotations.length} mypy warnings`
Expand All @@ -24,7 +24,7 @@ async function submitResult(githubToken, octokit, conclusion, annotations) {
// Create the check run and the first 50 annotations
const result = await octokit.checks.create({
...github.context.repo,
name: "Mypy",
name: checkName,
head_sha: github.context.sha,
completed_at: new Date().toISOString(),
conclusion: conclusion,
Expand Down Expand Up @@ -78,6 +78,8 @@ async function run() {
10
);

const checkName = core.getInput("check-name", { required: true });

// Initialize the octokit library
const githubToken = core.getInput("github-token", { required: true });
const octokit = new github.GitHub(githubToken);
Expand Down Expand Up @@ -143,7 +145,7 @@ async function run() {

const conclusion = numErrors > maxErrors ? "failure" : "success";

await submitResult(githubToken, octokit, conclusion, annotations);
await submitResult(octokit, checkName,conclusion, annotations);
} catch (error) {
console.log(error);
core.setFailed(error.message);
Expand Down