mirror of
https://github.com/GoTestTools/gotestfmt-action.git
synced 2026-02-22 23:51:46 +00:00
Remove inline comments
This is per @engelmi's comment: https://github.com/GoTestTools/gotestfmt-action/pull/10/files#r1017614705 Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com>
This commit is contained in:
parent
141a3b7b62
commit
ef20a3ae63
1 changed files with 5 additions and 16 deletions
19
index.js
19
index.js
|
|
@ -4,50 +4,39 @@ const fs = require("fs")
|
||||||
const { execSync } = require("child_process")
|
const { execSync } = require("child_process")
|
||||||
|
|
||||||
async function downloadRelease(octokit, os, org, repo, release, token) {
|
async function downloadRelease(octokit, os, org, repo, release, token) {
|
||||||
|
const postfix = `_${os}_amd64.${os === "windows" ? "zip" : "tar.gz"}`;
|
||||||
|
const tempdir = os === "windows" ? process.env.TEMP + "\\" : "/tmp/";
|
||||||
|
const extract = os === "windows" ? "tar -xvf" : "tar -xvzf";
|
||||||
|
const archive = `${tempdir}gotestfmt${postfix}`;
|
||||||
const releaseAssets = await octokit.rest.repos.listReleaseAssets({
|
const releaseAssets = await octokit.rest.repos.listReleaseAssets({
|
||||||
owner: org,
|
owner: org,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
release_id: release.id,
|
release_id: release.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Determine environment specific details, paths etc...
|
|
||||||
const postfix = `_${os}_amd64.${os === "windows" ? "zip" : "tar.gz"}`;
|
|
||||||
const tempdir = os === "windows" ? process.env.TEMP + "\\" : "/tmp/";
|
|
||||||
const extract = os === "windows" ? "tar -xvf" : "tar -xvzf";
|
|
||||||
const archive = `${tempdir}gotestfmt${postfix}`;
|
|
||||||
|
|
||||||
// Search through the latest release assets for an install canidate
|
|
||||||
for (let asset of releaseAssets.data) {
|
for (let asset of releaseAssets.data) {
|
||||||
// Check if the asset name matches the determined postfix
|
|
||||||
console.log("Examining release asset " + asset.name + " at " + asset.browser_download_url + " ...")
|
console.log("Examining release asset " + asset.name + " at " + asset.browser_download_url + " ...")
|
||||||
if (asset.name.endsWith(postfix)) {
|
if (asset.name.endsWith(postfix)) {
|
||||||
// Download the selected release asset archive
|
|
||||||
console.log("Found binary named " + asset.name + " at " + asset.browser_download_url + " , attempting download...")
|
console.log("Found binary named " + asset.name + " at " + asset.browser_download_url + " , attempting download...")
|
||||||
if (token) {
|
if (token) {
|
||||||
// Use the token to avoid rate limits
|
|
||||||
execSync(`curl -L -o ${archive} -H "Authorization: Bearer ${token}" ${asset.browser_download_url}`)
|
execSync(`curl -L -o ${archive} -H "Authorization: Bearer ${token}" ${asset.browser_download_url}`)
|
||||||
} else {
|
} else {
|
||||||
// Fallback to unauthenticated requests (might get rate limited)
|
|
||||||
execSync(`curl -L -o ${archive} ${asset.browser_download_url}`)
|
execSync(`curl -L -o ${archive} ${asset.browser_download_url}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the archive into the install target
|
|
||||||
console.log("Unpacking archive file...")
|
console.log("Unpacking archive file...")
|
||||||
core.addPath(process.env.GITHUB_WORKSPACE)
|
core.addPath(process.env.GITHUB_WORKSPACE)
|
||||||
process.chdir(process.env.GITHUB_WORKSPACE)
|
process.chdir(process.env.GITHUB_WORKSPACE)
|
||||||
execSync(`${extract} "${archive}"`)
|
execSync(`${extract} "${archive}"`)
|
||||||
|
|
||||||
// Remove the downloaded asset archive
|
|
||||||
console.log("Removing asset archive...")
|
console.log("Removing asset archive...")
|
||||||
fs.unlinkSync(archive)
|
fs.unlinkSync(archive)
|
||||||
|
|
||||||
// Successfully installed gotestfmt, return early
|
|
||||||
console.log("Successfully set up gotestfmt.")
|
console.log("Successfully set up gotestfmt.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Throw an error if no asset matched the expected postfix
|
|
||||||
throw `No release asset matched postfix '${postfix}'.`
|
throw `No release asset matched postfix '${postfix}'.`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue