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

Show current version at bottom of admin dashboard #11004

Merged
merged 1 commit into from
Jun 15, 2023

Conversation

dacook
Copy link
Member

@dacook dacook commented Jun 14, 2023

Closes #577.

With generic link to the releases page. We could provide a link to latest tag with git describe --tags --abbrev=0. But I thought it better to keep things simple.

This is visible to any admins.

I considered using view caching, but concluded that it wasn't worth it. When a deployment is made, I'm not sure that the cache is cleared. So we'd need to add a cache key based on the git reference. Which requires another system call to retrieve, which defeats the point of caching.

What? Why?

Most people don't have access to check this on the server, so this allows them to confirm at any time.

Also, sometimes a lot of time can be lost debugging an issue, without realising the platform is running on an older version where the but has been fixed (like yesterday!)

Screen Shot 2023-06-14 at 9 42 21 am
Screen Shot 2023-06-14 at 9 44 40 am
Screen Shot 2023-06-14 at 9 47 53 am
Screen Shot 2023-06-14 at 9 48 30 am

What should we test?

  • Go to the dashboard for a single or multi enterprise user.
  • view the version at the bottom
    • on production, this would show something like "v4.3.12-modified"
    • on staging where we've deployed a PR, it would look like "v4.3.11-182-g61baabb1f-modified"
  • click on the version, to open up the releases page in a new tab.

Release notes

Changelog Category: 👀 User facing changes

The title of the pull request will be included in the release notes.

@sigmundpetersen
Copy link
Contributor

Nice. This may actually close one of our ancient issues. I had to re-open 😄

@@ -0,0 +1,3 @@
%a{href:"https://github.com/openfoodfoundation/openfoodnetwork/releases", target: "_blank", title: t('.view_all_releases')}
=# Show the latest tag. If there are commits since the tag, show number of commits and an identifier. If the working tree is dirty, show 'modified'.
= `git describe --tags --dirty=-modified`
Copy link
Contributor

Choose a reason for hiding this comment

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

oh wahoo. I didn't know this was actually possible: running git in our view!
I don't have any better suggestion for now (maybe put in a controller ?) as it seems that we don't package a release.

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, it does feel a bit wrong.. but I think to change it would just be more work and obfuscate it further without any benefit.

@dacook
Copy link
Member Author

dacook commented Jun 15, 2023

Nice. This may actually close one of our ancient issues. I had to re-open 😄

Thank you for that link!

I took a look at the comments and I like Maikel's suggestion, which is a bit more work, but would might enable us to cache (rather than make a system call on every request to the dashboard page).

I don't think caching is important here, so I won't bother updating it for now.

@dacook dacook self-assigned this Jun 15, 2023
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

Great! Looking back at my old comment I would consider an initializer which runs git describe > public/VERSION. That way we can query the version even if the app completely crashes, or like a public API. And the view could render it like a partial, maybe.

@Matt-Yorkley
Copy link
Contributor

Matt-Yorkley commented Jun 15, 2023

Agree it should either go in an initializer or in application.rb so it gets called once when the app boots. There's an invisible newline character (\n) that gets added as well, it might be nice to trim it. That value could be useful in other contexts at some point.

# config/application.rb

config.x.git_version = `git describe --tags --dirty=-modified | tr -d "\n"`
# overview/_version.html.haml

%a{href: "https://etc..."}
  = Rails.application.config.x.git_version

Copy link
Contributor

@Matt-Yorkley Matt-Yorkley Jun 15, 2023

Choose a reason for hiding this comment

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

The file extension should be .html.haml for this file, right?

@drummer83 drummer83 added the pr-staged-uk staging.openfoodnetwork.org.uk label Jun 15, 2023
@drummer83 drummer83 self-assigned this Jun 15, 2023
@drummer83
Copy link
Contributor

Hi @dacook,
Wow, that's a good one! I have always wondered how to find out the version which is currently being used! I love it! 💚

Before staging

There was no version showing - SURPRISE! 😮

After staging

We now have the version at the bottom of the dashboard.
I checked the single-enterprise and the multi-enterprise dashboard. 👍
However I wonder, why I get v4.3.11 while we have 4.3.12 already? Even after rebasing your PR it changed, but it's still some 4.3.11 version. I just don't understand. Maybe you could explain quickly and merge if you think that everything is ok?

Single-enterprise dashboard:
image

Multi-enterprise dashboard:
image

And what about this file extension? Does it need an update?
image

I'll move it to Ready To Go and leave it for you to merge.
Thanks again! 🎉

@drummer83 drummer83 removed the pr-staged-uk staging.openfoodnetwork.org.uk label Jun 15, 2023
@mkllnk
Copy link
Member

mkllnk commented Jun 15, 2023

I wonder, why I get v4.3.11 while we have 4.3.12 already?

It depends on the tags the server knows about. And that depends on the deployments before. So if you deploy the tag v4.3.12 and then another pull request then it should display that number. But if the server has never seen v4.3.12 then it can't display it.

Or, if you logged into the server and ran git fetch then it would get the latest tag information and then it could display the right version. But it may also be that we create a new release after a deployment and no server would automatically fetch that information.

So, this information isn't as helpful in staging as it is in production where we deploy tags all the time.

With generic link to the releases page. We could provide a link to latest tag with `git describe --tags --abbrev=0`. But I thought it better to keep things simple.
@Matt-Yorkley Matt-Yorkley added the pr-staged-uk staging.openfoodnetwork.org.uk label Jun 15, 2023
@dacook dacook mentioned this pull request Jun 15, 2023
@dacook
Copy link
Member Author

dacook commented Jun 15, 2023

Thanks for explaining Maikel, I have to admit I wouldn't have been able to!

I've fixed up the filename, and specs pass, so I will merge.

@dacook dacook merged commit 47745b5 into openfoodfoundation:master Jun 15, 2023
@mkllnk mkllnk removed the pr-staged-uk staging.openfoodnetwork.org.uk label Jun 16, 2023
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.

Software version can be displayed in the UI or Admin interface
6 participants