⬆️ update ruff requirement from ~=0.3.3 to ~=0.4.1 #2358
Workflow file for this run
This file contains 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: build | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
schedule: | |
- cron: "0 2 * * *" | |
jobs: | |
static-analysis: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.8" | |
- uses: pre-commit/[email protected] | |
with: | |
extra_args: --all-files | |
compatibility-tests: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
matrix: | |
python-version: | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
#- "3.12" # FIXME: async-asgi-testclient doesn't support Python 3.12 yet | |
pydantic-version: | |
- "2.5.2" | |
motor-version: | |
- "3.1.1" | |
- "3.2.0" | |
- "3.3.2" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Mongo Service | |
id: mongo-service | |
uses: art049/mongodb-cluster-action@v0 | |
with: | |
version: "4.4" | |
mode: standalone | |
- name: "Set up Python ${{ matrix.python-version }}" | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ matrix.python-version }}" | |
- name: Cache environment | |
uses: actions/cache@v2 | |
id: cache | |
with: | |
path: ${{ env.pythonLocation }} | |
key: env-compatibility-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pydantic-version }}-${{ matrix.motor-version }}-${{ hashFiles('pyproject.toml') }} | |
- name: Install dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
pip install ".[test]" | |
pip install "pydantic==${{ matrix.pydantic-version }}" "motor==${{ matrix.motor-version }}" | |
- name: Run compatibility checks. | |
run: | | |
python -c "import motor; print(motor.version)" 1>&2 | |
python -c "import pydantic; print(pydantic.VERSION)" 1>&2 | |
python -m pytest -q -rs | |
tests: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
matrix: | |
python-version: | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
mongo-version: | |
- "4.4" | |
- "5" | |
- "6" | |
mongo-mode: | |
- standalone | |
include: | |
- python-version: 3.11 | |
mongo-version: 4.0 | |
mongo-mode: replicaSet | |
- python-version: 3.11 | |
mongo-version: 4.2 | |
mongo-mode: sharded | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: pip | |
cache-dependency-path: "pyproject.toml" | |
- name: Mongo Service | |
id: mongo-service | |
uses: art049/mongodb-cluster-action@v0 | |
with: | |
version: ${{ matrix.mongo-version }} | |
mode: ${{ matrix.mongo-mode }} | |
- name: Install dependencies | |
run: | | |
pip install flit | |
pip install ".[test]" | |
- name: Run all tests | |
run: | | |
set -e | |
coverage run -m pytest -v | |
coverage report -m | |
coverage xml | |
env: | |
TEST_MONGO_URI: ${{ steps.mongo-service.outputs.connection-string }} | |
TEST_MONGO_MODE: ${{ matrix.mongo-mode }} | |
- uses: codecov/codecov-action@v3 | |
if: github.event_name != 'schedule' # Don't report coverage for nightly builds | |
with: | |
file: ./coverage.xml | |
flags: tests-${{ matrix.python-version }}-${{ matrix.mongo-version }}-${{ matrix.mongo-mode }} | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
integrated-realworld-test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: odmantic-current | |
- uses: actions/checkout@v4 | |
with: | |
repository: art049/fastapi-odmantic-realworld-example | |
submodules: recursive | |
path: fastapi-odmantic-realworld-example | |
- name: Install poetry and flit | |
run: | | |
pipx install poetry | |
pipx install flit | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
cache: "poetry" | |
- name: Install dependencies (w/o ODMantic) | |
working-directory: fastapi-odmantic-realworld-example | |
run: | | |
echo "$(grep -v 'odmantic =' ./pyproject.toml)" > pyproject.toml | |
poetry lock --no-update | |
poetry install | |
- name: Install current ODMantic version | |
working-directory: fastapi-odmantic-realworld-example | |
run: poetry run pip install ../odmantic-current/ | |
- name: Start the MongoDB instance | |
uses: art049/mongodb-cluster-action@v0 | |
id: mongodb-cluster-action | |
- name: Start the FastAPI server | |
working-directory: fastapi-odmantic-realworld-example | |
run: | | |
./scripts/start.sh & | |
# Wait for the server | |
while ! curl "http://localhost:8000/health" > /dev/null 2>&1 | |
do | |
sleep 1; | |
done | |
echo "Server ready." | |
env: | |
MONGO_URI: ${{ steps.mongodb-cluster-action.outputs.connection-string }} | |
- name: Run realworld backend tests | |
working-directory: fastapi-odmantic-realworld-example | |
run: ./realworld/api/run-api-tests.sh | |
env: | |
APIURL: http://localhost:8000 | |
all-ci-checks: | |
needs: | |
- static-analysis | |
- compatibility-tests | |
- tests | |
- integrated-realworld-test | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "All CI checks passed." |