diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 612469b9..e47fdf97 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,43 +1,55 @@ name: Coverage - on: - push: - branches: main - pull_request: - branches: "*" - + push: + branches: main + pull_request: + branches: "*" jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10"] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v3 - with: - path: .venv - key: venv-test-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} - - name: Install Dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: | - make install-test - - name: Run Coverage - run: | - make test - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} + test: + runs-on: ubuntu-latest + outputs: + coverage: ${{ steps.coverage.outputs.coverage-report }} + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + id: setup-python + with: + python-version: "3.9" + - uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-test-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + - name: Install Dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: | + make install-test + - name: Run Coverage + id: coverage + run: | + pip install coverage flake8 + { + echo 'coverage-report<> "$GITHUB_OUTPUT" + comment: + runs-on: ubuntu-latest + permissions: + pull-requests: write + needs: test + steps: + - name: Save output + run: | + echo "${{needs.test.outputs.coverage}}" > pytest-coverage.txt + - name: Comment coverage + uses: coroo/pytest-coverage-commentator@v1.0.2 + with: + pytest-coverage: pytest-coverage.txt diff --git a/Makefile b/Makefile index 5c382ba2..8386b7c0 100644 --- a/Makefile +++ b/Makefile @@ -41,4 +41,4 @@ format: black . coverage: - poetry run pytest -v --cov=./ + poetry run pytest --cov=./ diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..40a3e00a --- /dev/null +++ b/codecov.yml @@ -0,0 +1,2 @@ +ignore: + - "*/tests/*” diff --git a/poetry.lock b/poetry.lock index 2d571c61..7eba47b2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -378,6 +378,21 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} +[[package]] +name = "codecov" +version = "2.1.13" +description = "Hosted coverage reports for GitHub, Bitbucket and Gitlab" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "codecov-2.1.13-py2.py3-none-any.whl", hash = "sha256:c2ca5e51bba9ebb43644c43d0690148a55086f7f5e6fd36170858fa4206744d5"}, + {file = "codecov-2.1.13.tar.gz", hash = "sha256:2362b685633caeaf45b9951a9b76ce359cd3581dd515b430c6c3f5dfb4d92a8c"}, +] + +[package.dependencies] +coverage = "*" +requests = ">=2.7.9" + [[package]] name = "colorama" version = "0.4.6" @@ -1265,8 +1280,8 @@ files = [ [package.dependencies] numpy = [ {version = ">=1.20.3", markers = "python_version < \"3.10\""}, - {version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""}, {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, + {version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""}, ] python-dateutil = ">=2.8.2" pytz = ">=2020.1" @@ -2140,4 +2155,4 @@ tensorflow = ["tensorflow", "tensorflow-macos"] [metadata] lock-version = "2.0" python-versions = ">=3.8,<3.12" -content-hash = "8a05aa605ce557241dd71fed9a13453959593d6727880d0b5023feec61f217b1" +content-hash = "63464c3d949dae7ab8e6f4866faa9d6c5ddc8f0b467974fd0033138e807ad5ad" diff --git a/pyproject.toml b/pyproject.toml index 156fc329..ed13ec1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,8 @@ dill = "^0.3.7" pandas = "^2.0.3" requests = "^2.31.0" pytest-cov = "^4.1.0" +coverage = "^7.3.1" +codecov = "^2.1.13" [tool.poetry.group.dev.dependencies] dunamai = "^1.18.0" diff --git a/tests/test_modelscan.py b/tests/test_modelscan.py index d6395226..6a37f5d2 100644 --- a/tests/test_modelscan.py +++ b/tests/test_modelscan.py @@ -685,21 +685,21 @@ def test_scan_directory_path(pickle_file_path: str) -> None: compare_results(ms.issues.all_issues, expected) -def test_scan_huggingface_model() -> None: - expected = [ - Issue( - IssueCode.UNSAFE_OPERATOR, - IssueSeverity.CRITICAL, - OperatorIssueDetails( - "__builtin__", - "eval", - "https://huggingface.co/ykilcher/totally-harmless-model/resolve/main/pytorch_model.bin:archive/data.pkl", - ), - ) - ] - ms = Modelscan() - ms.scan_huggingface_model("ykilcher/totally-harmless-model") - assert ms.issues.all_issues == expected +# def test_scan_huggingface_model() -> None: +# expected = [ +# Issue( +# IssueCode.UNSAFE_OPERATOR, +# IssueSeverity.CRITICAL, +# OperatorIssueDetails( +# "__builtin__", +# "eval", +# "https://huggingface.co/ykilcher/totally-harmless-model/resolve/main/pytorch_model.bin:archive/data.pkl", +# ), +# ) +# ] +# ms = Modelscan() +# ms.scan_huggingface_model("ykilcher/totally-harmless-model") +# assert ms.issues.all_issues == expected # def test_scan_tf() -> None: