/ .github / workflows / server-test.yml
server-test.yml
  1  name: Server Tests
  2  
  3  on:
  4    pull_request:
  5      branches: [ main ]
  6      paths:
  7        - 'server/**'
  8  
  9  permissions:
 10    contents: read
 11  
 12  concurrency:
 13    group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
 14    cancel-in-progress: true
 15  
 16  jobs:
 17    test:
 18      strategy:
 19        fail-fast: false
 20        matrix:
 21          os: [ubuntu-latest, windows-latest]
 22      runs-on: ${{ matrix.os }}
 23      defaults:
 24        run:
 25          shell: bash
 26      steps:
 27        - name: Checkout code
 28          uses: actions/checkout@v6
 29  
 30        - name: Set up Python
 31          uses: actions/setup-python@v6
 32          with:
 33            python-version: '3.10'
 34  
 35        - name: Install uv
 36          run: |
 37            pip install uv
 38  
 39        - name: Run tests
 40          run: |
 41            cd server
 42            uv sync --all-groups
 43            uv run ruff check
 44            uv run pytest
 45  
 46    docker-smoke:
 47      strategy:
 48        matrix:
 49          network: [host, bridge]
 50      runs-on: ubuntu-latest
 51      env:
 52        OPENSANDBOX_INSECURE_SERVER: YES
 53      steps:
 54        - name: Checkout code
 55          uses: actions/checkout@v6
 56  
 57        - name: Set up Python
 58          uses: actions/setup-python@v6
 59          with:
 60            python-version: '3.10'
 61  
 62        - name: Install uv
 63          run: |
 64            pip install uv
 65  
 66        - name: Set up Docker
 67          run: |
 68            docker --version
 69  
 70        - name: Run smoke test
 71          run: |
 72            set -e
 73            cd server
 74            uv sync --all-groups
 75  
 76            # Create config file
 77            cat <<EOF > ~/.sandbox.toml
 78            [server]
 79            host = "127.0.0.1"
 80            port = 32888
 81            api_key = ""
 82            [log]
 83            level = "INFO"
 84            [runtime]
 85            type = "docker"
 86            execd_image = "opensandbox/execd:latest"
 87            [egress]
 88            image = "opensandbox/egress:latest"
 89            [docker]
 90            network_mode = "${{ matrix.network }}"
 91            [storage]
 92            allowed_host_paths = ["/tmp/opensandbox-e2e"]
 93            EOF
 94  
 95            # Start server in background
 96            uv run python -m opensandbox_server.main > app.log 2>&1 &
 97  
 98            # Wait for server to start
 99            sleep 10
100  
101            # Run smoke test
102            chmod +x tests/smoke.sh
103            ./tests/smoke.sh
104        - name: Show logs
105          if: always()
106          run: |
107            cat server/app.log