mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* reduce dependency for runtime * try making llama-index an optional dependency that's not installed by default * do not install llama-index in CI * do not install llama-index in the app docker as well
168 lines
4.5 KiB
YAML
168 lines
4.5 KiB
YAML
name: Run Unit Tests
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- '**/*.md'
|
|
- 'frontend/**'
|
|
- 'docs/**'
|
|
- 'evaluation/**'
|
|
pull_request:
|
|
|
|
env:
|
|
PERSIST_SANDBOX : "false"
|
|
|
|
jobs:
|
|
fe-test:
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
node-version: [20]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
- name: Install dependencies
|
|
working-directory: ./frontend
|
|
run: npm ci
|
|
|
|
- name: Run tests and collect coverage
|
|
working-directory: ./frontend
|
|
run: npm run test:coverage
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
env:
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
test-on-macos:
|
|
name: Test on macOS
|
|
runs-on: macos-12
|
|
env:
|
|
INSTALL_DOCKER: "1" # Set to '0' to skip Docker installation
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.11"]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install poetry via pipx
|
|
run: pipx install poetry
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
cache: "poetry"
|
|
|
|
- name: Install Python dependencies using Poetry
|
|
run: poetry install --without evaluation,llama-index
|
|
|
|
- name: Install & Start Docker
|
|
if: env.INSTALL_DOCKER == '1'
|
|
run: |
|
|
INSTANCE_NAME="colima-${GITHUB_RUN_ID}"
|
|
|
|
# Uninstall colima to upgrade to the latest version
|
|
if brew list colima &>/dev/null; then
|
|
brew uninstall colima
|
|
# unlinking colima dependency: go
|
|
brew uninstall go@1.21
|
|
fi
|
|
rm -rf ~/.colima ~/.lima
|
|
brew install --HEAD colima
|
|
brew install docker
|
|
|
|
start_colima() {
|
|
# Find a free port in the range 10000-20000
|
|
RANDOM_PORT=$((RANDOM % 10001 + 10000))
|
|
|
|
# Original line:
|
|
if ! colima start --network-address --arch x86_64 --cpu=1 --memory=1 --verbose --ssh-port $RANDOM_PORT; then
|
|
echo "Failed to start Colima."
|
|
return 1
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
# Attempt to start Colima for 5 total attempts:
|
|
ATTEMPT_LIMIT=5
|
|
for ((i=1; i<=ATTEMPT_LIMIT; i++)); do
|
|
|
|
if start_colima; then
|
|
echo "Colima started successfully."
|
|
break
|
|
else
|
|
colima stop -f
|
|
sleep 10
|
|
colima delete -f
|
|
if [ $i -eq $ATTEMPT_LIMIT ]; then
|
|
exit 1
|
|
fi
|
|
sleep 10
|
|
fi
|
|
done
|
|
|
|
# For testcontainers to find the Colima socket
|
|
# https://github.com/abiosoft/colima/blob/main/docs/FAQ.md#cannot-connect-to-the-docker-daemon-at-unixvarrundockersock-is-the-docker-daemon-running
|
|
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
|
|
|
|
- name: Build Environment
|
|
run: make build
|
|
|
|
- name: Run Tests
|
|
run: poetry run pytest --forked --cov=agenthub --cov=opendevin --cov-report=xml ./tests/unit -k "not test_sandbox.py and not test_runtime.py"
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
env:
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
test-on-linux:
|
|
name: Test on Linux
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
INSTALL_DOCKER: "0" # Set to '0' to skip Docker installation
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.11"]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install poetry via pipx
|
|
run: pipx install poetry
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
cache: "poetry"
|
|
|
|
- name: Install Python dependencies using Poetry
|
|
run: poetry install --without evaluation,llama-index
|
|
|
|
- name: Build Environment
|
|
run: make build
|
|
|
|
- name: Run Tests
|
|
run: poetry run pytest --forked --cov=agenthub --cov=opendevin --cov-report=xml ./tests/unit -k "not test_sandbox.py and not test_runtime.py"
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
env:
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|