Skip to content

Commit

Permalink
🐛 Fixes flake8 command piping problem
Browse files Browse the repository at this point in the history
Due to a bug in the @actions/exec package piping of commands is
currently not supported. I therefore had to use the workarround that is
given in actions/toolkit#346.
  • Loading branch information
rickstaa committed Dec 10, 2020
1 parent 378e483 commit c439054
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1619,11 +1619,11 @@ async function run() {
await exec.exec("python -m pip install --upgrade pip");
}

// install reviewdog
// install Reviewdog (nightly)
console.log(`[*] Installing reviewdog...`);
await exec.exec(
`/bin/bash -c "wget -O - -q https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh| sudo sh -s -- -b /usr/local/bin/`
);
); // /bin/bash -c is needed since @actions/exec does not yet support piping https://github.com/actions/toolkit/issues/346

// install/update flake8 package
console.log(`[*] Installing flake8 package @ ${flake8Version}...`);
Expand Down Expand Up @@ -1674,13 +1674,13 @@ async function run() {
level = "error";
}

// Add reviewdog execution code
// setup reviewdog execution command
console.log(`[*] Adding reviewdog command...`);
flake8Cmd += `| reviewdog -f flake8 -name="flake8-lint" -reporter="${reporter}" -level="${level}" -tee`;
const reviewdogCmd = `reviewdog -f flake8 -name="flake8-lint" -reporter="${reporter}" -level="${level}" -tee`;

// execute flake8
// execute flake8 with reviewdog annotations
console.log(`[*] Executing flake8 + reviewdog command...`);
await exec.exec(`${flake8Cmd}`);
await exec.exec(`/bin/bash -c "${flake8Cmd}|${reviewdogCmd}"`);
} catch (error) {
core.setFailed(
`ERROR: Action failed during execution with error: ${error.message}`
Expand Down
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ async function run() {
await exec.exec("python -m pip install --upgrade pip");
}

// install reviewdog
// install Reviewdog (nightly)
console.log(`[*] Installing reviewdog...`);
await exec.exec(
`/bin/bash -c "wget -O - -q https://raw.githubusercontent.com/reviewdog/nightly/master/install.sh| sudo sh -s -- -b /usr/local/bin/`
);
); // /bin/bash -c is needed since @actions/exec does not yet support piping https://github.com/actions/toolkit/issues/346

// install/update flake8 package
console.log(`[*] Installing flake8 package @ ${flake8Version}...`);
Expand Down Expand Up @@ -79,13 +79,13 @@ async function run() {
level = "error";
}

// Add reviewdog execution code
// setup reviewdog execution command
console.log(`[*] Adding reviewdog command...`);
flake8Cmd += `| reviewdog -f flake8 -name="flake8-lint" -reporter="${reporter}" -level="${level}" -tee`;
const reviewdogCmd = `reviewdog -f flake8 -name="flake8-lint" -reporter="${reporter}" -level="${level}" -tee`;

// execute flake8
// execute flake8 with reviewdog annotations
console.log(`[*] Executing flake8 + reviewdog command...`);
await exec.exec(`${flake8Cmd}`);
await exec.exec(`/bin/bash -c "${flake8Cmd}|${reviewdogCmd}"`);
} catch (error) {
core.setFailed(
`ERROR: Action failed during execution with error: ${error.message}`
Expand Down

0 comments on commit c439054

Please sign in to comment.