Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(electron-updater): fix backward compatibility for GitHub provider without channels #6998

Conversation

matejkriz
Copy link
Contributor

@matejkriz matejkriz commented Jul 12, 2022

Adding support for channels on GitHub was breaking change for those using only pre-release status without channel tags.

  • TODO: update documentation

Issues with the current solution (without this PR):

Example 1:

  • User has app version 1.0.0 with allowPrerelease=true
  • App has available updates on GitHub:
    • 2.0.0-beta
    • 4.0.0 latest

Expected result is to offer latest 4.0.0 version, but in current state it offers 2.0.0-beta.

Example 2:

  • User has app version 1.0.0 with allowPrerelease=true
  • App has available updates on GitHub:
    • 2.0.0 latest
    • 3.0.0 in pre-release state

Expected result is to offer pre-released 3.0.0 version, but in current state it offers no update at all.

… without channels

Adding support for channels on GitHub was breaking change for those using only pre-release status without channel tags.
@changeset-bot
Copy link

changeset-bot bot commented Jul 12, 2022

🦋 Changeset detected

Latest commit: 2666c98

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
electron-updater Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Jul 12, 2022

Deploy Preview for car-park-attendant-cleat-11576 ready!

Name Link
🔨 Latest commit 2666c98
🔍 Latest deploy log https://app.netlify.com/sites/car-park-attendant-cleat-11576/deploys/62cd8dd57355cf0008bf6c04
😎 Deploy Preview https://deploy-preview-6998--car-park-attendant-cleat-11576.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@matejkriz
Copy link
Contributor Author

@matejkriz
Copy link
Contributor Author

maybe fixes #6700

@mmaietta
Copy link
Collaborator

This looks great.

I'd like to set up a test repo for this so that we can have two different tests for prerelease w/ channels and without. I thought we already had covered these use cases here: https://github.com/electron-userland/electron-builder/blob/master/test/src/updater/nsisUpdaterTest.ts#L279-L305

What's your publish config?

@matejkriz
Copy link
Contributor Author

Thanks for your quick response!

What's your publish config?
Do you mean this? https://github.com/trezor/trezor-suite/blob/develop/packages/suite-desktop/package.json#L90

Our flow is using pre-release state on GitHub for opt-in "Early access program" and publishing from Early access to public just by removing pre-release state.

@matejkriz
Copy link
Contributor Author

@mmaietta please let me know how could I help to test it properly / prepare test repo.

@mmaietta
Copy link
Collaborator

mmaietta commented Jul 13, 2022

Thanks for adding the expected flows:

Example 1:

User has app version 1.0.0 with allowPrerelease=true
App has available updates on GitHub:
2.0.0-beta
4.0.0 latest
Expected result is to offer latest 4.0.0 version, but in current state it offers 2.0.0-beta.

Example 2:

User has app version 1.0.0 with allowPrerelease=true
App has available updates on GitHub:
2.0.0 latest
3.0.0 in pre-release state
Expected result is to offer pre-released 3.0.0 version, but in current state it offers no update at all.

Was this previously working this way? Trying to discern if this was a regression or if this changes base functionality of what the definition of allowPrerelease is

I don't see any unit tests with in the Updater Tests that are configured with allowPrerelease, so that flow will need coverage.

@matejkriz
Copy link
Contributor Author

matejkriz commented Jul 14, 2022

Was this previously working this way? Trying to discern if this was a regression or if this changes base functionality of what the definition of allowPrerelease is

Yes, I believe it is a regression, the expected results were met in v4.6.5 but no more in v5.0.5.

@mmaietta
Copy link
Collaborator

That's a regression alright 😅
I've created a test repo that works on your branch with the following tests to NsisUpdaterTests.ts. I think it should cover both examples you have listed.

test("github allowPrerelease=true", async () => {
  const updater = await createNsisUpdater('1.0.1')
  updater.allowPrerelease = true
  updater.updateConfigPath = await writeUpdateConfig<GithubOptions>({
    provider: "github",
    owner: "mmaietta",
    repo: "electron-builder-test"
  })
  const updateCheckResult = await updater.checkForUpdates()
  expect(removeUnstableProperties(updateCheckResult?.updateInfo)).toMatchSnapshot()
})

test("github allowPrerelease=false", async () => {
  const updater = await createNsisUpdater('1.0.1')
  updater.allowPrerelease = false
  updater.updateConfigPath = await writeUpdateConfig<GithubOptions>({
    provider: "github",
    owner: "mmaietta",
    repo: "electron-builder-test"
  })
  const updateCheckResult = await updater.checkForUpdates()
  expect(removeUnstableProperties(updateCheckResult?.updateInfo)).toMatchSnapshot()
})

Can you please add to your PR and use pnpm compile && TEST_FILES=nsisUpdaterTest UPDATE_SNAPSHOT=true pnpm test to generate the new test snapshots

@mmaietta mmaietta merged commit d6115bc into electron-userland:master Jul 16, 2022
@mmaietta
Copy link
Collaborator

Merging. I'll add the tests separate :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants