Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marina Limeira committed Sep 7, 2023
1 parent d146162 commit ac9dc3e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 31 deletions.
21 changes: 18 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13754,8 +13754,16 @@ async function downloadGitHubBinary(octokit, owner, repo, tag, token) {
async function downloadAndSetupTooling(octokit, token) {
// Setup the tools also installed in https://hub.docker.com/r/gruntwork/patcher_bash_env
const tools = [
{ org: GRUNTWORK_GITHUB_ORG, repo: PATCHER_GITHUB_REPO, version: PATCHER_VERSION },
{ org: GRUNTWORK_GITHUB_ORG, repo: TERRAPATCH_GITHUB_REPO, version: TERRAPATCH_VERSION },
{
org: GRUNTWORK_GITHUB_ORG,
repo: PATCHER_GITHUB_REPO,
version: PATCHER_VERSION,
},
{
org: GRUNTWORK_GITHUB_ORG,
repo: TERRAPATCH_GITHUB_REPO,
version: TERRAPATCH_VERSION,
},
{ org: HCLEDIT_ORG, repo: TFUPDATE_GITHUB_REPO, version: TFUPDATE_VERSION },
{ org: HCLEDIT_ORG, repo: HCLEDIT_GITHUB_REPO, version: HCLEDIT_VERSION },
];
Expand Down Expand Up @@ -13808,7 +13816,14 @@ async function runPatcher(octokit, gitCommiter, command, { updateStrategy, depen
core.startGroup("Running 'patcher update'");
const updateOutput = await exec.getExecOutput("patcher", updateArgs(updateStrategy, dependency, workingDir), { env: getPatcherEnvVars(token) });
core.endGroup();
if (false) {}
if (await wasCodeUpdated()) {
core.startGroup("Commit and push changes");
await commitAndPushChanges(gitCommiter, dependency, workingDir, token);
core.endGroup();
core.startGroup("Opening pull request");
await openPullRequest(octokit, gitCommiter, updateOutput.stdout, dependency, workingDir);
core.endGroup();
}
else {
core.info(`No changes in ${dependency} after running Patcher. No further action is necessary.`);
}
Expand Down
66 changes: 38 additions & 28 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const TERRAPATCH_GITHUB_REPO = "terrapatch-cli";
const TERRAPATCH_VERSION = "v0.1.3";

const HCLEDIT_ORG = "minamijoyo";
const TFUPDATE_GITHUB_REPO = "tfupdate"
const TFUPDATE_GITHUB_REPO = "tfupdate";
const TFUPDATE_VERSION = "v0.6.5";
const HCLEDIT_GITHUB_REPO = "hcledit"
const HCLEDIT_GITHUB_REPO = "hcledit";
const HCLEDIT_VERSION = "v0.2.5";

const REPORT_COMMAND = "report";
Expand Down Expand Up @@ -85,13 +85,6 @@ interface DownloadedBinary {
name: string;
}

interface Hi123 {
repo: string;
org: string;
version: string;
}


function osPlatform() {
const platform = os.platform();
switch (platform) {
Expand Down Expand Up @@ -296,12 +289,12 @@ async function openPullRequest(

function repoToBinaryMap(repo: string): string {
switch (repo) {
case "patcher-cli":
return "patcher";
case "terrapatch-cli":
return "terrapatch";
default:
return repo;
case "patcher-cli":
return "patcher";
case "terrapatch-cli":
return "terrapatch";
default:
return repo;
}
}

Expand All @@ -323,7 +316,7 @@ async function downloadGitHubBinary(
const binaryName = repoToBinaryMap(repo);

// Before downloading, check the cache.
const pathInCache = toolCache.find(repo, tag)
const pathInCache = toolCache.find(repo, tag);
if (pathInCache) {
core.info(`Found ${owner}/${repo} version ${tag} in cache!`);

Expand Down Expand Up @@ -365,34 +358,51 @@ async function downloadGitHubBinary(
);

if (path.extname(asset.name) === ".gz") {
await exec.exec(`mkdir ${binaryName}`)
await exec.exec(`tar -C ${binaryName} -xzvf ${downloadedPath}`)
await exec.exec(`mkdir ${binaryName}`);
await exec.exec(`tar -C ${binaryName} -xzvf ${downloadedPath}`);

const extractedPath = path.join(binaryName, binaryName)
const extractedPath = path.join(binaryName, binaryName);

const cachedPath = await toolCache.cacheFile(extractedPath, binaryName, repo, tag);
const cachedPath = await toolCache.cacheFile(
extractedPath,
binaryName,
repo,
tag,
);
core.debug(`Cached in ${cachedPath}`);

return { folder: cachedPath, name: binaryName };
}

const cachedPath = await toolCache.cacheFile(downloadedPath, binaryName, repo, tag);
const cachedPath = await toolCache.cacheFile(
downloadedPath,
binaryName,
repo,
tag,
);
core.debug(`Cached in ${cachedPath}`);

return { folder: cachedPath, name: binaryName };

}

async function downloadAndSetupTooling(octokit: GitHub, token: string) {
// Setup the tools also installed in https://hub.docker.com/r/gruntwork/patcher_bash_env
const tools = [
{org: GRUNTWORK_GITHUB_ORG, repo: PATCHER_GITHUB_REPO, version: PATCHER_VERSION},
{org: GRUNTWORK_GITHUB_ORG, repo: TERRAPATCH_GITHUB_REPO, version: TERRAPATCH_VERSION},
{org: HCLEDIT_ORG, repo: TFUPDATE_GITHUB_REPO, version: TFUPDATE_VERSION},
{org: HCLEDIT_ORG, repo: HCLEDIT_GITHUB_REPO, version: HCLEDIT_VERSION},
{
org: GRUNTWORK_GITHUB_ORG,
repo: PATCHER_GITHUB_REPO,
version: PATCHER_VERSION,
},
{
org: GRUNTWORK_GITHUB_ORG,
repo: TERRAPATCH_GITHUB_REPO,
version: TERRAPATCH_VERSION,
},
{ org: HCLEDIT_ORG, repo: TFUPDATE_GITHUB_REPO, version: TFUPDATE_VERSION },
{ org: HCLEDIT_ORG, repo: HCLEDIT_GITHUB_REPO, version: HCLEDIT_VERSION },
];

for await (const {org, repo, version} of tools) {
for await (const { org, repo, version } of tools) {
const binary = await downloadGitHubBinary(
octokit,
org,
Expand Down Expand Up @@ -475,7 +485,7 @@ async function runPatcher(
);
core.endGroup();

if (false) {
if (await wasCodeUpdated()) {
core.startGroup("Commit and push changes");
await commitAndPushChanges(gitCommiter, dependency, workingDir, token);
core.endGroup();
Expand Down

0 comments on commit ac9dc3e

Please sign in to comment.