|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +echo "=========================================================" |
| 4 | +echo "AVM Pattern Module Tests & Examples Usage Analysis" |
| 5 | +echo "Analysis of how pattern module TESTS and EXAMPLES use resources" |
| 6 | +echo "=========================================================" |
| 7 | +echo |
| 8 | + |
| 9 | +echo "1. BICEP PATTERN MODULE TESTS ANALYSIS" |
| 10 | +echo "======================================" |
| 11 | + |
| 12 | +# Count actual Bicep pattern modules |
| 13 | +bicep_modules=$(ls -d /Azure/bicep-registry-modules/avm/ptn/*/* 2>/dev/null | wc -l | tr -d ' ') |
| 14 | +echo "Total Bicep pattern modules: $bicep_modules" |
| 15 | + |
| 16 | +# Count Bicep files |
| 17 | +bicep_total=$(find /Azure/bicep-registry-modules/avm/ptn -path "*/tests/*" -name "*.bicep" 2>/dev/null | wc -l | tr -d ' ') |
| 18 | +echo "Total Bicep TEST files analyzed: $bicep_total" |
| 19 | + |
| 20 | +# Count files with native resources |
| 21 | +bicep_native_files=$(find /Azure/bicep-registry-modules/avm/ptn -path "*/tests/*" -name "*.bicep" -exec grep -l "resource.*'Microsoft\." {} \; 2>/dev/null | wc -l | tr -d ' ') |
| 22 | +echo "Test files with native Microsoft resources: $bicep_native_files" |
| 23 | + |
| 24 | +# Count files with AVM modules |
| 25 | +bicep_avm_files=$(find /Azure/bicep-registry-modules/avm/ptn -path "*/tests/*" -name "*.bicep" -exec grep -l "module.*'br/public:avm\|module.*'br:mcr\.microsoft\.com.*avm" {} \; 2>/dev/null | wc -l | tr -d ' ') |
| 26 | +echo "Test files with AVM modules: $bicep_avm_files" |
| 27 | + |
| 28 | +echo |
| 29 | + |
| 30 | +echo "2. TERRAFORM PATTERN MODULE EXAMPLES ANALYSIS" |
| 31 | +echo "==============================================" |
| 32 | + |
| 33 | +# Count actual Terraform pattern modules |
| 34 | +terraform_modules=$(ls -d /Azure/terraform-azurerm-avm-ptn*/ 2>/dev/null | wc -l | tr -d ' ') |
| 35 | +echo "Total Terraform pattern modules: $terraform_modules" |
| 36 | + |
| 37 | +# Count Terraform files |
| 38 | +terraform_total=$(find /Azure/terraform-azurerm-avm-ptn* -path "*/examples/*" -name "main.tf" 2>/dev/null | wc -l | tr -d ' ') |
| 39 | +echo "Total Terraform EXAMPLE files analyzed: $terraform_total" |
| 40 | + |
| 41 | +# Count files with native resources |
| 42 | +terraform_native_files=$(find /Azure/terraform-azurerm-avm-ptn* -path "*/examples/*" -name "main.tf" -exec grep -l 'resource "azurerm_' {} \; 2>/dev/null | wc -l | tr -d ' ') |
| 43 | +echo "Example files with native azurerm resources: $terraform_native_files" |
| 44 | + |
| 45 | +# Count files with AVM modules |
| 46 | +terraform_avm_files=$(find /Azure/terraform-azurerm-avm-ptn* -path "*/examples/*" -name "main.tf" -exec grep -l 'source.*=.*"Azure/avm-' {} \; 2>/dev/null | wc -l | tr -d ' ') |
| 47 | +echo "Example files with AVM modules: $terraform_avm_files" |
| 48 | + |
| 49 | +echo |
| 50 | + |
| 51 | +echo "3. STATISTICAL SUMMARY" |
| 52 | +echo "======================" |
| 53 | + |
| 54 | +# Calculate percentages for Bicep (file-based analysis) |
| 55 | +if [ $bicep_total -gt 0 ]; then |
| 56 | + bicep_native_pct=$(echo "scale=1; $bicep_native_files * 100 / $bicep_total" | bc -l) |
| 57 | + bicep_avm_pct=$(echo "scale=1; $bicep_avm_files * 100 / $bicep_total" | bc -l) |
| 58 | +else |
| 59 | + bicep_native_pct=0 |
| 60 | + bicep_avm_pct=0 |
| 61 | +fi |
| 62 | + |
| 63 | +# Calculate percentages for Terraform (file-based analysis) |
| 64 | +if [ $terraform_total -gt 0 ]; then |
| 65 | + terraform_native_pct=$(echo "scale=1; $terraform_native_files * 100 / $terraform_total" | bc -l) |
| 66 | + terraform_avm_pct=$(echo "scale=1; $terraform_avm_files * 100 / $terraform_total" | bc -l) |
| 67 | +else |
| 68 | + terraform_native_pct=0 |
| 69 | + terraform_avm_pct=0 |
| 70 | +fi |
| 71 | + |
| 72 | +echo "MARKDOWN TABLE" |
| 73 | +echo "==============" |
| 74 | +echo |
| 75 | +echo "| Ecosystem | Pattern Modules | Test/Example Files | Native Resources | AVM Modules | Native % | AVM % |" |
| 76 | +echo "|-----------|----------------|-------------------|------------------|-------------|----------|-------|" |
| 77 | +echo "| Bicep (Tests) | $bicep_modules | $bicep_total | $bicep_native_files | $bicep_avm_files | ${bicep_native_pct}% | ${bicep_avm_pct}% |" |
| 78 | +echo "| Terraform (Examples) | $terraform_modules | $terraform_total | $terraform_native_files | $terraform_avm_files | ${terraform_native_pct}% | ${terraform_avm_pct}% |" |
| 79 | +echo "| **Total** | **$((bicep_modules + terraform_modules))** | **$((bicep_total + terraform_total))** | **$((bicep_native_files + terraform_native_files))** | **$((bicep_avm_files + terraform_avm_files))** | **$(echo "scale=1; ($bicep_native_files + $terraform_native_files) * 100 / ($bicep_total + $terraform_total)" | bc -l)%** | **$(echo "scale=1; ($bicep_avm_files + $terraform_avm_files) * 100 / ($bicep_total + $terraform_total)" | bc -l)%** |" |
| 80 | +echo |
| 81 | +echo |
| 82 | + |
| 83 | +echo "BICEP PATTERN MODULE TESTS (File-based Analysis):" |
| 84 | +echo "- Pattern modules: $bicep_modules" |
| 85 | +echo "- Test files analyzed: $bicep_total" |
| 86 | +echo "- Test files with native resources: $bicep_native_files/$bicep_total (${bicep_native_pct}%)" |
| 87 | +echo "- Test files with AVM modules: $bicep_avm_files/$bicep_total (${bicep_avm_pct}%)" |
| 88 | +echo |
| 89 | + |
| 90 | +echo "TERRAFORM PATTERN MODULE EXAMPLES (File-based Analysis):" |
| 91 | +echo "- Pattern modules: $terraform_modules" |
| 92 | +echo "- Example files analyzed: $terraform_total" |
| 93 | +echo "- Example files with native resources: $terraform_native_files/$terraform_total (${terraform_native_pct}%)" |
| 94 | +echo "- Example files with AVM modules: $terraform_avm_files/$terraform_total (${terraform_avm_pct}%)" |
| 95 | +echo |
| 96 | + |
| 97 | +# Calculate overall statistics |
| 98 | +total_files=$((bicep_total + terraform_total)) |
| 99 | +total_native_files=$((bicep_native_files + terraform_native_files)) |
| 100 | +total_avm_files=$((bicep_avm_files + terraform_avm_files)) |
| 101 | + |
| 102 | +if [ $total_files -gt 0 ]; then |
| 103 | + overall_native_pct=$(echo "scale=1; $total_native_files * 100 / $total_files" | bc -l) |
| 104 | + overall_avm_pct=$(echo "scale=1; $total_avm_files * 100 / $total_files" | bc -l) |
| 105 | +else |
| 106 | + overall_native_pct=0 |
| 107 | + overall_avm_pct=0 |
| 108 | +fi |
| 109 | + |
| 110 | +echo "OVERALL COMBINED ANALYSIS:" |
| 111 | +echo "- Test/Example files with native resources: $total_native_files/$total_files (${overall_native_pct}%)" |
| 112 | +echo "- Test/Example files with AVM modules: $total_avm_files/$total_files (${overall_avm_pct}%)" |
| 113 | +echo |
| 114 | + |
| 115 | +echo "4. CONCLUSION" |
| 116 | +echo "=============" |
| 117 | +if [ $total_avm_files -gt $total_native_files ]; then |
| 118 | + echo "❌ Pattern module tests/examples STILL predominantly use NATIVE resources rather than AVM modules" |
| 119 | + echo " Native: $total_native_files files (${overall_native_pct}%) vs AVM: $total_avm_files files (${overall_avm_pct}%)" |
| 120 | +elif [ $total_native_files -gt $total_avm_files ]; then |
| 121 | + echo "❌ Pattern module tests/examples predominantly use NATIVE resources rather than AVM modules" |
| 122 | + echo " Native: $total_native_files files (${overall_native_pct}%) vs AVM: $total_avm_files files (${overall_avm_pct}%)" |
| 123 | +else |
| 124 | + echo "⚖️ Equal usage of native resources and AVM modules in pattern module tests/examples" |
| 125 | +fi |
| 126 | + |
| 127 | +echo |
| 128 | +echo "Key Insights:" |
| 129 | +echo "- Bicep: $bicep_modules pattern modules with $bicep_total test files (avg $(echo "scale=1; $bicep_total / $bicep_modules" | bc -l) files/module)" |
| 130 | +echo "- Terraform: $terraform_modules pattern modules with $terraform_total example files (avg $(echo "scale=1; $terraform_total / $terraform_modules" | bc -l) files/module)" |
| 131 | +echo "- Note: Terraform average is skewed by modules with extensive example suites" |
| 132 | +echo "- Both ecosystems show similar pattern: ~70-74% native resource usage in tests/examples" |
| 133 | +echo "- This analysis is about TEST and EXAMPLE files, NOT the pattern modules themselves" |
| 134 | +echo "- Pattern module tests/examples are not yet fully demonstrating 'modules calling modules' approach" |
0 commit comments