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

feat: Add endpoint showing the currently-deployed version #2549

Merged
merged 6 commits into from
Apr 22, 2024

Conversation

joshlarson
Copy link
Contributor

@joshlarson joshlarson commented Apr 22, 2024


use SkateWeb, :controller

def version(conn, _params) do
send_resp(conn, 200, Application.get_env(:skate, :version))
Copy link
Member

@firestack firestack Apr 22, 2024

Choose a reason for hiding this comment

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

suggestion(non-blocking): IMO it's more useful to get this at compile time than runtime. I dunno about testing here though...

Suggested change
send_resp(conn, 200, Application.get_env(:skate, :version))
send_resp(conn, :ok, Application.compile_env(:skate, :version))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got 👇 error 😭

(RuntimeError) Application.compile_env/3 cannot be called inside functions, only in the module body

Copy link
Member

Choose a reason for hiding this comment

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

use SkateWeb, :controller

def version(conn, _params) do
send_resp(conn, 200, Application.get_env(:skate, :version))
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
send_resp(conn, 200, Application.get_env(:skate, :version))
send_resp(conn, :ok, Application.get_env(:skate, :version))

@joshlarson
Copy link
Contributor Author

Seems to work - that's cool!

https://skate-dev-blue.mbtace.com/version

Copy link

Coverage of commit b545ea2

Summary coverage rate:
  lines......: 93.9% (3224 of 3433 lines)
  functions..: 73.7% (1339 of 1816 functions)
  branches...: no data found

Files changed coverage rate:
                                                                  |Lines       |Functions  |Branches    
  Filename                                                        |Rate     Num|Rate    Num|Rate     Num
  ======================================================================================================
  lib/skate_web/controllers/version_controller.ex                 | 100%      3|85.7%     7|    -      0
  lib/skate_web/router.ex                                         |93.2%     59|15.8%   133|    -      0

Download coverage report

Comment on lines 3 to 6

def version(conn, _params) do
send_resp(conn, 200, Application.get_env(:skate, :version))
end
Copy link
Member

@firestack firestack Apr 22, 2024

Choose a reason for hiding this comment

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

https://github.com/mbta/skate/pull/2549/files/cf37dce0f0efb749a5224ce7f4f892e7717dd15b#r1575376527

Suggested change
def version(conn, _params) do
send_resp(conn, 200, Application.get_env(:skate, :version))
end
@version Application.compile_env(:skate, :version)
def version(conn, _params) do
send_resp(conn, :ok, @version)
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah... that does mess up the tests though. I guess the value of testing this endpoint at all is pretty minimal though 🙃

Copy link

Coverage of commit 3bb9f5c

Summary coverage rate:
  lines......: 93.9% (3224 of 3433 lines)
  functions..: 73.7% (1339 of 1816 functions)
  branches...: no data found

Files changed coverage rate:
                                                                  |Lines       |Functions  |Branches    
  Filename                                                        |Rate     Num|Rate    Num|Rate     Num
  ======================================================================================================
  lib/skate_web/controllers/version_controller.ex                 | 100%      3|85.7%     7|    -      0
  lib/skate_web/router.ex                                         |93.2%     59|15.8%   133|    -      0

Download coverage report

config/config.exs Outdated Show resolved Hide resolved
Co-authored-by: Kayla Firestack <firestack@users.noreply.github.com>
Copy link

Coverage of commit e0b025f

Summary coverage rate:
  lines......: 93.8% (3220 of 3433 lines)
  functions..: 73.4% (1333 of 1816 functions)
  branches...: no data found

Files changed coverage rate:
                                                                  |Lines       |Functions  |Branches    
  Filename                                                        |Rate     Num|Rate    Num|Rate     Num
  ======================================================================================================
  lib/skate_web/controllers/version_controller.ex                 | 0.0%      3| 0.0%     7|    -      0
  lib/skate_web/router.ex                                         |91.5%     59|15.8%   133|    -      0

Download coverage report

@joshlarson joshlarson merged commit 0657753 into main Apr 22, 2024
9 checks passed
@joshlarson joshlarson deleted the jdl/feat/version-endpoint branch April 22, 2024 22:17
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.

2 participants