fix(publish): Fix publishing when resuming from a state file#197
Merged
Conversation
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
commented
Apr 5, 2021
BYK
commented
Apr 5, 2021
| 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)); |
Member
Author
There was a problem hiding this comment.
This, combined with better splitting the if statements below is the real fix for the issue documented on the PR description.
mitsuhiko
reviewed
Apr 5, 2021
| name: 'readyToPublish', | ||
| type: 'input', | ||
| validate: (input: string) => input.length > 2 || 'Please type "yes"', | ||
| validate: (input: string) => input.length >= 2 || 'Please type "yes"', |
Contributor
There was a problem hiding this comment.
I don’t understand this code. What is this supposed to do?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
githubtarget to not be published but the publish operation successfully finishing.