|
| 1 | +name: core-test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - dev |
| 8 | + paths: |
| 9 | + - 'src/server/core/**' |
| 10 | + - '.github/workflows/core-test.yaml' |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + - dev |
| 15 | + paths: |
| 16 | + - 'src/server/core/**' |
| 17 | + - '.github/workflows/core-test.yaml' |
| 18 | + |
| 19 | +jobs: |
| 20 | + test: |
| 21 | + name: Tests on ${{ matrix.os }} for ${{ matrix.python-version }} |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + python-version: [3.13] |
| 25 | + os: [ubuntu-latest] |
| 26 | + runs-on: ${{ matrix.os }} |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + defaults: |
| 30 | + run: |
| 31 | + working-directory: src/server/ |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + - name: Install uv |
| 35 | + uses: astral-sh/setup-uv@v6 |
| 36 | + |
| 37 | + - name: Set up Python |
| 38 | + run: uv python install |
| 39 | + - name: Install dependencies |
| 40 | + run: | |
| 41 | + cd core |
| 42 | + uv sync --frozen --no-dev --no-cache-dir |
| 43 | + - name: Start containers |
| 44 | + run: | |
| 45 | + cp .env.example .env |
| 46 | + cp core/config.yaml.example core/config.yaml |
| 47 | + sh scripts/local_dev_deps.sh & |
| 48 | + - name: Wait for containers to start |
| 49 | + working-directory: ./src/server |
| 50 | + run: | |
| 51 | + set -a; . ./.env; set +a |
| 52 | + until docker compose exec acontext-server-pg pg_isready -U $DATABASE_USER -d $DATABASE_NAME; do |
| 53 | + echo "Waiting for PostgreSQL to be ready..." |
| 54 | + sleep 5 |
| 55 | + done |
| 56 | +
|
| 57 | + until docker compose exec acontext-server-minio curl -f http://127.0.0.1:9000/minio/health/ready; do |
| 58 | + echo "Waiting for MinIO to be ready..." |
| 59 | + sleep 5 |
| 60 | + done |
| 61 | +
|
| 62 | + docker compose exec acontext-server-minio mc alias set local http://127.0.0.1:9000 $S3_ACCESS_KEY $S3_SECRET_KEY |
| 63 | +
|
| 64 | + until docker compose exec acontext-server-minio mc ls local/$S3_BUCKET >/dev/null 2>&1; do |
| 65 | + echo "Waiting for S3 bucket '$S3_BUCKET' to be created..." |
| 66 | + sleep 5 |
| 67 | + done |
| 68 | + - name: Test with pytest |
| 69 | + run: | |
| 70 | + cd core |
| 71 | + uv run -m pytest --junit-xml=junit/test-results-${{ matrix.python-version }}.xml --cov=. --cov-report=xml:coverage-${{ matrix.python-version }}.xml tests/ -s -v |
| 72 | + - name: Upload pytest test results and coverage |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: pytest-results-${{ matrix.python-version }} |
| 76 | + path: | |
| 77 | + ./src/server/core/junit/test-results-${{ matrix.python-version }}.xml |
| 78 | + ./src/server/core/coverage-${{ matrix.python-version }}.xml |
| 79 | + if: ${{ always() }} |
| 80 | + - name: Stop containers |
| 81 | + if: ${{ always() }} |
| 82 | + run: | |
| 83 | + docker compose down |
0 commit comments