run-unit-tests.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. name: Run Unit Tests
  2. concurrency:
  3. group: ${{ github.workflow }}-${{ github.ref }}
  4. cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
  5. on:
  6. push:
  7. branches:
  8. - main
  9. paths-ignore:
  10. - '**/*.md'
  11. - 'frontend/**'
  12. - 'docs/**'
  13. - 'evaluation/**'
  14. pull_request:
  15. env:
  16. PERSIST_SANDBOX : "false"
  17. jobs:
  18. fe-test:
  19. runs-on: ubuntu-latest
  20. strategy:
  21. matrix:
  22. node-version: [20]
  23. steps:
  24. - name: Checkout
  25. uses: actions/checkout@v4
  26. - name: Set up Node.js
  27. uses: actions/setup-node@v4
  28. with:
  29. node-version: ${{ matrix.node-version }}
  30. - name: Install dependencies
  31. working-directory: ./frontend
  32. run: npm ci
  33. - name: Run tests and collect coverage
  34. working-directory: ./frontend
  35. run: npm run test:coverage
  36. - name: Upload coverage to Codecov
  37. uses: codecov/codecov-action@v4
  38. env:
  39. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  40. test-on-macos:
  41. name: Test on macOS
  42. runs-on: macos-12
  43. env:
  44. INSTALL_DOCKER: "1" # Set to '0' to skip Docker installation
  45. strategy:
  46. matrix:
  47. python-version: ["3.11"]
  48. steps:
  49. - uses: actions/checkout@v4
  50. - name: Install poetry via pipx
  51. run: pipx install poetry
  52. - name: Set up Python ${{ matrix.python-version }}
  53. uses: actions/setup-python@v5
  54. with:
  55. python-version: ${{ matrix.python-version }}
  56. cache: "poetry"
  57. - name: Install Python dependencies using Poetry
  58. run: poetry install
  59. - name: Install & Start Docker
  60. if: env.INSTALL_DOCKER == '1'
  61. run: |
  62. # Uninstall colima to upgrade to the latest version
  63. if brew list colima &>/dev/null; then
  64. brew uninstall colima
  65. # unlinking colima dependency: go
  66. brew uninstall go@1.21
  67. fi
  68. rm -rf ~/.colima ~/.lima
  69. brew install --HEAD colima
  70. brew services start colima
  71. brew install docker
  72. colima delete
  73. # Attempt to start Colima
  74. ATTEMPT_LIMIT=3
  75. start_colima() {
  76. colima start --network-address --arch x86_64 --cpu=1 --memory=1
  77. }
  78. for ((i=1; i<=ATTEMPT_LIMIT; i++)); do
  79. if start_colima; then
  80. echo "Colima started successfully."
  81. break
  82. else
  83. echo "Failed to start Colima. Attempt $i/$ATTEMPT_LIMIT."
  84. if [ $i -eq $ATTEMPT_LIMIT ]; then
  85. colima delete
  86. else
  87. colima stop -f
  88. fi
  89. fi
  90. done
  91. if [ $i -gt $ATTEMPT_LIMIT ]; then
  92. echo "Failed to start Colima after $ATTEMPT_LIMIT attempts."
  93. exit 1
  94. fi
  95. # For testcontainers to find the Colima socket
  96. # https://github.com/abiosoft/colima/blob/main/docs/FAQ.md#cannot-connect-to-the-docker-daemon-at-unixvarrundockersock-is-the-docker-daemon-running
  97. sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
  98. - name: Build Environment
  99. run: make build
  100. - name: Run Tests
  101. run: poetry run pytest --forked --cov=agenthub --cov=opendevin --cov-report=xml ./tests/unit -k "not test_sandbox and not test_runtime"
  102. - name: Upload coverage to Codecov
  103. uses: codecov/codecov-action@v4
  104. env:
  105. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  106. test-on-linux:
  107. name: Test on Linux
  108. runs-on: ubuntu-latest
  109. env:
  110. INSTALL_DOCKER: "0" # Set to '0' to skip Docker installation
  111. strategy:
  112. matrix:
  113. python-version: ["3.11"]
  114. steps:
  115. - uses: actions/checkout@v4
  116. - name: Install poetry via pipx
  117. run: pipx install poetry
  118. - name: Set up Python
  119. uses: actions/setup-python@v5
  120. with:
  121. python-version: ${{ matrix.python-version }}
  122. cache: "poetry"
  123. - name: Install Python dependencies using Poetry
  124. run: poetry install --without evaluation
  125. - name: Build Environment
  126. run: make build
  127. - name: Run Tests
  128. run: poetry run pytest --forked --cov=agenthub --cov=opendevin --cov-report=xml ./tests/unit -k "not test_sandbox and not test_runtime"
  129. - name: Upload coverage to Codecov
  130. uses: codecov/codecov-action@v4
  131. env:
  132. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}