unit_tests.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. name: zzz [DO NOT RUN] Automated unit tests
  2. on:
  3. workflow_dispatch: # TODO: remove this after testing
  4. pull_request:
  5. branches:
  6. - dev
  7. - main
  8. push:
  9. branches:
  10. - dev
  11. - main
  12. jobs:
  13. test:
  14. name: Run Unit Tests
  15. runs-on: macos-15
  16. if: github.repository_owner == 'nightscout'
  17. steps:
  18. - name: Select Xcode version
  19. run: sudo xcode-select -s /Applications/Xcode_16.3.app/Contents/Developer
  20. - name: Checkout code
  21. uses: actions/checkout@v4
  22. with:
  23. fetch-depth: 1
  24. submodules: recursive
  25. - name: Build for testing
  26. run: |
  27. set -o pipefail && \
  28. time xcodebuild build-for-testing \
  29. -workspace Trio.xcworkspace \
  30. -scheme "Trio Tests" \
  31. -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.4' \
  32. - name: Run tests
  33. run: |
  34. set -o pipefail
  35. time xcodebuild test-without-building \
  36. -workspace Trio.xcworkspace \
  37. -scheme "Trio Tests" \
  38. -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.4' \
  39. 2>&1 | tee xcodebuild.log
  40. - name: Annotate test results
  41. if: always()
  42. run: |
  43. if [ -f xcodebuild.log ]; then
  44. if grep -q "Failing tests:" xcodebuild.log; then
  45. echo "::error title=Unit Tests Failed::Some tests failed"
  46. echo "## ❌ Some tests failed:" >> $GITHUB_STEP_SUMMARY
  47. grep -A 20 "Failing tests:" xcodebuild.log | \
  48. grep -E '^\s+[A-Za-z0-9]+\..+\(\)' | \
  49. sed 's/^/ - /' >> $GITHUB_STEP_SUMMARY
  50. echo "::group::Failed Test List"
  51. grep -A 20 "Failing tests:" xcodebuild.log | \
  52. grep -E '^\s+[A-Za-z0-9]+\..+\(\)' | \
  53. sed 's/^/ - /'
  54. echo "::endgroup::"
  55. else
  56. echo "::notice title=Unit Tests Passed::✅ All tests passed"
  57. echo "✅ All tests passed" >> $GITHUB_STEP_SUMMARY
  58. fi
  59. else
  60. echo "::warning::Test log (xcodebuild.log) not found"
  61. fi