DEV Community

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

Posted on

2 2

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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay