Skip to content

- bugfix due to a newer version of pydantic 1 #2

- bugfix due to a newer version of pydantic 1

- bugfix due to a newer version of pydantic 1 #2

Workflow file for this run

name: CI tests
on:
pull_request:
push:
branches:
- master
- 'push-action/**'
env:
PYTEST_ADDOPTS: "--color=yes"
# Cancel running workflows when additional changes are pushed
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
pip install -e .
pip install -r requirements.txt
pip install -r requirements-server.txt
pip install -r requirements-dev.txt
- name: Run pre-commit
run: |
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
openapi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install tools
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
pip install -e .
pip install -r requirements.txt
pip install -r requirements-server.txt
pip install -r requirements-dev.txt
- name: Pass generated OpenAPI schemas through validator.swagger.io
run: |
invoke swagger-validator openapi/openapi.json
invoke swagger-validator openapi/index_openapi.json
- name: Check OpenAPI Schemas have not changed
run: invoke check-openapi-diff
docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build the container image
run: docker build -f Dockerfile --build-arg CONFIG_FILE=.docker/docker_config.json --tag optimade .
- name: Start Docker image - server
run: |
docker run --rm -d -p 3213:5000 --name optimade optimade
.github/utils/wait_for_it.sh localhost:3213 -t 120
sleep 15
- name: Test server, including OPTIONAL base URLs
uses: Materials-Consortia/optimade-validator-action@v2
with:
port: 3213
path: /
all versioned paths: yes
validator version: ${{ github.sha }} # This ensures the head of a PR or latest push commit is tested
- name: Start Docker image - index server
run: |
docker run --rm -d -p 3214:5000 --name optimade-index -e MAIN=main_index optimade
.github/utils/wait_for_it.sh localhost:3214 -t 120
sleep 15
- name: Test index server, including OPTIONAL base URLs
uses: Materials-Consortia/optimade-validator-action@v2
with:
port: 3214
path: /
all versioned paths: yes
index: yes
validator version: ${{ github.sha }} # This ensures the head of a PR or latest push commit is tested
pytest:
runs-on: ubuntu-latest
env:
OPTIMADE_CONFIG_FILE: ${{ github.workspace }}/optimade_config.json
strategy:
fail-fast: false
max-parallel: 4
matrix:
python-version: ['3.9', '3.10', '3.11']
services:
mongo:
image: mongo:4
ports:
- 27017:27017
postgres:
image: postgres:10
env:
POSTGRES_DB: test_aiida
POSTGRES_PASSWORD: test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
elasticsearch:
image: elasticsearch:7.17.7
ports:
- 9200:9200
- 9300:9300
env:
discovery.type: single-node
xpack.security.enabled: 'false'
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install latest compatible versions of immediate dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
pip install -e .
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -r requirements-http-client.txt
- name: Run non-server tests
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml tests/ --ignore tests/server
- name: Install latest server dependencies
run: pip install -r requirements-server.txt
- name: Run server tests (using `mongomock`)
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongomock'
- name: Run server tests with no API validation (using `mongomock`)
run:
pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongomock'
OPTIMADE_VALIDATE_API_RESPONSE: false
- name: Run server tests (using a real MongoDB)
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongodb'
- name: Run server tests (using Elasticsearch)
run: |
.github/utils/wait_for_it.sh localhost:9200 -t 120
.github/utils/wait_for_it.sh localhost:9300 -t 120
pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'elastic'
- name: Install adapter conversion dependencies
run: pip install -r requirements-client.txt
- name: Setup environment for AiiDA
env:
AIIDA_TEST_BACKEND: core.psql_dos
run: |
.github/aiida/setup_aiida.sh
- name: Run previously skipped tests for adapter conversion
run: pytest -rs -vvv --cov=./optimade/ --cov-report=xml --cov-append tests/adapters/
- name: Run tests for validator only to assess coverage (mongomock)
if: matrix.python-version == 3.10
run: pytest -rs --cov=./optimade/ --cov-report=xml:validator_cov.xml --cov-append tests/server/test_server_validation.py
env:
OPTIMADE_DATABASE_BACKEND: 'mongomock'
- name: Run tests for validator only to assess coverage (Elasticsearch)
if: matrix.python-version == 3.10
run: pytest -rs --cov=./optimade/ --cov-report=xml:validator_cov.xml --cov-append tests/server/test_server_validation.py
env:
OPTIMADE_DATABASE_BACKEND: 'elastic'
OPTIMADE_INSERT_TEST_DATA: false # Must be specified as previous steps will have already inserted the test data
- name: Run tests for validator only to assess coverage (MongoDB)
if: matrix.python-version == 3.10
run: pytest -rs --cov=./optimade/ --cov-report=xml:validator_cov.xml --cov-append tests/server/test_server_validation.py
env:
OPTIMADE_DATABASE_BACKEND: 'mongodb'
OPTIMADE_INSERT_TEST_DATA: false # Must be specified as previous steps will have already inserted the test data
- name: Run the OPTIMADE Client CLI
if: matrix.python-version == 3.10
run: |
coverage run --append --source optimade optimade/client/cli.py \
--filter 'nsites = 1' \
--output-file test_get_async.json \
https://optimade.fly.dev
test test_get_async.json
coverage run --append --source optimade optimade/client/cli.py \
--filter 'nsites = 1' \
--count \
--output-file test_count.json \
https://optimade.fly.dev
test test_count.json
coverage run --append --source optimade optimade/client/cli.py \
--no-async \
--filter 'nsites = 1' \
--count \
--output-file test_count_no_async.json \
https://optimade.fly.dev
test test_count_no_async.json
diff test_count_no_async.json test_count.json
coverage xml
- name: Upload coverage to Codecov
if: matrix.python-version == '3.10' && github.repository == 'Materials-Consortia/optimade-python-tools'
uses: codecov/codecov-action@v3
with:
name: project
file: ./coverage.xml
flags: project
- name: Upload validator coverage to Codecov
if: matrix.python-version == '3.10' && github.repository == 'Materials-Consortia/optimade-python-tools'
uses: codecov/codecov-action@v3
with:
name: validator
file: ./validator_cov.xml
flags: validator
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
pip install -e .
pip install -r requirements.txt
pip install -r requirements-server.txt
pip install -r requirements-dev.txt
pip install -r requirements-http-client.txt
pip install -r requirements-docs.txt
# NOTE: While we're now using `mike`, this is still useful
# to test the integrity of the documentation build.
- name: Build
run: |
invoke create-api-reference-docs --pre-clean
mkdocs build --strict
test_build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: |
requirements*.txt
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools requests
- name: Install package
run: |
pip install -r requirements.txt -r requirements-dev.txt -r requirements-client.txt -r requirements-http-client.txt -r requirements-docs.txt
pip install -e .[all]
- name: Build source distribution
run: python ./setup.py sdist