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

RSDK-8304 - send version metadata #251

Merged
merged 3 commits into from
Aug 5, 2024
Merged

Conversation

stuqdog
Copy link
Member

@stuqdog stuqdog commented Aug 1, 2024

How it works:

  • update-protos.yml updates the apiTag value in the getVersionMetadata function
  • release.yml updates the sdkVersion value in the getVersionMetadata function
  • channels update their options to set viam_client equal to the output of getVersionMetadata

Note that this is a bit of a bummer because we're storing the SDK version in two places (pubspec.yml and utils.dart). I spent a good amount of time trying to find some alternative whereby we'd get the version info out of pubspec.yml instead. The potential solutions and (seemingly intractable) problems I encountered were:

  • you can't read data out of pubspec.yml directly in a synchronous way, which means that reading pubspec.yml data would require polluting our API with async, which would be a significant breaking change and open tons of new cans of worms.
  • Though it's not recommended, you can just open a file synchronously (i.e., instead of saying "give me pubspec data" we could say "open the file found at pubspec.yml and convert it into a map that I can parse). This seemed promising and tests passed, but the problem I found was the absolute path to pubspec.yml can't be reliably assumed, and setting a relative path meant the file couldn't always be found (it was found successfully for a unit test, but not by the flutter-rc-app running from a sibling directory). So, this approach was too fragile to work.
  • Technically, you can still force an async function in dart to run to completion and block synchronously, meaning we could get the ask for data from the pubspec.yml as per the first option above. But, the function to do so is deprecated, will be removed soon, and its use is strongly discouraged. So that approach is neither future proof nor idiomatic.

Given the above, I opted for the simple and consistent, but sadly duplicative, approach that we wound up with here.

Screenshot 2024-08-01 at 09 27 42

@stuqdog stuqdog marked this pull request as ready for review August 1, 2024 13:43
@stuqdog stuqdog requested a review from a team as a code owner August 1, 2024 13:43
Copy link
Member

@njooma njooma left a comment

Choose a reason for hiding this comment

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

Can we have the make buf command grab the apiTag from this file?

String getVersionMetadata() {
const String sdkVersion = 'v0.0.18';
const String apiTag = 'v0.1.328';
return format('flutter;{};{}', sdkVersion, apiTag);
Copy link
Member

Choose a reason for hiding this comment

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

Don't need the format library -- you can use format strings:

return 'flutter;$sdkVersion;$apiTag'

pubspec.yaml Outdated
@@ -20,6 +20,7 @@ dependencies:
collection: ^1.17.1
async: ^2.11.0
bonsoir: ^5.1.8
format: ^1.5.2
Copy link
Member

Choose a reason for hiding this comment

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

Won't be needed

Comment on lines 37 to 39
- name: Update Proto Tag
run: sed -i -e "s/apiTag = 'v[0-9]*\.[0-9]*\.[0-9]*'/api_tag = '${{ github.event.client_payload.tag }}'" > lib/src/utils.dart

Copy link
Member

Choose a reason for hiding this comment

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

Can we update the proto tag earlier, and then update the Makefile so that it reads the lib/src/utils.dart file and grabs the apiTag, and then generates that specific api tag?

@stuqdog stuqdog requested a review from njooma August 5, 2024 13:51
@stuqdog stuqdog merged commit 699f626 into viamrobotics:main Aug 5, 2024
4 checks passed
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