|
| 1 | +name: Scheduler Tests |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + |
| 5 | +env: |
| 6 | + DEFAULT_PYTHON: '3.12' |
| 7 | + |
| 8 | +jobs: |
| 9 | + tests: |
| 10 | + name: Run Scheduler tests |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up QEMU |
| 18 | + uses: docker/setup-qemu-action@v3 |
| 19 | + |
| 20 | + - name: Set up Docker Buildx |
| 21 | + uses: docker/setup-buildx-action@v3 |
| 22 | + |
| 23 | + - name: Cache jars |
| 24 | + uses: actions/cache@v4 |
| 25 | + with: |
| 26 | + path: ./cached_jars |
| 27 | + key: ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-test-scheduler |
| 28 | + restore-keys: | |
| 29 | + ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-test-scheduler |
| 30 | + ${{ runner.os }}-python- |
| 31 | +
|
| 32 | + - name: Build Worker Image |
| 33 | + uses: docker/build-push-action@v6 |
| 34 | + with: |
| 35 | + context: . |
| 36 | + tags: mtsrus/syncmaster-worker:${{ github.sha }} |
| 37 | + target: test |
| 38 | + file: docker/Dockerfile.worker |
| 39 | + load: true |
| 40 | + cache-from: mtsrus/syncmaster-worker:develop |
| 41 | + |
| 42 | + - name: Docker compose up |
| 43 | + run: | |
| 44 | + docker compose -f docker-compose.test.yml --profile all down -v --remove-orphans |
| 45 | + docker compose -f docker-compose.test.yml --profile worker up -d --wait --wait-timeout 200 |
| 46 | + env: |
| 47 | + WORKER_IMAGE_TAG: ${{ github.sha }} |
| 48 | + |
| 49 | + # This is important, as coverage is exported after receiving SIGTERM |
| 50 | + - name: Run Scheduler Tests |
| 51 | + run: | |
| 52 | + docker compose -f ./docker-compose.test.yml --profile worker exec -T worker coverage run -m pytest -vvv -s -m "scheduler" |
| 53 | +
|
| 54 | + - name: Dump worker logs on failure |
| 55 | + if: failure() |
| 56 | + uses: jwalton/gh-docker-logs@v2 |
| 57 | + with: |
| 58 | + images: mtsrus/syncmaster-worker |
| 59 | + dest: ./logs |
| 60 | + |
| 61 | + - name: Shutdown |
| 62 | + if: always() |
| 63 | + run: | |
| 64 | + docker compose -f docker-compose.test.yml --profile all down -v --remove-orphans |
| 65 | +
|
| 66 | + - name: Upload worker logs |
| 67 | + uses: actions/upload-artifact@v4 |
| 68 | + if: failure() |
| 69 | + with: |
| 70 | + name: worker-logs-scheduler |
| 71 | + path: logs/* |
| 72 | + |
| 73 | + - name: Upload coverage results |
| 74 | + uses: actions/upload-artifact@v4 |
| 75 | + with: |
| 76 | + name: coverage-scheduler |
| 77 | + path: reports/* |
| 78 | + # https://github.com/actions/upload-artifact/issues/602 |
| 79 | + include-hidden-files: true |
0 commit comments