/Scripts/validate-local.sh

https://github.com/LambdaSharp/LambdaSharpTool · Shell · 157 lines · 118 code · 31 blank · 8 comment · 13 complexity · 60b6346485f8c84be0155952a65e36b5 MD5 · raw file

  1. #!/bin/bash
  2. if [ -z "$LAMBDASHARP" ]; then
  3. echo "ERROR: environment variable \$LAMBDASHARP is not set"
  4. exit 1
  5. fi
  6. # Validate λ# Release
  7. cd $LAMBDASHARP
  8. UNCOMMITTED=$(git status --porcelain 2>/dev/null| egrep "^(M| M)" | wc -l)
  9. if [ $UNCOMMITTED -ne "0" ]; then
  10. echo "ERROR: found $UNCOMMITTED uncommitted files"
  11. exit 1
  12. fi
  13. # Check if any "TODO:" comments are present (using ripgrep: https://github.com/BurntSushi/ripgrep)
  14. if rg -q 'TODO:' -g '!*.{js,map,sh}'; then
  15. echo "ERROR: found files with 'TODO:' comment"
  16. rg 'TODO:' -g '!*.{js,map,sh}'
  17. exit
  18. fi
  19. # Setup and validate λ# CLI
  20. Scripts/install-cli.sh
  21. if [ $? -ne 0 ]; then
  22. exit $?
  23. fi
  24. echo "***********************************"
  25. echo "*** Run Module Generation Tests ***"
  26. echo "***********************************"
  27. git update-index -q --refresh
  28. if ! git diff-index --quiet HEAD -- Tests/; then
  29. git diff-index --name-only HEAD -- Tests/
  30. echo "ERROR: found changes in Tests/ folder BEFORE running tests"
  31. exit 1
  32. fi
  33. Scripts/run-tests.sh
  34. if [ $? -ne 0 ]; then
  35. exit $?
  36. fi
  37. git update-index -q --refresh
  38. if ! git diff-index --quiet HEAD -- Tests/; then
  39. git diff-index --name-only HEAD -- Tests/
  40. echo "ERROR: found changes in Tests/ folder AFTER running tests"
  41. exit 1
  42. fi
  43. UNCOMMITTED=$(git status --porcelain 2>/dev/null| egrep "^(M| M)" | wc -l)
  44. if [ $UNCOMMITTED -ne "0" ]; then
  45. echo "ERROR: found $UNCOMMITTED uncommitted files"
  46. exit 1
  47. fi
  48. echo "************************"
  49. echo "*** Init LambdaSharp ***"
  50. echo "*************************"
  51. cd $LAMBDASHARP
  52. SUFFIX=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)
  53. export LAMBDASHARP_TIER=TestContrib$SUFFIX
  54. echo "Creating test tier: $LAMBDASHARP_TIER"
  55. lash init \
  56. --quick-start \
  57. --core-services enabled \
  58. --verbose:exceptions
  59. if [ $? -ne 0 ]; then
  60. exit $?
  61. fi
  62. echo "*********************"
  63. echo "*** Build Samples ***"
  64. echo "*********************"
  65. cd $LAMBDASHARP/Samples
  66. lash build `find . -name "Module.yml"`
  67. if [ $? -ne 0 ]; then
  68. exit $?
  69. fi
  70. echo "********************"
  71. echo "*** Build Demos ***"
  72. echo "********************"
  73. cd $LAMBDASHARP/Demos
  74. lash build `find . -name "Module.yml"`
  75. if [ $? -ne 0 ]; then
  76. exit $?
  77. fi
  78. echo "****************************"
  79. echo "*** Build Legacy Modules ***"
  80. echo "****************************"
  81. cd $LAMBDASHARP/Tests/Legacy
  82. lash build `find . -name "Module.yml"`
  83. if [ $? -ne 0 ]; then
  84. exit $?
  85. fi
  86. # Deploy all λ# Sample Modules
  87. echo "**********************"
  88. echo "*** Deploy Samples ***"
  89. echo "**********************"
  90. cd $LAMBDASHARP
  91. lash deploy \
  92. --verbose:exceptions \
  93. Samples/AlexaSample/bin/cloudformation.json \
  94. Samples/ApiSample/bin/cloudformation.json \
  95. Samples/ApiInvokeSample/bin/cloudformation.json \
  96. Samples/ApiInvokeAssemblySample/bin/cloudformation.json \
  97. Samples/BlazorEventsSample/bin/cloudformation.json \
  98. Samples/BlazorSample/bin/cloudformation.json \
  99. Samples/CustomResourceTypeSample/bin/cloudformation.json \
  100. Samples/DynamoDBSample/bin/cloudformation.json \
  101. Samples/EventSample/bin/cloudformation.json \
  102. Samples/FinalizerSample/bin/cloudformation.json \
  103. Samples/JsonSerializerSample/bin/cloudformation.json \
  104. Samples/KinesisFirehoseSample/bin/cloudformation.json \
  105. Samples/KinesisSample/bin/cloudformation.json \
  106. Samples/LambdaLayerSample/bin/cloudformation.json \
  107. Samples/LambdaSelfContainedSample/bin/cloudformation.json \
  108. Samples/MacroSample/bin/cloudformation.json \
  109. Samples/MetricSample/bin/cloudformation.json \
  110. Samples/S3IOSample/bin/cloudformation.json \
  111. Samples/S3SubscriptionSample/bin/cloudformation.json \
  112. Samples/ScheduleSample/bin/cloudformation.json \
  113. Samples/SlackCommandSample/bin/cloudformation.json \
  114. Samples/SnsSample/bin/cloudformation.json \
  115. Samples/SqsSample/bin/cloudformation.json \
  116. Samples/WebSocketSample/bin/cloudformation.json
  117. # skipping this sample since it requires a VPC
  118. # Samples/VpcFunctionSample/bin/manifest.json
  119. if [ $? -ne 0 ]; then
  120. exit $?
  121. fi
  122. # Create a Default λ# Module and Deploy it
  123. echo "*****************************"
  124. echo "*** Deploy Default Module ***"
  125. echo "*****************************"
  126. Scripts/test-new-module.sh