Skip to content

Commit

Permalink
ci - start adding coverage using DSP 2043 mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
commonism committed May 27, 2024
1 parent 4b6b761 commit 063e649
Show file tree
Hide file tree
Showing 6 changed files with 381 additions and 2 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CodeCov
on: [push, pull_request]
jobs:
run:
name: test ${{ matrix.os }} / ${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.11","3.12"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
steps:
- uses: actions/checkout@master
- uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python }}
- name: install deps
run: |
pdm use -f $PYTHON
pdm install -d
- name: Setup description documents
run: |
pdm run pytest --cov=tests/test_description_documents --cov-report=xml:./coverage/reports/coverage-description_documents-tests.xml tests/description_documents_test.py
- name: Generate coverage report (DSP 2043)
run: |
pdm run pytest --cov=src/aiopenapi3_redfish/ --cov-report=xml:./coverage/reports/coverage-dsp2043.xml tests/dsp2043_test.py::test_dsp2043_file
pdm run pytest --cov=tests/test_dsp2043.py --cov-report=xml:./coverage/reports/coverage-dsp2043-tests.xml tests/dsp2043_test.py::test_dsp2043_file
- name: Upload coverage to Codecov (core)
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/reports/
files: coverage-dsp2043.xml
env_vars: OS,PYTHON
fail_ci_if_error: false
flags: core
name: codecov-aiopenapi3_redfish
verbose: true
- name: Upload coverage to Codecov (tests)
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/reports/
files: coverage-description_documents-tests.xml,coverage-dsp2043-tests.xml
env_vars: OS,PYTHON
fail_ci_if_error: false
flags: tests
name: codecov-aiopenapi3_redfish-tests
verbose: true
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ repos:
- "--max-line-length=120"
- "--ignore=E203,W503"
- "--select=W504"

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py311-plus]
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.ci hooks
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build-backend = "setuptools.build_meta"


[tool.pdm]
package-type = "library"
distribution = true

[tool.pdm.dev-dependencies]
dev = [
Expand Down
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pathlib import Path

import pytest

import aiopenapi3_redfish


@pytest.fixture(scope="session")
def description_documents():
return Path(aiopenapi3_redfish.__file__).parent / "description_documents"
42 changes: 42 additions & 0 deletions tests/description_documents_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import io
import zipfile

import httpx


def test_DSP8010(description_documents):
if (p := description_documents / "DSP8010" / "2024.1").exists():
return

p.mkdir(exist_ok=True)

zip = zipfile.Path(
zipfile.ZipFile(
io.BytesIO(
httpx.get("https://www.dmtf.org/sites/default/files/standards/documents/DSP8010_2024.1.zip").content
)
)
)
for i in zip.glob("openapi/*.yaml"):
(p / i.name).write_text(i.read_text())


def test_Swordfish(description_documents):
if (p := description_documents / "Swordfish" / "v1.2.6").exists():
return

p.mkdir(exist_ok=True)

zip = zipfile.Path(
zipfile.ZipFile(
io.BytesIO(
httpx.get(
"https://www.snia.org/sites/default/files/technical-work/swordfish/release/v1.2.6/zip/Swordfish_v1.2.6.zip"
).content
)
)
)
schema = zipfile.Path(io.BytesIO((zip / "Swordfish_v1.2.6_Schema.zip").read_bytes()))

for i in schema.glob("yaml/*.yaml"):
(p / i.name).write_text(i.read_text())
Loading

0 comments on commit 063e649

Please sign in to comment.