diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..e966646 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,117 @@ +name: Development +on: push + +jobs: + pylint: + name: PyLint + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Check out repository code + uses: actions/checkout@v4.2.2 + + # Setup Python (faster than using Python container) + - name: Setup Python + uses: actions/setup-python@v5.3.0 + with: + python-version: "3.12.0" + + - name: Install Hatch + run: python -m pip install --upgrade hatch + + - name: Get Hatch Dependency Hash + run: echo "HATCH_DEP_HASH=$(hatch dep hash)" >> $GITHUB_ENV + + - name: Cache Hatch environment + id: cache-hatch + uses: actions/cache@v4.2.3 + with: + path: | + ~/.cache/hatch + ~/.local/share/hatch + key: ${{ runner.os }}-hatch-${{ env.HATCH_DEP_HASH }} + + # Run pylint once and capture output + - name: Run Pylint on compile_flags + run: | + PYLINT_OUTPUT=$(hatch run pylint compile_flags || true) + echo "$PYLINT_OUTPUT" + SCORE=$(sed -n '$s/[^0-9]*\([0-9.]*\).*/\1/p' <<< "$PYLINT_OUTPUT") + echo "PYLINT_SCORE=$SCORE" >> $GITHUB_ENV + + # Check if pass, the test command only takes integers so truncate decimals + - name: Check If Pass (90%) + run: test "${PYLINT_SCORE%.*}" -ge 9 + + test: + name: PyTest + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Check out repository code + uses: actions/checkout@v4.2.2 + + # Setup Python (faster than using Python container) + - name: Setup Python + uses: actions/setup-python@v5.3.0 + with: + python-version: "3.12.0" + + - name: Install Hatch + run: python -m pip install --upgrade hatch + + - name: Get Hatch Dependency Hash + run: echo "HATCH_DEP_HASH=$(hatch dep hash)" >> $GITHUB_ENV + + - name: Cache Hatch environment + id: cache-hatch + uses: actions/cache@v4.2.3 + with: + path: | + ~/.cache/hatch + ~/.local/share/hatch + key: ${{ runner.os }}-hatch-${{ env.HATCH_DEP_HASH }} + + - name: Run test suite + run: hatch test + + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Check out repository code + uses: actions/checkout@v4.2.2 + + # Setup Python (faster than using Python container) + - name: Setup Python + uses: actions/setup-python@v5.3.0 + with: + python-version: "3.12.0" + + - name: Install Hatch + run: python -m pip install --upgrade hatch + + - name: Get Hatch Dependency Hash + run: echo "HATCH_DEP_HASH=$(hatch dep hash)" >> $GITHUB_ENV + + - name: Cache Hatch environment + id: cache-hatch + uses: actions/cache@v4.2.3 + with: + path: | + ~/.cache/hatch + ~/.local/share/hatch + key: ${{ runner.os }}-hatch-${{ env.HATCH_DEP_HASH }} + + - name: Hatch build + run: hatch build + + - name: Upload build files + uses: actions/upload-artifact@v4.4.3 + with: + name: build + path: dist diff --git a/compile_flags/__about__.py b/compile_flags/__about__.py index ebd3b51..9eb7e60 100644 --- a/compile_flags/__about__.py +++ b/compile_flags/__about__.py @@ -1,4 +1,7 @@ # SPDX-FileCopyrightText: 2025-present Yiannis Charalambous # # SPDX-License-Identifier: AGPL-3.0 + +"""Contains information about the program.""" + __version__ = "0.0.1" diff --git a/compile_flags/__main__.py b/compile_flags/__main__.py index a459ea7..2e3f497 100644 --- a/compile_flags/__main__.py +++ b/compile_flags/__main__.py @@ -2,9 +2,10 @@ # # SPDX-License-Identifier: AGPL-3.0 +"""Entry point of compile-flags.""" + import argparse import logging -import sys import structlog from pydantic_settings import CliApp, CliSettingsSource diff --git a/compile_flags/config.py b/compile_flags/config.py index 6ef616e..f9bbfc8 100644 --- a/compile_flags/config.py +++ b/compile_flags/config.py @@ -2,6 +2,8 @@ # # SPDX-License-Identifier: AGPL-3.0 +"""Handles loading from command line args.""" + import logging import os from pathlib import Path diff --git a/pyproject.toml b/pyproject.toml index 090dc09..8ebbafd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,10 +19,7 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3.12", ] -dependencies = [ - "pydantic-settings", - "structlog", -] +dependencies = ["pydantic-settings", "structlog"] [project.scripts] compile-flags = "compile_flags.__main__:main" @@ -35,13 +32,14 @@ Source = "https://github.com/esbmc/compile-flags" [tool.hatch.version] path = "compile_flags/__about__.py" +[tool.hatch.envs.default] +extra-dependencies = ["pylint"] + [tool.hatch.envs.default.scripts] compile-flags = "python -m compile_flags {args}" [tool.hatch.envs.types] -extra-dependencies = [ - "mypy>=1.0.0", -] +extra-dependencies = ["mypy>=1.0.0"] [tool.hatch.envs.types.scripts] check = "mypy --install-types --non-interactive {args:src/compile_flags tests}" @@ -49,18 +47,11 @@ check = "mypy --install-types --non-interactive {args:src/compile_flags tests}" source_pkgs = ["compile_flags", "tests"] branch = true parallel = true -omit = [ - "src/compile_flags/__about__.py", -] +omit = ["src/compile_flags/__about__.py"] [tool.coverage.paths] compile_flags = ["src/compile_flags", "*/compile-flags/src/compile_flags"] tests = ["tests", "*/compile-flags/tests"] [tool.coverage.report] -exclude_lines = [ - "no cov", - "if __name__ == .__main__.:", - "if TYPE_CHECKING:", -] - +exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] diff --git a/tests/test_dummy.py b/tests/test_dummy.py new file mode 100644 index 0000000..a52f33e --- /dev/null +++ b/tests/test_dummy.py @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2025-present Yiannis Charalambous +# +# SPDX-License-Identifier: AGPL-3.0 + +"""Dummy test file until we get some actual tests.""" + + +def test_dummy() -> None: + assert 1