Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
117 changes: 117 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/[email protected]
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/[email protected]
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/[email protected]

# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/[email protected]
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/[email protected]
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/[email protected]

# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/[email protected]
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/[email protected]
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/[email protected]
with:
name: build
path: dist
3 changes: 3 additions & 0 deletions compile_flags/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# SPDX-FileCopyrightText: 2025-present Yiannis Charalambous <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0

"""Contains information about the program."""

__version__ = "0.0.1"
3 changes: 2 additions & 1 deletion compile_flags/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion compile_flags/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#
# SPDX-License-Identifier: AGPL-3.0

"""Handles loading from command line args."""

import logging
import sys

import structlog
from pydantic import AliasChoices, Field, PrivateAttr, computed_field
from pydantic import AliasChoices, Field, computed_field
from pydantic_settings import BaseSettings, SettingsConfigDict


Expand Down
23 changes: 7 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -35,32 +32,26 @@ 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}"

[tool.coverage.run]
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:"]
9 changes: 9 additions & 0 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2025-present Yiannis Charalambous <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0

"""Dummy test file until we get some actual tests."""


def test_dummy() -> None:
assert 1