push.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. WORKSPACE_FOLDER=$1
  2. VSCODE_FOLDER=$WORKSPACE_FOLDER/.vscode
  3. DEV_ENV=$VSCODE_FOLDER/.devenv
  4. if [ -f $DEV_ENV ]; then
  5. source $DEV_ENV
  6. else
  7. DEV_MODE='normal'
  8. fi
  9. echo "Dev mode: $DEV_MODE"
  10. if [[ 'tcr' = $DEV_MODE ]]; then
  11. git add -u
  12. fi
  13. sfdx force:source:status
  14. sfdx force:source:push
  15. rc=$?
  16. if [[ $rc != 0 ]]; then
  17. if [[ 'tcr' = $DEV_MODE ]]; then
  18. echo "Push failed - reverting"
  19. git reset --hard
  20. fi
  21. exit $rc;
  22. fi
  23. TO_RUN=""
  24. TEST_LIST_FILE="$VSCODE_FOLDER/tests.list"
  25. if [ -f "$TEST_LIST_FILE" ]; then
  26. tests=$(cat $TEST_LIST_FILE | grep -v '#' | paste -sd "," -)
  27. TO_RUN="--tests $tests"
  28. fi
  29. if [[ 'tdd' = $DEV_MODE ]] || [[ 'tcr' = $DEV_MODE ]]; then
  30. sfdx force:apex:test:run \
  31. $TO_RUN \
  32. --codecoverage \
  33. --resultformat human \
  34. --outputdir "$WORKSPACE_FOLDER/.sfdx/tools/testresults/apex" \
  35. --loglevel error
  36. rc=$?
  37. if [[ $rc != 0 ]]; then
  38. echo "Tests RED!"
  39. else
  40. echo "Tests GREEN!"
  41. fi
  42. if [[ 'tcr' = $DEV_MODE ]]; then
  43. if [[ $rc != 0 ]]; then
  44. echo "Tests failed - reverting"
  45. git reset --hard
  46. exit $rc;
  47. fi
  48. echo "Tests passed - committing"
  49. git commit -m '>>> TCR wip'
  50. fi
  51. fi
  52. echo "Sequence finished"