DEV Community

Cover image for Add Haml validation to CI/CD
Anatoli Babenia
Anatoli Babenia

Posted on

Add Haml validation to CI/CD

TL;DR

Add this to your .gitlab-ci.yml or whatever CI/CD system you are using.

find . -name "*.haml" -type f -print0 | xargs -0L1 sh -c \
  'for arg do echo -n "$arg .. "; haml --check "$arg"; done' _
Enter fullscreen mode Exit fullscreen mode

Explanation

Use find to find all .haml files in current directory recursively. Pass paths of find files to xargs. Use \0 symbol as file delimiter. For each file, run sh command. In sh command print path of the file and run haml --check on it.

find is necessary, because haml utility is unable to search for files on its own. xargs is needed, because find can not detect if executed program failed. sh is needed, because haml can not report the filename being checked.

Credits

Top comments (0)