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

Enable OS Updates to pre-release versions of higher base semver #1398

Merged
merged 4 commits into from
Jan 23, 2024

Conversation

thgreasi
Copy link
Member

@thgreasi thgreasi commented Jan 4, 2024

Depends-on: balena-io-modules/balena-hup-action-utils#34
Depends-on: https://github.com/balena-io/balena-proxy/pull/1098
Update balena-hup-action-utils from 5.0.0 to 6.1.0

Change-type: minor

Resolves: #
HQ:
See:
Depends-on:
Change-type: major|minor|patch


Contributor checklist
  • Includes tests
  • Includes typings
  • Includes updated documentation
  • Includes updated build output

@thgreasi thgreasi changed the title Update balena-hup-action-utils to 6.1.0 Enable OS Updates to pre-release versions of higher base semver Jan 4, 2024
@thgreasi thgreasi force-pushed the draft-hup branch 2 times, most recently from 85a9481 to ded8ea6 Compare January 4, 2024 15:57
@thgreasi thgreasi force-pushed the draft-hup branch 6 times, most recently from 536b6dc to b77818b Compare January 19, 2024 11:39
@thgreasi thgreasi marked this pull request as ready for review January 19, 2024 11:41
src/models/os.ts Outdated
$filter: {
is_final: true,
...(filterOptions !== 'include_draft' && { is_final: true }),
Copy link
Contributor

@otaviojacobi otaviojacobi Jan 19, 2024

Choose a reason for hiding this comment

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

maybe filterOptions === 'default' is more clear?

src/models/os.ts Outdated
@@ -392,6 +397,7 @@ const getOsModel = function (
* @memberof balena.models.os
*
* @param {String|String[]} deviceTypes - device type slug or array of slugs
* @param {Boolean} [includeDraft=false] - Whether pre-releases should be included in the results
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this could make more sense as an options object so that it can also cover the potential cases of production vs draft vs old/legacy vs known issues, etc without having to add a bunch of individual arguments

src/models/os.ts Outdated
async (deviceTypes: string[], listedByDefault: boolean | null) => {
async (
deviceTypes: string[],
filterOptions: 'default' | 'include_draft' | 'all',
Copy link
Member Author

Choose a reason for hiding this comment

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

authDependentMemoizer is atm using primitive: true and doesn't expose a normalizer, so I've left it for the next time we need to add an extra property for getAvailableOsVersions.

os_version: osVersion,
os_variant: osVariant,
},
'2.29.2-1704382618288+rev1.prod',
Copy link
Member

@myarmolinsky myarmolinsky Jan 23, 2024

Choose a reason for hiding this comment

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

Can we please have comments on why these specific OS versions were chosen? Same on line 3999 and 3960 (and anywhere else where we put a specific OS version)

Copy link
Member Author

@thgreasi thgreasi Jan 23, 2024

Choose a reason for hiding this comment

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

B/c that's the only one atm on prod that is draft, and since it's old enough I don't expect it to become finalized ever :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ends up the versions in this file are random, so I added a comment about that right at the start of the describe().

Comment on lines 3979 to 3983
[['balenaOS 2.28.0+rev1', 'prod']].forEach(function ([
osVersion,
osVariant,
]) {
expect(() =>
Copy link
Member

Choose a reason for hiding this comment

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

Why are we using an array and forEach when it's just one item?

Comment on lines 3999 to 4003
[['balenaOS 2.28.0-1704382553234', 'prod']].forEach(function ([
osVersion,
osVariant,
]) {
expect(() =>
Copy link
Member

Choose a reason for hiding this comment

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

Why are we using an array and forEach when it's just one item?

Comment on lines 4019 to 4023
[['balenaOS 2.28.0-1704382553234', 'prod']].forEach(function ([
osVersion,
osVariant,
]) {
expect(() =>
Copy link
Member

Choose a reason for hiding this comment

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

Why are we using an array and forEach when it's just one item?

src/models/os.ts Outdated
Comment on lines 367 to 375
filterOptions: 'default' | 'include_draft' | 'all',
) => {
return await _getAllOsVersions(
deviceTypes,
listedByDefault
? {
filterOptions === 'all'
? undefined
: {
$filter: {
is_final: true,
...(filterOptions === 'default' && { is_final: true }),
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer either a comment pointing out that default is finalized only or to replace default with finalized to make it clearer. (tbh I prefer replacing default with finalized most for clarity)

@@ -404,13 +411,14 @@ const getOsModel = function (
*/
async function getAvailableOsVersions(
deviceTypes: string[] | string,
options?: { includeDraft?: boolean },
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this and line 900 should be the options that _memoizedGetAllOsVersions expects for its second parameter

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Moreover _memoizedGetAllOsVersions is used by both getAvailableOsVersions & getAllOsVersions.
Till now I couldn't find a nice way to combine them :(

Copy link
Member

Choose a reason for hiding this comment

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

Nothing changed? Just reformatted?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes :)

expect(draftVersions).to.have.lengthOf(0);
});

it('should include draft OS versions when the respective flag is not used [string device type argument]', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it('should include draft OS versions when the respective flag is not used [string device type argument]', async () => {
it('should include draft OS versions when the respective flag is used [string device type argument]', async () => {

@myarmolinsky myarmolinsky marked this pull request as draft January 23, 2024 13:34
auto-merge was automatically disabled January 23, 2024 13:34

Pull request was converted to draft

@myarmolinsky
Copy link
Member

LGTM

@thgreasi thgreasi marked this pull request as ready for review January 23, 2024 14:10
@thgreasi thgreasi merged commit 5318a7b into master Jan 23, 2024
50 checks passed
@thgreasi thgreasi deleted the draft-hup branch January 23, 2024 14:36
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.

4 participants