Skip to content

Commit

Permalink
Support CLI diagnose options for releases
Browse files Browse the repository at this point in the history
When an Elixir app is made into a release with `mix release` it's more
difficult to run the diagnose command. A user needs to eval this
command:

```
bin/your_app eval ":appsignal_tasks.diagnose()"
```

It's not possible to pass along `--send-report` this way, because it
will be will ignored for some reason.

To allow for the options to be available for this method of calling the
diagnose command, allow the Mix task (that's being called this way) to
receive arguments and pass them to the Diagnose module, like how it
would be done if one would call `mix appsignal.diagnose --send-report`.

This change is necessary for the diagnose tests
(https://github.com/appsignal/diagnose_tests) test suite, because we
need to run the diagnose from a released app. If we'd run a unreleased
app the AppSignal package would recompile on every run, making it
impossible to overwrite the install and download reports for testing.
  • Loading branch information
tombruijn committed Oct 25, 2021
1 parent e71792f commit f7c0b1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .changesets/support-mix-task-diagnose-arguments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
bump: "patch"
---

Support mix task diagnose arguments. When an app is released with `mix release` CLI arguments cannot normally be passed to the diagnose task. Use the `eval` command pass along the CLI arguments as function arguments.

```
mix format
# Without arguments
bin/your_app eval ':appsignal_tasks.diagnose()'
# With arguments
bin/your_app eval ':appsignal_tasks.diagnose(["--send-report"])'
```
4 changes: 2 additions & 2 deletions lib/appsignal/utils/tasks.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule :appsignal_tasks do
@moduledoc false
def diagnose do
Mix.Tasks.Appsignal.Diagnose.run(nil)
def diagnose(args \\ []) do
Mix.Tasks.Appsignal.Diagnose.run(args)
:init.stop()
end

Expand Down

0 comments on commit f7c0b1e

Please sign in to comment.