Skip to content

Commit

Permalink
Update APPSIGNAL_BUILD_FOR_MUSL flag behavior (#653)
Browse files Browse the repository at this point in the history
Currently the APPSIGNAL_BUILD_FOR_MUSL flag listens to any value and
accepts that as meaning that the user intends to install the Linux musl
build.

The defined behavior in the integrations guide specifies that the
APPSIGNAL_BUILD_FOR_MUSL env var should listen to the `1` or `true`
values.

Source:
https://github.com/appsignal/integration-guide/blob/9b6fb1491e3aab87cb29b732470c8162f9cd080b/build/installation.md#appsignal_build_for_musl

Update the APPSIGNAL_BUILD_FOR_MUSL flag to listen to only the `1` and
`true` values as agreed upon.
  • Loading branch information
tombruijn authored Jun 22, 2021
1 parent 3e27666 commit b2c888d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changesets/musl-flag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
bump: "patch"
---

Update `APPSIGNAL_BUILD_FOR_MUSL` behavior to only listen to the values `1` and `true`. This way `APPSIGNAL_BUILD_FOR_MUSL=false` is not interpreted to install the musl build.
3 changes: 2 additions & 1 deletion mix_helpers.exs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ defmodule Mix.Appsignal.Helper do
end

defp force_musl_build? do
!is_nil(System.get_env("APPSIGNAL_BUILD_FOR_MUSL"))
env = System.get_env("APPSIGNAL_BUILD_FOR_MUSL")
env == "1" || env == "true"
end

defp make do
Expand Down
14 changes: 13 additions & 1 deletion test/mix/helpers_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,24 @@ defmodule Mix.Appsignal.HelperTest do
assert Mix.Appsignal.Helper.agent_platform() == "linux"
end

test "returns the musl build when using the APPSIGNAL_BUILD_FOR_MUSL env var" do
test "does not return the musl build when using the APPSIGNAL_BUILD_FOR_MUSL=='' env var" do
with_env(%{"APPSIGNAL_BUILD_FOR_MUSL" => ""}, fn ->
assert Mix.Appsignal.Helper.agent_platform() != "linux-musl"
end)
end

test "returns the musl build when using the APPSIGNAL_BUILD_FOR_MUSL==1 env var" do
with_env(%{"APPSIGNAL_BUILD_FOR_MUSL" => "1"}, fn ->
assert Mix.Appsignal.Helper.agent_platform() == "linux-musl"
end)
end

test "returns the musl build when using the APPSIGNAL_BUILD_FOR_MUSL==true env var" do
with_env(%{"APPSIGNAL_BUILD_FOR_MUSL" => "true"}, fn ->
assert Mix.Appsignal.Helper.agent_platform() == "linux-musl"
end)
end

test "returns the musl build when on a musl system", %{fake_system: fake_system} do
FakeSystem.update(fake_system, :cmd, fn _, _, _ ->
{"musl libc (x86_64)\nVersion 1.1.16", 0}
Expand Down

0 comments on commit b2c888d

Please sign in to comment.