build #1951
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@v2 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.9" | |
- uses: pre-commit/action@v2.0.0 | |
with: | |
extra_args: --all-files | |
compatibility-tests: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
matrix: | |
python-version: | |
- "3.7" | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
#- "3.11" # TODO: Enable once 3.11 is released | |
steps: | |
- uses: actions/checkout@v2 | |
- 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@v2 | |
with: | |
python-version: "${{ matrix.python-version }}" | |
- name: Cache environment | |
uses: actions/cache@v2 | |
with: | |
path: | | |
.venv | |
.tox | |
key: env-compatibility-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }} | |
- name: Install tox | |
run: pip install "tox~=3.27.1" flit | |
- name: Run compatibility checks. | |
run: | | |
export VERSION_STR=$(echo ${{ matrix.python-version }} | sed -e "s/\.//g") | |
export TOX_SKIP_ENV=$(printf '^(?!py%s-)' $VERSION_STR) | |
tox --parallel auto | |
tests: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
matrix: | |
python-version: | |
- "3.7" | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
#- "3.11" # TODO: Enable once 3.11 is released | |
mongo-version: | |
- "4.4" | |
- "5" | |
- "6" | |
mongo-mode: | |
- standalone | |
include: | |
- python-version: 3.8 | |
mongo-version: 4.0 | |
mongo-mode: replicaSet | |
- python-version: 3.8 | |
mongo-version: 4.2 | |
mongo-mode: sharded | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
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@v1 | |
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 | |
integrated-realworld-test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
path: odmantic-current | |
- uses: actions/checkout@v3 | |
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.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: "poetry" | |
- name: Install dependencies (w/o ODMantic) | |
working-directory: fastapi-odmantic-realworld-example | |
run: | | |
echo "$(grep -v 'odmantic =' ./pyproject.toml)" > pyproject.toml | |
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 |