Skip to content

Commit

Permalink
updated ci/cd (#2)
Browse files Browse the repository at this point in the history
* test: ci/cd

* fix: fixed the ci/cd

* fix: add ruff installation through pip

* feat: added test and updated the workflow

* feat: updated the install command
  • Loading branch information
Rishabh672003 authored Jul 1, 2024
1 parent 2321d91 commit e35ebb1
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 12 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,26 @@ permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
Testing:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9,"3.10", "3.11", "3.12"]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v4
- name: Setup PDM
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pdm install && pip install ruff
run: |
pdm install ; pip install ruff pytest
- name: Run Tests
run: |
pdm run -v pytest tests
- name: Lint with ruff
run: |
ruff check .
58 changes: 54 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ build-backend = "pdm.backend"
distribution = true

[tool.pdm.dev-dependencies]
lint = [
"ruff>=0.5.0",
]
lint = ["ruff>=0.5.0"]
tests = ["pytest>=8.2.2"]

[project.scripts]
pyfix-imports = "pyfix_imports.commandline.cli:cli"
pyfix-imports = "pyfix_imports.commandline.cli:cli"
15 changes: 15 additions & 0 deletions tests/mod_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pyfix_imports.pyflake import pyflake
from tests.test import test_code

def check_code(output):
mod_list = pyflake(output)

if mod_list:
return mod_list
else:
return {}


def test_code_output():
assert check_code(test_code) == {'defaultdict', 'Tuple', 'List', 'mp', 'Optional', 'time', 'np', 'deque', 'os', 'itertools', 'Dict', 'dedent', 'collections', 'random'}

32 changes: 32 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
test_code = """
start = time.time()
a = np.array([1, 2, 3, 4])
b = os.getcwd()
c = random.randint(1, 3)
deq = deque()
a = dedent("121")
d = defaultdict(str)
a = mp.sqrt_mod(12, 2)
itt = itertools.accumulate([1, 2, 3, 4])
print(list(itt))
assert list(itt) == [1, 3, 6, 10]
Points = collections.namedtuple("Point", ["x", "y"])
def fname(a: Dict[int, List], b: Tuple[int], c: Optional[List]):
pass
z = os.getcwd()
end = time.time()
print(end - start)
"""

0 comments on commit e35ebb1

Please sign in to comment.