Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/CD: Code Quality Checks #83

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: Tests

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
- main

jobs:
build:
Expand All @@ -27,10 +25,18 @@ jobs:
- name: Cache the image on GitHub's repository
run: docker tag aleph-message:${GITHUB_REF##*/} docker.pkg.github.com/$GITHUB_REPOSITORY/aleph-message-build-cache && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/aleph-message-build-cache || true

- name: Test with black in the Docker image
run: |
docker run aleph-message:${GITHUB_REF##*/} black --check aleph_message

- name: Test with ruff in the Docker image
run: |
docker run aleph-message:${GITHUB_REF##*/} ruff aleph_message

- name: Pytest in the Docker image
run: |
docker run aleph-message:${GITHUB_REF##*/} pytest -vv --cov aleph_message

- name: MyPy in the Docker image
run: |
docker run aleph-message:${GITHUB_REF##*/} mypy aleph_message --ignore-missing-imports --check-untyped-defs
docker run aleph-message:${GITHUB_REF##*/} mypy aleph_message --install-types --non-interactive --check-untyped-defs --ignore-missing-imports
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ RUN pip install pytest requests types-requests pytest-cov mypy twine typing-exte
COPY . /opt/aleph-message
WORKDIR /opt/aleph-message
RUN pip install -e .
RUN pip install mypy ruff black
2 changes: 1 addition & 1 deletion aleph_message/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .base import Chain, HashType, MessageType
from .execution.instance import InstanceContent
from .execution.program import ProgramContent
from .execution.base import PaymentType, MachineType, Payment
from .execution.base import PaymentType, MachineType, Payment # noqa
from .item_hash import ItemHash, ItemType


Expand Down
6 changes: 3 additions & 3 deletions aleph_message/models/execution/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class CpuProperties(HashableModel):
class Config:
extra = Extra.forbid

class HypervisorType(str, Enum):
qemu = 'qemu'
firecracker = 'firecracker'

class HypervisorType(str, Enum):
qemu = "qemu"
firecracker = "firecracker"


class FunctionEnvironment(HashableModel):
Expand Down
4 changes: 2 additions & 2 deletions aleph_message/models/execution/program.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

from typing import Literal, Optional, Union
from typing import Literal, Optional

from pydantic import Field, validator
from pydantic import Field

from ..abstract import HashableModel
from ..item_hash import ItemHash
Expand Down
4 changes: 2 additions & 2 deletions aleph_message/models/execution/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from abc import ABC, abstractmethod
from enum import Enum
from typing import Literal, Optional, Type, Union
from typing import Literal, Optional, Union

from pydantic import ConstrainedInt, Extra, conint
from pydantic import ConstrainedInt, Extra

from ...utils import Gigabytes, gigabyte_to_mebibyte
from ..abstract import HashableModel
Expand Down
2 changes: 0 additions & 2 deletions aleph_message/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from os import listdir
from os.path import isdir, join
from pathlib import Path
from typing import Dict

import pytest
import requests
Expand All @@ -20,7 +19,6 @@
MessageType,
PostContent,
PostMessage,
ProgramContent,
ProgramMessage,
add_item_content_and_hash,
create_message_from_file,
Expand Down