Skip to content

Instantly share code, notes, and snippets.

@maskati
Created March 24, 2025 11:21
Show Gist options
  • Save maskati/9c872bda6702951029739bc5bf66d7b9 to your computer and use it in GitHub Desktop.
Save maskati/9c872bda6702951029739bc5bf66d7b9 to your computer and use it in GitHub Desktop.
Faster linting of multiple Bicep files

Bicep v0.34.1 brings many great features to Bicep. One that I think is underrated by not having it as a highlighted feature is the new --pattern argument for faster batch operations on multiple files. Below is a comparison of a simulated linting of 100 Bicep files using a parallel invocation of bicep lint vs a single invocation of bicep lint --pattern. The difference is dramatic, with pattern based linting being 40 times faster in clock time on a 4 core system, and 261 times faster in CPU usage. I typically lint all Bicep files that are part of an IaC repository to ensure that module changes do not break upstream or downstream dependencies. This change will allow you to save CI runner resources and have your IaC PR checks completed faster.

> docker run --rm -it alpine /bin/sh -c 'apk add -q --no-progress libstdc++ icu-libs icu-data-full parallel && wget -qO /usr/local/bin/bicep https://github.com/Azure/bicep/releases/download/v0.34.1/bicep-linux-musl-x64 && chmod +x /usr/local/bin/bicep && for i in $(seq 1 100); do mkdir "/tmp/${i}" && printf "param i int = ${i}" > "/tmp/${i}/bicep${i}.bicep"; done && time parallel bicep lint {} ::: /tmp/**/*.bicep'

real    1m 14.78s
user    8m 48.29s
sys     0m 41.62s
> docker run --rm -it alpine /bin/sh -c 'apk add -q --no-progress libstdc++ icu-libs icu-data-full parallel && wget -qO /usr/local/bin/bicep https://github.com/Azure/bicep/releases/download/v0.34.1/bicep-linux-musl-x64 && chmod +x /usr/local/bin/bicep && for i in $(seq 1 100); do mkdir "/tmp/${i}" && printf "param i int = ${i}" > "/tmp/${i}/bicep${i}.bicep"; done && time bicep lint --pattern "/tmp/**/*.bicep"'

real    0m 1.83s
user    0m 2.02s
sys     0m 0.16s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment