updated logging
This commit is contained in:
Родитель
7a3d19e83f
Коммит
4af16e68f9
|
@ -1,6 +1,11 @@
|
|||
const nock = require("nock");
|
||||
const { GitHubProvider } = require("../src/github-provider");
|
||||
|
||||
import * as core from "@actions/core";
|
||||
|
||||
jest.spyOn(core, "debug").mockImplementation(() => {});
|
||||
jest.spyOn(core, "info").mockImplementation(() => {});
|
||||
|
||||
test("It creates an approved review", async () => {
|
||||
process.env["GITHUB_REPOSITORY"] = "foo/bar";
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import { GitHubProvider } from "../src/github-provider";
|
||||
import { PrivilegedRequester } from "../src/privileged-requester";
|
||||
|
||||
import * as core from "@actions/core";
|
||||
|
||||
jest.spyOn(core, "debug").mockImplementation(() => {});
|
||||
jest.spyOn(core, "info").mockImplementation(() => {});
|
||||
|
||||
test("We receive the expected config content", async () => {
|
||||
let configContent = `---
|
||||
requesters:
|
||||
|
|
|
@ -36930,6 +36930,9 @@ class GitHubProvider {
|
|||
}
|
||||
|
||||
async createReview(prNumber, reviewEvent) {
|
||||
core.debug(`prNumber: ${prNumber}`)
|
||||
core.debug(`reviewEvent: ${reviewEvent}`)
|
||||
|
||||
await this.octokit.rest.pulls.createReview({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
|
@ -36939,11 +36942,14 @@ class GitHubProvider {
|
|||
}
|
||||
|
||||
async getConfigContent() {
|
||||
const path = core.getInput("path", { required: true })
|
||||
core.info(`config path: ${path}`)
|
||||
|
||||
// getContent defaults to the main branch
|
||||
const { data: configContent } = await this.octokit.rest.repos.getContent({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
path: core.getInput("path"),
|
||||
path: path,
|
||||
mediaType: { format: "raw" },
|
||||
});
|
||||
return configContent;
|
||||
|
@ -37001,6 +37007,8 @@ class PrivilegedRequester {
|
|||
if (this.requesters === false) {
|
||||
try {
|
||||
const config = await this.github.getConfigContent();
|
||||
lib_core.debug(`config: ${config}`);
|
||||
|
||||
this.configContents = yaml.load(config);
|
||||
this.requesters = this.configContents["requesters"];
|
||||
} catch (err) {
|
||||
|
@ -37237,7 +37245,7 @@ class Runner {
|
|||
const index_core = __nccwpck_require__(2186);
|
||||
let myToken = index_core.getInput("myToken");
|
||||
const robotUserToken = index_core.getInput("robotUserToken");
|
||||
if (robotUserToken !== "") {
|
||||
if (robotUserToken !== "" || robotUserToken !== undefined || robotUserToken !== null) {
|
||||
index_core.info("Robot User configured. I will use that PAT instead.");
|
||||
myToken = robotUserToken;
|
||||
}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
2
index.js
2
index.js
|
@ -6,7 +6,7 @@ import { Runner } from "./src/runner";
|
|||
const core = require("@actions/core");
|
||||
let myToken = core.getInput("myToken");
|
||||
const robotUserToken = core.getInput("robotUserToken");
|
||||
if (robotUserToken !== "") {
|
||||
if (robotUserToken !== "" || robotUserToken !== undefined || robotUserToken !== null) {
|
||||
core.info("Robot User configured. I will use that PAT instead.");
|
||||
myToken = robotUserToken;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@ class GitHubProvider {
|
|||
}
|
||||
|
||||
async createReview(prNumber, reviewEvent) {
|
||||
core.debug(`prNumber: ${prNumber}`)
|
||||
core.debug(`reviewEvent: ${reviewEvent}`)
|
||||
|
||||
await this.octokit.rest.pulls.createReview({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
|
@ -20,11 +23,14 @@ class GitHubProvider {
|
|||
}
|
||||
|
||||
async getConfigContent() {
|
||||
const path = core.getInput("path", { required: true })
|
||||
core.info(`config path: ${path}`)
|
||||
|
||||
// getContent defaults to the main branch
|
||||
const { data: configContent } = await this.octokit.rest.repos.getContent({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
path: core.getInput("path"),
|
||||
path: path,
|
||||
mediaType: { format: "raw" },
|
||||
});
|
||||
return configContent;
|
||||
|
|
|
@ -14,6 +14,8 @@ class PrivilegedRequester {
|
|||
if (this.requesters === false) {
|
||||
try {
|
||||
const config = await this.github.getConfigContent();
|
||||
core.debug(`config: ${config}`);
|
||||
|
||||
this.configContents = yaml.load(config);
|
||||
this.requesters = this.configContents["requesters"];
|
||||
} catch (err) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче