Skip to content

Commit

Permalink
Merge pull request #21 from LedgerHQ/add/europa
Browse files Browse the repository at this point in the history
Adding "Europa" device
  • Loading branch information
lpascal-ledger authored Mar 7, 2024
2 parents 34dc43f + 4d628da commit 27d9785
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build_and_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
name: Build, install and test the Ledgered Python package
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python_version: ['3.8', '3.9', '3.10', '3.11']
steps:
Expand All @@ -43,9 +44,10 @@ jobs:
run: pytest -v --tb=short tests/ --cov ledgered --cov-report xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
name: codecov-ledgered
token: ${{ secrets.CODECOV_TOKEN }}


package_and_deploy:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.5.0] - 2024-??-??

### Added

- ledger-manifest: "Europa" is now a valid `app.devices` value.

### Removed

- BREAKING: removing references to `LegacyManifest` and `RepoManifest`. Only `Manifest` is to be
Expand Down
6 changes: 2 additions & 4 deletions src/ledgered/manifest/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,12 @@ def main(): # pragma: no cover
display_content["tests"]["dependencies"] = dependencies

if args.output_tests_unit_directory:
if repo_manifest.tests is None or repo_manifest.tests.unit_directory is None or str(
repo_manifest.tests.unit_directory) is None:
if repo_manifest.tests is None or repo_manifest.tests.unit_directory is None:
logger.error("This manifest does not contains the 'tests.unit_directory' field")
sys.exit(2)
display_content["tests"]["unit_directory"] = str(repo_manifest.tests.unit_directory)
if args.output_tests_pytest_directory:
if repo_manifest.tests is None or repo_manifest.tests.pytest_directory is None or str(
repo_manifest.tests.pytest_directory) is None:
if repo_manifest.tests is None or repo_manifest.tests.pytest_directory is None:
logger.error("This manifest does not contains the 'tests.pytest_directory' field")
sys.exit(2)
display_content["tests"]["pytest_directory"] = str(repo_manifest.tests.pytest_directory)
Expand Down
2 changes: 1 addition & 1 deletion src/ledgered/manifest/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
EXISTING_DEVICES = ["nanos", "nanox", "nanos+", "stax"]
EXISTING_DEVICES = ["nanos", "nanox", "nanos+", "stax", "europa"]
MANIFEST_FILE_NAME = "ledger_app.toml"
DEFAULT_USE_CASE = "default"
2 changes: 2 additions & 0 deletions src/ledgered/manifest/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class MissingField(ValueError):
pass
7 changes: 2 additions & 5 deletions src/ledgered/manifest/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from urllib.parse import urlparse

from .constants import DEFAULT_USE_CASE
from .errors import MissingField
from .types import Jsonable, JsonDict, JsonSet
from .utils import getLogger

Expand All @@ -15,10 +16,6 @@ class DuplicateDependencyError(ValueError):
pass


class MissingPytestDirectory(ValueError):
pass


@dataclass
class TestsDependencyConfig(Jsonable):
__test__ = False # deactivate pytest discovery warning
Expand Down Expand Up @@ -96,7 +93,7 @@ def __init__(self,
self.dependencies = None
else:
if self.pytest_directory is None:
raise MissingPytestDirectory()
raise MissingField("[tests] pytest_directory")
self.dependencies = JsonDict()
for key, value in dependencies.items():
logger.info("Parsing dependencies for '%s' tests", key)
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/ledger_app.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[app]
sdk = "Rust"
build_directory = ""
devices = ["nanos", "Stax"]
devices = ["nanos", "Stax", "EUROPA"]

[tests]
unit_directory = "unit"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/manifest/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestManifest(TestCase):

def check_ledger_app_toml(self, manifest: Manifest) -> None:
self.assertEqual(manifest.app.sdk, "rust")
self.assertEqual(manifest.app.devices, {"nanos", "stax"})
self.assertEqual(manifest.app.devices, {"nanos", "stax", "europa"})
self.assertEqual(manifest.app.build_directory, Path(""))
self.assertTrue(manifest.app.is_rust)
self.assertFalse(manifest.app.is_c)
Expand All @@ -19,7 +19,7 @@ def check_ledger_app_toml(self, manifest: Manifest) -> None:
self.assertEqual(manifest.tests.pytest_directory, Path("pytest"))

def test___init__ok(self):
app = {"sdk": "rust", "devices": ["NANOS", "stAX"], "build_directory": ""}
app = {"sdk": "rust", "devices": ["NANOS", "stAX", "europa"], "build_directory": ""}
tests = {"unit_directory": "unit", "pytest_directory": "pytest"}
self.check_ledger_app_toml(Manifest(app, tests))

Expand Down
6 changes: 5 additions & 1 deletion tests/unit/manifest/test_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import TestCase

from ledgered.manifest.constants import DEFAULT_USE_CASE
from ledgered.manifest.errors import MissingField
from ledgered.manifest.tests import DuplicateDependencyError, TestsConfig, TestsDependencyConfig, \
TestsDependenciesConfig, APPLICATION_DIRECTORY_KEY, APPLICATION_DIRECTORY_NAME

Expand Down Expand Up @@ -99,9 +100,12 @@ def test____init___ok_complete(self):
# the rest of the json can be compared
self.assertDictEqual(result_json, {"unit_directory": str(ud), "pytest_directory": str(pd)})


def test___init___nok_empty(self):
config = TestsConfig(**dict())
self.assertIsNone(config.unit_directory)
self.assertIsNone(config.pytest_directory)
self.assertIsNone(config.dependencies)

def test___init__missing_field(self):
with self.assertRaises(MissingField):
TestsConfig(dependencies="something")

0 comments on commit 27d9785

Please sign in to comment.