implement file server as a config flag #3462
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: CI tests | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - 'push-action/**' | |
| env: | |
| PYTEST_ADDOPTS: "--color=yes" | |
| LINTING_PY_VERSION: "3.10" # The version of Python to use for linting (typically the minimum supported) | |
| # 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@v7 | |
| with: | |
| submodules: true | |
| - name: Set up Python ${{ env.LINTING_PY_VERSION }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.LINTING_PY_VERSION }} | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: | | |
| uv sync --locked --extra server --group dev --extra elastic | |
| - name: Run pre-commit | |
| run: uv run pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) | |
| openapi: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| submodules: true | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: | | |
| uv sync --locked --extra server --group dev | |
| - name: Pass generated OpenAPI schemas through validator.swagger.io | |
| run: | | |
| uv run invoke swagger-validator openapi/openapi.json | |
| uv run invoke swagger-validator openapi/index_openapi.json | |
| - name: Check OpenAPI Schemas have not changed | |
| run: uv run invoke check-openapi-diff | |
| docker-image: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| 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.10', '3.11', '3.12', '3.13'] | |
| services: | |
| mongo: | |
| image: mongo:7 | |
| 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@v7 | |
| with: | |
| submodules: true | |
| fetch-depth: 2 | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: | | |
| uv sync --locked --extra http-client --group dev | |
| - name: Run non-server tests | |
| run: uv run pytest -rs -vvv --durations=10 --cov=./optimade/ --cov-report=xml tests/ --ignore tests/server | |
| - name: Install latest server dependencies | |
| run: uv sync --locked --extra http-client --group dev --extra server --extra elastic | |
| - name: Run server tests (using `mongomock`) | |
| run: uv run pytest -rs -vvv --durations=10 --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: | |
| uv run pytest -rs -vvv --durations=10 --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: uv run pytest -rs -vvv --durations=10 --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 | |
| uv run 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: uv sync --locked --all-extras --group dev | |
| - name: Setup environment for AiiDA | |
| env: | |
| AIIDA_TEST_BACKEND: core.psql_dos | |
| run: | | |
| uv run .github/aiida/setup_aiida.sh | |
| - name: Run previously skipped tests for adapter conversion | |
| run: uv 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.11' | |
| run: uv 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.11' | |
| run: uv 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 | |
| OPTIMADE_INSERT_FROM_JSONL: '' # 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.11' | |
| run: uv 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 | |
| OPTIMADE_INSERT_FROM_JSONL: '' # Must be specified as previous steps will have already inserted the test data | |
| - name: Run the OPTIMADE Client CLI | |
| if: matrix.python-version == '3.11' | |
| run: | | |
| uv run coverage run --append --source optimade optimade/client/cli.py \ | |
| --filter 'nsites = 1' \ | |
| --http-timeout 10.0 \ | |
| --output-file test_get_async.json \ | |
| https://optimade.fly.dev | |
| test test_get_async.json | |
| uv run coverage run --append --source optimade optimade/client/cli.py \ | |
| --filter 'nsites = 1' \ | |
| --http-timeout 10.0 \ | |
| --count \ | |
| --output-file test_count.json \ | |
| https://optimade.fly.dev | |
| test test_count.json | |
| uv run coverage run --append --source optimade optimade/client/cli.py \ | |
| --no-async \ | |
| --filter 'nsites = 1' \ | |
| --http-timeout 10.0 \ | |
| --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 | |
| uv run coverage xml | |
| - name: Upload coverage to Codecov | |
| if: matrix.python-version == '3.11' && github.repository == 'Materials-Consortia/optimade-python-tools' | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| name: project | |
| file: ./coverage.xml | |
| flags: project | |
| - name: Upload validator coverage to Codecov | |
| if: matrix.python-version == '3.11' && github.repository == 'Materials-Consortia/optimade-python-tools' | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| name: validator | |
| file: ./validator_cov.xml | |
| flags: validator | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| submodules: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.LINTING_PY_VERSION }} | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: | | |
| uv sync --locked --all-extras --group dev | |
| # NOTE: While we're now using `mike`, this is still useful | |
| # to test the integrity of the documentation build. | |
| - name: Build | |
| run: | | |
| uv run invoke create-api-reference-docs --pre-clean | |
| uv run mkdocs build --strict | |
| test_build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| - name: Set up Python ${{ env.LINTING_PY_VERSION }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.LINTING_PY_VERSION }} | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: | | |
| uv sync --locked --all-extras | |
| - name: Build source distribution | |
| run: uv run python -m build |