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

Upgrade to Phoenix 1.7 #3615

Merged
merged 15 commits into from
Feb 7, 2024

Conversation

marvelm
Copy link
Contributor

@marvelm marvelm commented Jan 15, 2024

Overview

First off of all, thank you for making and maintaining this project! It's extremely useful to me. I'm really happy that it's written in Elixir because I can actually help out 😄

I noticed that the project is still using Phoenix 1.6. I followed the upgrade guide and it was very simple.

I also made a bunch of changes to get rid of all the compile-time warnings.

Testing

I'm not quite sure how to QA these changes. Maybe we could come up with a checklist together?

Copy link

netlify bot commented Jan 15, 2024

Deploy Preview for teslamate ready!

Name Link
🔨 Latest commit c0672f3
🔍 Latest deploy log https://app.netlify.com/sites/teslamate/deploys/65c3c9b506da7c0008eb15e5
😎 Deploy Preview https://deploy-preview-3615--teslamate.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 configuration.

@marvelm marvelm changed the title Upgrade phoenix 1.7 Upgrade to Phoenix 1.7 Jan 15, 2024
@JakobLichterfeld
Copy link
Collaborator

JakobLichterfeld commented Jan 19, 2024

Thanks for your work! At least all 321 test cases still pass :-)

@JakobLichterfeld JakobLichterfeld added the area:teslamate Related to TeslaMate core label Jan 19, 2024
Copy link
Collaborator

@JakobLichterfeld JakobLichterfeld left a comment

Choose a reason for hiding this comment

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

lgtm

@JakobLichterfeld
Copy link
Collaborator

JakobLichterfeld commented Jan 19, 2024

Test cases pass, but linting failed, please format the files correctly, see https://github.com/teslamate-org/teslamate/actions/runs/7523079638/job/20657593930?pr=3615#step:12:9

Copy link
Collaborator

@JakobLichterfeld JakobLichterfeld left a comment

Choose a reason for hiding this comment

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

Please lint properly

@marvelm
Copy link
Contributor Author

marvelm commented Jan 21, 2024

Thanks for reviewing @JakobLichterfeld

CI is passing now.

@JakobLichterfeld JakobLichterfeld added the note:needs investigation The issue must be investigated first label Jan 22, 2024
@JakobLichterfeld
Copy link
Collaborator

@JakobLichterfeld
Copy link
Collaborator

@brianmay can you help with the outdated pot file? https://github.com/teslamate-org/teslamate/actions/runs/7767265925/job/21183920267?pr=3615#step:10:11

Running mix gettext.extract --merge manually works fine.

@brianmay
Copy link
Collaborator

brianmay commented Feb 4, 2024

I am not going to be able to update this PR as is, I probably don't have access to the source repo.

Apologies if I misunderstood something here ;-)

@JakobLichterfeld
Copy link
Collaborator

JakobLichterfeld commented Feb 4, 2024

I am not going to be able to update this PR as is, I probably don't have access to the source repo.

I was able to merge our master into his repo.

Apologies if I misunderstood something here ;-)

Do you have a hint how to solve the outdated pot warning?

@brianmay
Copy link
Collaborator

brianmay commented Feb 4, 2024

The mix gettext.extract --merge command is probably a good start... Looks like some new messages have been added.

But I am a bit puzzled why we aren't getting errors from the master branch. Unless something is wrong with the pot checks there.

@JakobLichterfeld
Copy link
Collaborator

I linted the files correctly.
@marvelm please fix the test: https://github.com/teslamate-org/teslamate/actions/runs/7789209181/job/21240291062?pr=3615#step:10:73
Not sure, why it is expecting 4.32kWh instead of 4.32 kWh

and the Linting warning about the uncalled function: https://github.com/teslamate-org/teslamate/actions/runs/7789209181/job/21240291393?pr=3615#step:16:34

@brianmay
Copy link
Collaborator

brianmay commented Feb 7, 2024

I think that uncalled function warning is a false warning, fetch_settings is used as a plug. Not sure how to make it happy here. Maybe I missed something.

@brianmay
Copy link
Collaborator

brianmay commented Feb 7, 2024

The other error, I think there is a missing space in the template:

diff --git a/lib/teslamate_web/live/car_live/summary.html.heex b/lib/teslamate_web/live/car_live/summary.html.heex
index 70d0b72f..ae9632b1 100644
--- a/lib/teslamate_web/live/car_live/summary.html.heex
+++ b/lib/teslamate_web/live/car_live/summary.html.heex
@@ -272,7 +272,7 @@
             <%= unless is_nil(@summary.charge_energy_added) do %>
               <tr>
                 <td class="has-text-weight-medium"><%= gettext("Charged") %></td>
-                <td><%= @summary.charge_energy_added %>kWh</td>
+                <td><%= @summary.charge_energy_added %> kWh</td>
               </tr>
             <% end %>
             <%= unless is_nil(@summary.charger_power) do %>

This appears to have happened in the "mix format" commit. I can't reproduce this, but something we may need to watch out for.

@brianmay
Copy link
Collaborator

brianmay commented Feb 7, 2024

Possible solution to the unused function problem, just make the function public:

diff --git a/lib/teslamate_web/router.ex b/lib/teslamate_web/router.ex
index 246b47fa..f00d9ea0 100644
--- a/lib/teslamate_web/router.ex
+++ b/lib/teslamate_web/router.ex
@@ -54,7 +54,7 @@ defmodule TeslaMateWeb.Router do
     put "/car/:id/logging/suspend", CarController, :suspend_logging
   end

-  defp fetch_settings(conn, _opts) do
+  def fetch_settings(conn, _opts) do
     settings = Settings.get_global_settings!()

     conn

@JakobLichterfeld
Copy link
Collaborator

Giving up on this. A whitespace result in test failing, using the unicode character result in failed lint. Assume we need to adopt the test to use the whitespace

@brianmay
Copy link
Collaborator

brianmay commented Feb 7, 2024

It looks like that worked. Maybe the tests require the unicode whitespace character.

@JakobLichterfeld
Copy link
Collaborator

Using whitespace in html and in test instead of nbsp unicode finally works.

@JakobLichterfeld JakobLichterfeld merged commit da81905 into teslamate-org:master Feb 7, 2024
12 checks passed
JakobLichterfeld added a commit that referenced this pull request Feb 9, 2024
* Upgrade to phoenix 1.7.0
The minimal changes necessary to compile the application

* Import Phoenix.Component instead of LiveView

* Fix compilation warnings

* mix format

* Update tests to trim newline characters

* mix gettext.extract --merge

* style: correct linting

* rebuild gettext

* fix: correct spacing before unit for energy added

* fix: use unicode character for whitespace

* fix: spacing with witespace

* fix: use numeric value for charge_energy_added in charging test

* fix: avoid warning about unsued function, which is actually used in plug

* fix: use whitespace in test before charge_energy_added

---------

Co-authored-by: JakobLichterfeld <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:teslamate Related to TeslaMate core note:needs investigation The issue must be investigated first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants