Skip to content

Commit

Permalink
chore: cleanup PackSquash < 0.3.1 support code remnants
Browse files Browse the repository at this point in the history
I'm not interested in supporting older PackSquash versions on newer
versions of the action because it requires effort, complicates
maintenance, and it might backfire as an excuse for users to don't
upgrade, even if they lack good reasons to stay outdated. Unless those
older versions happen to be compatible and there are no reasons to drop
that support, of course.

Let's remove code whose only purpose was to deal with older PackSquash
versions that the action rejects anyway.
  • Loading branch information
AlexTMjugador committed Oct 11, 2022
1 parent 79e2c36 commit fc12103
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 33 deletions.
6 changes: 3 additions & 3 deletions dist/main/index.js

Large diffs are not rendered by default.

43 changes: 14 additions & 29 deletions src/packsquash.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { debug, endGroup, getBooleanInput, getInput, setSecret, startGroup, warning } from '@actions/core';
import { debug, endGroup, getBooleanInput, getInput, setSecret, startGroup } from '@actions/core';
import { exec } from '@actions/exec';
import { readFile, rm, writeFile } from 'fs/promises';
import { readFile, writeFile } from 'fs/promises';
import { addProblemMatcher, removeProblemMatcher } from './problem_matcher';
import { Options } from './options';
import * as uuid from 'uuid';
Expand All @@ -22,39 +22,24 @@ export async function runPackSquash(workingDirectory: WorkingDirectory) {
debug(`Using system ID: ${systemId}`);
setSecret(systemId);

async function run(description: string | null) {
await addProblemMatcher(workingDirectory.problemMatcherFile);
if (description) {
startGroup(`PackSquash output (${description})`);
} else {
startGroup('PackSquash output');
await addProblemMatcher(workingDirectory.problemMatcherFile);

startGroup('PackSquash output');
const exitCode = await exec(workingDirectory.packsquashBinary, [workingDirectory.optionsFile], {
env: {
PACKSQUASH_SYSTEM_ID: systemId,
PACKSQUASH_EMOJI: showEmojiInPacksquashLogs(),
PACKSQUASH_COLOR: enableColorInPacksquashLogs()
}
const exitCode = await exec(workingDirectory.packsquashBinary, [workingDirectory.optionsFile], {
env: {
PACKSQUASH_SYSTEM_ID: systemId,
PACKSQUASH_EMOJI: showEmojiInPacksquashLogs(),
PACKSQUASH_COLOR: enableColorInPacksquashLogs()
}
});
endGroup();
removeProblemMatcher(workingDirectory.problemMatcherFile);
return exitCode;
}
});
endGroup();

removeProblemMatcher(workingDirectory.problemMatcherFile);

let exitCode = await run(null);
switch (exitCode) {
case 0:
// Success
break;
case 129:
// Actionable error code returned by v0.3.0 only
warning('PackSquash reported that the previous ZIP file could not be used to speed up processing. Discarding it.');
await rm(workingDirectory.outputFile);
exitCode = await run('discarded previous ZIP file');
if (exitCode !== 0) {
throw new Error(`PackSquash finished with an error code: ${exitCode}`);
}
break;
default:
// Any other PackSquash error
throw new Error(`PackSquash finished with an error code: ${exitCode}`);
Expand Down
2 changes: 1 addition & 1 deletion src/problem_matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const json = {
severity: 'error',
pattern: [
{
regexp: '^(?:\x1B\\[\\d+\\w*)*[!❌] (?!.*Invalid stick parity bit)(.+?)(?:\x1B\\[0m)?$',
regexp: '^(?:\x1B\\[\\d+\\w*)*[!❌] (.+?)(?:\x1B\\[0m)?$',
message: 1
},
{
Expand Down

0 comments on commit fc12103

Please sign in to comment.