Skip to content

fix(publish): Fix publishing when resuming from a state file#197

Merged
BYK merged 3 commits into
masterfrom
byk/fix/publish
Apr 6, 2021
Merged

fix(publish): Fix publishing when resuming from a state file#197
BYK merged 3 commits into
masterfrom
byk/fix/publish

Conversation

@BYK

@BYK BYK commented Apr 5, 2021

Copy link
Copy Markdown
Member

This is a follow up to #192. It fixes a bug that occurs when a
publish state file does not list all possible targets. In this case
any unlisted target, is skipped whereas its state should be treated
as "unpublished". This stemmed from a logic error in the if statement
which skipped publishing when the special target type "none" was passed.

The PR also refactors the code around this a bit to make it easier
to follow and less prone to errors. Ideal follow ups would be more
tests around publish and the state file functionality.

Example case: https://github.com/getsentry/publish/runs/2254551314?check_suite_focus=true#step:8:45

When it found a state file, Craft completely skipped the whole publish pipeline, causing the github target to not be published but the publish operation successfully finishing.

This is a follow up to #192. It fixes a bug that occurs when a
publish state file does not list all possible targets. In this case
any unlisted target, is skipped whereas its state should be treated
as "unpublished". This stemmed from a logic error in the if statement
which skipped publishing when the special target type "none" was passed.

The PR also refactors the code around this a bit to make it easier
to follow and less prone to errors. Ideal follow ups would be more
tests around publish and the state file functionality.
@BYK
BYK requested review from chadwhitacre, jan-auer and tonyo April 5, 2021 10:23
Comment thread src/commands/publish.ts Outdated
Comment thread src/commands/publish.ts
logger.info(`Found publish state file, resuming from there...`);
publishState = JSON.parse(readFileSync(publishStateFile).toString());
targetsToPublish = new Set(getAllTargetNames());
targetsToPublish = new Set(targetConfigList.map(getTargetId));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, combined with better splitting the if statements below is the real fix for the issue documented on the PR description.

Comment thread src/commands/publish.ts Outdated
name: 'readyToPublish',
type: 'input',
validate: (input: string) => input.length > 2 || 'Please type "yes"',
validate: (input: string) => input.length >= 2 || 'Please type "yes"',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t understand this code. What is this supposed to do?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can add a comment :D

chadwhitacre
chadwhitacre approved these changes Apr 5, 2021
@BYK
BYK enabled auto-merge (squash) April 6, 2021 07:47
@BYK
BYK merged commit 35f9536 into master Apr 6, 2021
@BYK
BYK deleted the byk/fix/publish branch April 6, 2021 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants