Skip to content

Commit

Permalink
CI performance refresh (#1836)
Browse files Browse the repository at this point in the history
* Add durations output to test runs

* Split default linting and testing Python version

* Set HTTP timeout for client tests in CI
  • Loading branch information
ml-evs authored Nov 7, 2023
1 parent 5b0a3cc commit 590bdac
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

env:
PYTEST_ADDOPTS: "--color=yes"
LINTING_PY_VERSION: "3.9" # 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
Expand All @@ -26,10 +27,10 @@ jobs:
with:
submodules: true

- name: Set up Python 3.9
- name: Set up Python ${{ env.LINTING_PY_VERSION }}
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: ${{ env.LINTING_PY_VERSION }}
cache: 'pip'
cache-dependency-path: |
requirements*.txt
Expand All @@ -56,10 +57,10 @@ jobs:
with:
submodules: true

- name: Set up Python 3.9
- name: Set up Python ${{ env.LINTING_PY_VERSION }}
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: ${{ env.LINTING_PY_VERSION }}
cache: 'pip'
cache-dependency-path: |
requirements*.txt
Expand Down Expand Up @@ -184,25 +185,25 @@ jobs:
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
run: pytest -rs -vvv --durations=0 --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
run: pytest -rs -vvv --durations=0 --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
pytest -rs -vvv --durations=0 --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
run: pytest -rs -vvv --durations=0 --cov=./optimade/ --cov-report=xml --cov-append tests/server tests/filtertransformers
env:
OPTIMADE_DATABASE_BACKEND: 'mongodb'

Expand All @@ -227,36 +228,38 @@ jobs:
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.9
if: matrix.python-version == '3.11'
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.9
if: matrix.python-version == '3.11'
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.9
if: matrix.python-version == '3.11'
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.9
if: matrix.python-version == '3.11'
run: |
coverage run --append --source optimade optimade/client/cli.py \
--filter 'nsites = 1' \
--http-timeout 1.0 \
--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' \
--http-timeout 1.0 \
--count \
--output-file test_count.json \
https://optimade.fly.dev
Expand All @@ -265,6 +268,7 @@ jobs:
coverage run --append --source optimade optimade/client/cli.py \
--no-async \
--filter 'nsites = 1' \
--http-timeout 1.0 \
--count \
--output-file test_count_no_async.json \
https://optimade.fly.dev
Expand All @@ -275,15 +279,15 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: matrix.python-version == '3.9' && github.repository == 'Materials-Consortia/optimade-python-tools'
if: matrix.python-version == '3.11' && 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.9' && github.repository == 'Materials-Consortia/optimade-python-tools'
if: matrix.python-version == '3.11' && github.repository == 'Materials-Consortia/optimade-python-tools'
uses: codecov/codecov-action@v3
with:
name: validator
Expand All @@ -300,7 +304,7 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: ${{ env.LINTING_PY_VERSION }}
cache: 'pip'
cache-dependency-path: |
requirements*.txt
Expand Down Expand Up @@ -330,10 +334,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python 3.9
- name: Set up Python ${{ env.LINTING_PY_VERSION }}
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: ${{ env.LINTING_PY_VERSION }}
cache: 'pip'
cache-dependency-path: |
requirements*.txt
Expand Down

0 comments on commit 590bdac

Please sign in to comment.