Add GitHub Action to run tests #54
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| paths-ignore: | |
| - "**.md" | |
| jobs: | |
| tests: | |
| runs-on: ubuntu-latest | |
| env: | |
| PYTHON_ENV: test | |
| services: | |
| docker: | |
| image: docker:24.0.5 | |
| options: --privileged | |
| strategy: | |
| matrix: | |
| python-version: | |
| # - "3.11" | |
| - "3.12" | |
| # - "3.13" | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
| - name: Cache docker/setup-buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Install Python dependencies | |
| run: | | |
| uv venv | |
| source ./.venv/bin/activate | |
| uv sync | |
| - name: Add .venv to PATH | |
| run: | | |
| echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH | |
| - name: Display Python dependencies | |
| run: | | |
| uv pip list | |
| - name: Verify tox installed | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| tox -h | |
| - name: Copy .env file | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| cp ./tests/.env.tests .env | |
| docker compose config | |
| - name: Start Docker services | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| docker compose --profile marker up -d ocr-forwarding-api | |
| - name: Wait for services to be healthy | |
| run: | | |
| docker compose ps | |
| docker compose logs | |
| sleep 30 | |
| docker compose ps | |
| docker compose logs | |
| - name: Test with tox | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| tox run | |
| - name: Tear down services | |
| working-directory: ${{ github.workspace }} | |
| if: always() | |
| run: | | |
| docker compose --profile marker --rmi all --volumes --remove-orphans |