diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 3cfb188a..942bb89a 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -35,17 +35,15 @@ jobs: virtualenvs-create: true virtualenvs-in-project: true - - name: Configure Poetry cache - run: poetry config cache-dir ./.cache/pypoetry - - - name: Load cached poetry dependencies + - name: Load cached venv id: cached-poetry-dependencies uses: actions/cache@v4 with: - path: ./.cache/pypoetry - key: poetry-cache-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + path: .venv + key: venv-ruff-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' run: poetry install --only dev - name: Ruff version @@ -60,10 +58,10 @@ jobs: run-unit-tests: name: Run unit tests using matrix needs: ruff - strategy: + strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] runs-on: [self-hosted, Linux, X64] timeout-minutes: 30 @@ -71,7 +69,7 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v5 - + - name: Set up Python uses: actions/setup-python@v5 with: @@ -84,15 +82,12 @@ jobs: virtualenvs-create: true virtualenvs-in-project: true - - name: Configure Poetry cache - run: poetry config cache-dir ./.cache/pypoetry - - - name: Load cached poetry dependencies + - name: Load cached venv id: cached-poetry-dependencies uses: actions/cache@v4 with: - path: ./.cache/pypoetry - key: poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} + path: .venv + key: venv-tests-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - name: Install dependencies run: poetry install --no-interaction @@ -101,36 +96,36 @@ jobs: run: | poetry run pytest \ --cov=c2pie \ - --cov-report=xml:coverage-unit.xml \ -m "not e2e" \ --maxfail=1 \ -v - name: Upload coverage artifact - if: (matrix.os == 'ubuntu-latest' || runner.os == 'Linux') && matrix.python-version == '3.12' + if: matrix.python-version == '3.12' uses: actions/upload-artifact@v4 with: + include-hidden-files: true name: coverage-unit - path: | - coverage-unit.xml - .coverage + path: .coverage run-e2e-tests: name: Run e2e tests needs: ruff - strategy: + + strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] runs-on: [self-hosted, Linux, X64] timeout-minutes: 30 - + steps: - name: Checkout repository uses: actions/checkout@v5 - - - uses: actions/setup-python@v5 + + - name: Set up Python + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -141,15 +136,12 @@ jobs: virtualenvs-create: true virtualenvs-in-project: true - # - name: Configure Poetry cache - # run: poetry config cache-dir ./.cache/pypoetry - - # - name: Load cached poetry dependencies - # id: cached-poetry-dependencies - # uses: actions/cache@v4 - # with: - # path: ./.cache/pypoetry - # key: poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v4 + with: + path: .venv + key: venv-tests-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - name: Install dependencies run: poetry install --no-interaction @@ -175,7 +167,7 @@ jobs: - name: Add cargo to PATH run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Verify if c2patool is installed + - name: Verify if c2patool is installed run: | c2patool -V @@ -183,30 +175,28 @@ jobs: run: | poetry run pytest tests/c2pa/e2e_test.py \ --cov=c2pie \ - --cov-report=xml:coverage-e2e.xml \ -v env: C2PIE_KEY_FILEPATH: ${{ vars.C2PIE_KEY_FILEPATH }} C2PIE_CERT_FILEPATH: ${{ vars.C2PIE_CERT_FILEPATH }} - name: Upload coverage artifact - if: (matrix.os == 'ubuntu-latest' || runner.os == 'Linux') && matrix.python-version == '3.12' + if: matrix.python-version == '3.12' uses: actions/upload-artifact@v4 with: + include-hidden-files: true name: coverage-e2e - path: | - coverage-e2e.xml - .coverage - + path: .coverage + combine-coverage: name: Combine coverage and upload to Codecov needs: [run-unit-tests, run-e2e-tests] - runs-on: [self-hosted, Linux, X64] - + runs-on: [self-hosted, Linux, X64] + steps: - name: Checkout repository uses: actions/checkout@v5 - + - name: Set up Python uses: actions/setup-python@v5 with: @@ -216,24 +206,30 @@ jobs: run: python -m pip install coverage[toml] - name: Download unit coverage - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: name: coverage-unit - path: ./coverage-unit + path: coverage-unit - name: Download e2e coverage - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: name: coverage-e2e - path: ./coverage-e2e + path: coverage-e2e - name: Combine coverage reports run: | - coverage combine ./coverage-unit/.coverage ./coverage-e2e/.coverage + coverage combine ./coverage-e2e/.coverage ./coverage-unit/.coverage coverage xml -o coverage-combined.xml coverage report --format=markdown >> $GITHUB_STEP_SUMMARY - coverage report + coverage json -o coverage-combined.json + - name: Upload combined coverage artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-combined + path: coverage-combined.json + - name: Upload to Codecov uses: codecov/codecov-action@v4 with: @@ -241,3 +237,4 @@ jobs: fail_ci_if_error: false token: ${{ secrets.CODECOV_TOKEN }} + # ![Coverage](https://codecov.io/gh/TourmalineCore/c2pie/branch/master/graph/badge.svg) \ No newline at end of file diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 8745cbcf..a30031e1 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -16,7 +16,7 @@ jobs: linting-and-testing: name: Linting and Testing uses: ./.github/workflows/lint-and-test.yml - package-publishing: + release-build: name: Build and Publish Package if: startsWith(github.event.ref, 'refs/tags/v') needs: linting-and-testing @@ -25,7 +25,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] runs-on: ${{ matrix.os }} timeout-minutes: 30 @@ -45,14 +45,29 @@ jobs: with: version: 'latest' - - name: Run Poetry install + - name: Build and Publish the Package run: | - poetry lock && poetry install --no-interaction --no-ansi + poetry build - - name: Configure Repository Credentials - run: | - poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + - name: Upload dists + uses: actions/upload-artifact@v4 + with: + name: release-dists + path: dist/ - - name: Build and Publish the Package - run: | - poetry publish --build \ No newline at end of file + pypi-publish: + runs-on: ubuntu-latest + needs: + - release-build + permissions: + id-token: write + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@v5 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f \ No newline at end of file diff --git a/README.md b/README.md index d67ac399..a7b616aa 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ ------- -[![Unit Tests](https://github.com/TourmalineCore/tc-c2pa-py/actions/workflows/run_unit_tests.yml/badge.svg)](https://github.com/TourmalineCore/tc-c2pa-py/actions/workflows/run_unit_tests.yml) -[![Lint](https://github.com/TourmalineCore/tc-c2pa-py/actions/workflows/lint.yml/badge.svg)](https://github.com/TourmalineCore/tc-c2pa-py/actions/workflows/lint.yml) +[![CI](https://github.com/TourmalineCore/c2pie/actions/workflows/lint-and-test.yml/badge.svg)](https://github.com/TourmalineCore/c2pie/actions/workflows/lint-and-test.yml)
diff --git a/c2pie/jumbf_boxes/super_box.py b/c2pie/jumbf_boxes/super_box.py index 0c1e06bc..8ff8dfab 100644 --- a/c2pie/jumbf_boxes/super_box.py +++ b/c2pie/jumbf_boxes/super_box.py @@ -1,4 +1,5 @@ # Jumbf super box class +from __future__ import annotations from c2pie.jumbf_boxes.box import Box from c2pie.jumbf_boxes.content_box import ContentBox diff --git a/c2pie/signing.py b/c2pie/signing.py index dc5404d2..de5da794 100644 --- a/c2pie/signing.py +++ b/c2pie/signing.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import hashlib import os from pathlib import Path diff --git a/poetry.lock b/poetry.lock index a2676010..8aeda360 100644 --- a/poetry.lock +++ b/poetry.lock @@ -605,5 +605,5 @@ files = [ [metadata] lock-version = "2.1" -python-versions = ">=3.9.2,<3.14" -content-hash = "24f51121611add2f1457606c221021350b3b641cc14ea53c1ae8029a5454ad1f" +python-versions = ">=3.9.2,<3.15" +content-hash = "a6fbc153e43b02a84ca1c6300722b132b6e5343a2969e80a8b84c032de524769" diff --git a/pyproject.toml b/pyproject.toml index 13a880d2..42d6c340 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ Issues = "https://github.com/TourmalineCore/c2pie/issues" c2pie = 'c2pie.main:main' [tool.poetry.dependencies] -python = ">=3.9.2,<3.14" +python = ">=3.9.2,<3.15" cbor2 = "^5.6.3" cryptography = ">=44.0.1" pytz = "^2024.1"