mirror of
https://github.com/graalvm/setup-graalvm.git
synced 2025-03-13 14:30:15 +08:00
undone changes
This commit is contained in:
parent
5bc77ce65e
commit
a342fbb5bc
39
dist/main/index.js
generated
vendored
39
dist/main/index.js
generated
vendored
@ -74551,8 +74551,6 @@ function generateReports() {
|
||||
}
|
||||
const buildOutput = JSON.parse(fs.readFileSync(BUILD_OUTPUT_JSON_PATH, 'utf8'));
|
||||
yield (0, utils_1.saveReportJson)(JSON.stringify(buildOutput));
|
||||
const treeSha = yield (0, utils_1.createTree)(JSON.stringify(buildOutput));
|
||||
yield (0, utils_1.createRef)(treeSha);
|
||||
const report = createReport(buildOutput);
|
||||
if (areJobReportsEnabled()) {
|
||||
core.summary.addRaw(report);
|
||||
@ -75756,7 +75754,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.createTree = exports.createRef = exports.saveReportJson = exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getMatchingTags = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0;
|
||||
exports.saveReportJson = exports.createPRComment = exports.isPREvent = exports.toSemVer = exports.calculateSHA256 = exports.downloadExtractAndCacheJDK = exports.downloadAndExtractJDK = exports.getMatchingTags = exports.getTaggedRelease = exports.getLatestRelease = exports.exec = void 0;
|
||||
const c = __importStar(__nccwpck_require__(2764));
|
||||
const core = __importStar(__nccwpck_require__(2258));
|
||||
const github = __importStar(__nccwpck_require__(7168));
|
||||
@ -75897,9 +75895,6 @@ exports.isPREvent = isPREvent;
|
||||
function getGitHubToken() {
|
||||
return core.getInput(c.INPUT_GITHUB_TOKEN);
|
||||
}
|
||||
function getCommitSha() {
|
||||
return process.env.GITHUB_SHA || "default_tag";
|
||||
}
|
||||
function createPRComment(content) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
@ -75908,7 +75903,7 @@ function createPRComment(content) {
|
||||
}
|
||||
const context = github.context;
|
||||
try {
|
||||
yield new rest_1.Octokit({ auth: process.env.GITHUB_TOKEN }).rest.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.number, body: content }));
|
||||
yield github.getOctokit(getGitHubToken()).rest.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.number, body: content }));
|
||||
}
|
||||
catch (err) {
|
||||
core.error(`Failed to create pull request comment. Please make sure this job has 'write' permissions for the 'pull-requests' scope (see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)? Internal error: ${err}`);
|
||||
@ -75949,36 +75944,6 @@ function saveReportJson(content) {
|
||||
});
|
||||
}
|
||||
exports.saveReportJson = saveReportJson;
|
||||
function createRef(sha) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const ref = `refs/metrics/` + getCommitSha();
|
||||
console.log(`creating ref ${ref} for metrics tree ${sha}`);
|
||||
const octokit = new rest_1.Octokit({ auth: process.env.GITHUB_TOKEN });
|
||||
const context = github.context;
|
||||
const response = yield octokit.request(`POST /repos/${context.repo.owner}/${context.repo.repo}/git/refs`, Object.assign(Object.assign({}, context.repo), { ref,
|
||||
sha }));
|
||||
console.log(response);
|
||||
});
|
||||
}
|
||||
exports.createRef = createRef;
|
||||
function createTree(json) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
console.log(`creating tree at jessiscript/re_build_tracking`);
|
||||
const octokit = new rest_1.Octokit({ auth: process.env.GITHUB_TOKEN });
|
||||
const context = github.context;
|
||||
const response = yield octokit.request(`POST /repos/${context.repo.owner}/${context.repo.repo}/git/trees`, Object.assign(Object.assign({}, context.repo), { tree: [
|
||||
{
|
||||
path: "report.json",
|
||||
mode: "100644",
|
||||
type: "blob",
|
||||
content: json,
|
||||
},
|
||||
] }));
|
||||
console.log(response);
|
||||
return response.data.sha;
|
||||
});
|
||||
}
|
||||
exports.createTree = createTree;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
@ -4,7 +4,7 @@ import * as fs from 'fs'
|
||||
import * as github from '@actions/github'
|
||||
import {join} from 'path'
|
||||
import {tmpdir} from 'os'
|
||||
import {createPRComment, createRef, createTree, isPREvent, saveReportJson, toSemVer} from '../utils'
|
||||
import {createPRComment, isPREvent, saveReportJson, toSemVer} from '../utils'
|
||||
import {gte} from 'semver'
|
||||
import {Base64} from 'js-base64';
|
||||
import { Octokit } from '@octokit/rest';
|
||||
@ -135,8 +135,6 @@ export async function generateReports(): Promise<void> {
|
||||
)
|
||||
|
||||
await saveReportJson(JSON.stringify(buildOutput))
|
||||
const treeSha = await createTree(JSON.stringify(buildOutput))
|
||||
await createRef(treeSha)
|
||||
|
||||
const report = createReport(buildOutput)
|
||||
if (areJobReportsEnabled()) {
|
||||
|
122
src/utils.ts
122
src/utils.ts
@ -22,80 +22,80 @@ const GitHubDotCom = Octokit.defaults({
|
||||
})
|
||||
|
||||
export async function exec(
|
||||
commandLine: string,
|
||||
args?: string[],
|
||||
options?: ExecOptions | undefined
|
||||
commandLine: string,
|
||||
args?: string[],
|
||||
options?: ExecOptions | undefined
|
||||
): Promise<void> {
|
||||
const exitCode = await e(commandLine, args, options)
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(
|
||||
`'${[commandLine]
|
||||
.concat(args || [])
|
||||
.join(' ')}' exited with a non-zero code: ${exitCode}`
|
||||
`'${[commandLine]
|
||||
.concat(args || [])
|
||||
.join(' ')}' exited with a non-zero code: ${exitCode}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export async function getLatestRelease(
|
||||
repo: string
|
||||
repo: string
|
||||
): Promise<c.LatestReleaseResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
||||
const octokit = new GitHubDotCom(options)
|
||||
return (
|
||||
await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo
|
||||
})
|
||||
await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo
|
||||
})
|
||||
).data
|
||||
}
|
||||
|
||||
export async function getTaggedRelease(
|
||||
repo: string,
|
||||
tag: string
|
||||
repo: string,
|
||||
tag: string
|
||||
): Promise<c.LatestReleaseResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
||||
const octokit = new GitHubDotCom(options)
|
||||
return (
|
||||
await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo,
|
||||
tag
|
||||
})
|
||||
await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo,
|
||||
tag
|
||||
})
|
||||
).data
|
||||
}
|
||||
|
||||
export async function getMatchingTags(
|
||||
tagPrefix: string
|
||||
tagPrefix: string
|
||||
): Promise<c.MatchingRefsResponse['data']> {
|
||||
const githubToken = getGitHubToken()
|
||||
const options = githubToken.length > 0 ? {auth: githubToken} : {}
|
||||
const octokit = new GitHubDotCom(options)
|
||||
return (
|
||||
await octokit.request(
|
||||
'GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}',
|
||||
{
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo: c.GRAALVM_RELEASES_REPO,
|
||||
tagPrefix
|
||||
}
|
||||
)
|
||||
await octokit.request(
|
||||
'GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}',
|
||||
{
|
||||
owner: c.GRAALVM_GH_USER,
|
||||
repo: c.GRAALVM_RELEASES_REPO,
|
||||
tagPrefix
|
||||
}
|
||||
)
|
||||
).data
|
||||
}
|
||||
|
||||
export async function downloadAndExtractJDK(
|
||||
downloadUrl: string
|
||||
downloadUrl: string
|
||||
): Promise<string> {
|
||||
return findJavaHomeInSubfolder(
|
||||
await extract(await tc.downloadTool(downloadUrl))
|
||||
await extract(await tc.downloadTool(downloadUrl))
|
||||
)
|
||||
}
|
||||
|
||||
export async function downloadExtractAndCacheJDK(
|
||||
downloader: () => Promise<string>,
|
||||
toolName: string,
|
||||
version: string
|
||||
downloader: () => Promise<string>,
|
||||
toolName: string,
|
||||
version: string
|
||||
): Promise<string> {
|
||||
const semVersion = toSemVer(version)
|
||||
let toolPath = tc.find(toolName, semVersion)
|
||||
@ -122,7 +122,7 @@ async function extract(downloadPath: string): Promise<string> {
|
||||
return await tc.extractZip(downloadPath)
|
||||
} else {
|
||||
throw new Error(
|
||||
`Unexpected filetype downloaded: ${c.GRAALVM_FILE_EXTENSION}`
|
||||
`Unexpected filetype downloaded: ${c.GRAALVM_FILE_EXTENSION}`
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -133,7 +133,7 @@ function findJavaHomeInSubfolder(searchPath: string): string {
|
||||
return join(searchPath, baseContents[0], c.JDK_HOME_SUFFIX)
|
||||
} else {
|
||||
throw new Error(
|
||||
`Unexpected amount of directory items found: ${baseContents.length}`
|
||||
`Unexpected amount of directory items found: ${baseContents.length}`
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -159,29 +159,25 @@ function getGitHubToken(): string {
|
||||
return core.getInput(c.INPUT_GITHUB_TOKEN)
|
||||
}
|
||||
|
||||
function getCommitSha(): string {
|
||||
return process.env.GITHUB_SHA || "default_tag"
|
||||
}
|
||||
|
||||
export async function createPRComment(content: string): Promise<void> {
|
||||
if (!isPREvent()) {
|
||||
throw new Error('Not a PR event.')
|
||||
}
|
||||
const context = github.context
|
||||
try {
|
||||
await new Octokit({ auth: process.env.GITHUB_TOKEN }).rest.issues.createComment({
|
||||
await github.getOctokit(getGitHubToken()).rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: context.payload.pull_request?.number as number,
|
||||
body: content
|
||||
})
|
||||
} catch (err) {
|
||||
core.error(
|
||||
`Failed to create pull request comment. Please make sure this job has 'write' permissions for the 'pull-requests' scope (see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)? Internal error: ${err}`
|
||||
`Failed to create pull request comment. Please make sure this job has 'write' permissions for the 'pull-requests' scope (see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)? Internal error: ${err}`
|
||||
)
|
||||
}
|
||||
}
|
||||
export async function saveReportJson(content: string): Promise<void> {
|
||||
|
||||
export async function saveReportJson(content: string): Promise<void> {
|
||||
try {
|
||||
const octokit = new Octokit({
|
||||
auth: getGitHubToken(),
|
||||
@ -215,46 +211,4 @@ export async function saveReportJson(content: string): Promise<void> {
|
||||
`Failed to create pull request comment. Please make sure this job has 'write' permissions for the 'pull-requests' scope (see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions)? Internal error: ${err}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export async function createRef(sha: string) {
|
||||
const ref = `refs/metrics/` + getCommitSha()
|
||||
console.log(`creating ref ${ref} for metrics tree ${sha}`);
|
||||
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
|
||||
|
||||
const context = github.context
|
||||
const response = await octokit.request(
|
||||
`POST /repos/${context.repo.owner}/${context.repo.repo}/git/refs`,
|
||||
{
|
||||
...context.repo,
|
||||
ref,
|
||||
sha,
|
||||
}
|
||||
);
|
||||
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
export async function createTree(json: string): Promise<string> {
|
||||
console.log(`creating tree at jessiscript/re_build_tracking`);
|
||||
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
|
||||
|
||||
const context = github.context
|
||||
const response = await octokit.request(
|
||||
`POST /repos/${context.repo.owner}/${context.repo.repo}/git/trees`,
|
||||
{
|
||||
...context.repo,
|
||||
tree: [
|
||||
{
|
||||
path: "report.json",
|
||||
mode: "100644",
|
||||
type: "blob",
|
||||
content: json,
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
|
||||
console.log(response);
|
||||
return response.data.sha;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user