rails-templates icon indicating copy to clipboard operation
rails-templates copied to clipboard

[#350] Fix: Danger cannot find the coverage data on Github review code workflow

Open carryall opened this issue 2 years ago • 2 comments

  • Close #350

What happened 👀

The Danger cannot find the coverage data on the Github Review Code workflow as it runs on a separate workflow from the Test workflow where the coverage data is generated.

Screen Shot 2565-08-05 at 18 25 37

So this PR fixes the issue by

  • Move the code review job into the Test workflow
  • Upload the coverage data to the artifact after the Unit Test job is completed
  • Download the coverage data and run the Danger command

Then after the Danger command can run there's another issue about getting the output from Danger, it seems like it was trying to call the message method from the wrong place (the full log can be found on a public repo where I test it)

Screen Shot 2565-08-08 at 19 23 37

Screen Shot 2565-08-08 at 20 29 07

So I added the workaround on Dangerfile by copying the report method but using the markup method to output the message instead

Insight 📝

⚠️ The Danger Undercover is also using the message method so the same issue happens, it only log the output but does NOT add it to comment

Screen Shot 2565-08-08 at 20 34 39

What we've tried so far on the EWA project is to use wait-on-check action to wait for the Test workflow to finish before running the Review Code workflow but it'll double the cost of the GitHub workflow as the Test and Review Code workflow will run parallelly until the unit test job inside Test workflow is done

Proof Of Work 📹

I opened a public repository with a test PR with the updated workflow and files, Danger works

Screen Shot 2565-08-08 at 20 18 39

In case the Test job fails, the Review Code job also fail Screen Shot 2565-08-11 at 15 21 37 Screen Shot 2565-08-11 at 15 21 22 with this message Screen Shot 2565-08-11 at 15 27 33

carryall avatar Aug 05 '22 11:08 carryall

@carryall I just pushed a small fix so that the tests are passing again (see 9763ba7). Please git pull on your machine before addressing any change ;-)

malparty avatar Aug 18 '22 08:08 malparty

@carryall should we update it as in EWA-Payroll as in the end, we had some issues with the code coverage when not run in the same workflow as the tests...? 🤔

malparty avatar Aug 26 '22 04:08 malparty