excoveralls
excoveralls copied to clipboard
Github actions fail on scheduled workflows
When you try to run mix coveralls.github
in workflows that are scheduled using cron
schedule (https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule) you get a following error:
** (BadMapError) expected a map, got: nil
(elixir 1.13.3) lib/map.ex:481: Map.get(nil, "login", nil)
Warning: (excoveralls 0.14.4) lib/excoveralls/github.ex:93: ExCoveralls.Github.git_info/0
(excoveralls 0.14.4) lib/excoveralls/github.ex:25: ExCoveralls.Github.generate_json/2
Warning: (excoveralls 0.14.4) lib/excoveralls/github.ex:8: ExCoveralls.Github.execute/2
(mix 1.13.3) lib/mix/tasks/test.ex:538: Mix.Tasks.Test.do_run/3
Warning: (mix 1.13.3) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
(mix 1.13.3) lib/mix/task.ex:451: Mix.Task.run_alias/5
Warning: (mix 1.13.3) lib/mix/task.ex:455: Mix.Task.run_alias/5
(excoveralls 0.14.4) lib/mix/tasks.ex:54: Mix.Tasks.Coveralls.do_run/2
Warning: (mix 1.13.3) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
(mix 1.13.3) lib/mix/cli.ex:84: Mix.CLI.run_task/2
Warning: (elixir 1.13.3) lib/code.ex:1183: Code.require_file/2
The reason for this is we are trying to read GITHUB_EVENT_PATH
file which contains event payload, but the payload doesn't contain anything much in workflows scheduled like this. The file contains basically something like this only:
{
"schedule": "*/10 * * * *"
}
To fix this we should fallback to other ways of getting information for functions:
-
get_pr_id
-
get_committer_name
-
get_sha