Skip to content

Commit

Permalink
Merge pull request #103 from Materials-Consortia/index_meta_db
Browse files Browse the repository at this point in the history
Implement an Index meta-database.
This may be run as a second parallel server.
  • Loading branch information
CasperWA committed Dec 11, 2019
2 parents 160951a + b411bcc commit ddf11f5
Show file tree
Hide file tree
Showing 25 changed files with 2,639 additions and 143 deletions.
3 changes: 3 additions & 0 deletions .ci/index_openapi_diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
# Note: This returns exit code 0, if the two specs agree, otherwise exit code 1
docker run -t -v $(pwd):/specs:ro quen2404/openapi-diff /specs/index_openapi.json /specs/local_index_openapi.json
11 changes: 10 additions & 1 deletion .ci/json_diff.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#!/bin/bash
python -c "from optimade.server.main import app, update_schema; update_schema(app)"
python -c "from optimade.server.main_index import app, update_schema; update_schema(app)"

diff=$(jsondiff openapi.json local_openapi.json);
index_diff=$(jsondiff index_openapi.json local_index_openapi.json);

if [ ! "$diff" = "{}" ]; then
echo -e "Generated OpenAPI spec did not match committed version.\nRun 'invoke update_openapijson' and re-commit.\nDiff:\n$diff";
echo -e "Generated OpenAPI spec for test server did not match committed version.\nRun 'invoke update_openapijson' and re-commit.\nDiff:\n$diff";
exit 1;
fi

if [ ! "$index_diff" = "{}" ]; then
echo -e "Generated OpenAPI spec for Index meta-database did not match committed version.\nRun 'invoke update_openapijson' and re-commit.\nDiff:\n$index_diff";
exit 1;
fi
2 changes: 1 addition & 1 deletion .github/workflows/deps_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -U setuptools
pip install pre-commit
pip install .[dev]
- name: Run pre-commit
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@ venv.bak/

Untitled.ipynb
local_openapi.json
local_index_openapi.json
server.cfg
34 changes: 23 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
default_language_version:
python: python3.7

repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
name: Blacken

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: trailing-whitespace
exclude: README.md
- id: check-yaml
- id: check-json

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: trailing-whitespace
exclude: README.md
- id: check-yaml
- id: check-json
- repo: local
hooks:
- id: json-diff
name: OpenAPI diff
description: Check for differences in openapi.json and index_openapi.json with local versions.
entry: ./.ci/json_diff.sh
language: system

0 comments on commit ddf11f5

Please sign in to comment.