Search code examples
continuous-integrationelixirex-unit

How do I fail the CI when there is an `@tag` in a test?


We often have comments in our code review that tells people to remove their @tag from tests they had tagged to have a tighter iteration loop. However, I think that is a waste to have depend on humans to make those comments.

Is there some option for mix test, credo or some other tool that exists to detect @tag in tests?


Solution

  • You can try this bash spell:

    ! grep -R --include="*.exs" "@tag" test
    

    It basically greps for all instances of the pattern @tag in the directory test (because of the -R). The ! negates the exit code, so it succeeds when grep finds nothing and fails if it finds something. Most CIs should fail when any command in the script fails, so this might suit your bill.