From 7af06472d8ae7742024e2eaeb8f24eb19558afa9 Mon Sep 17 00:00:00 2001 From: Victor Guo Date: Mon, 15 Sep 2025 01:02:40 +0000 Subject: [PATCH 1/7] fixed format issue --- .github/workflows/ci.yaml | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..745c02d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,57 @@ +name: CI + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: [main] + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# Optional: least-privilege default +permissions: + contents: read + +jobs: + precommit: + name: pre-commit (lint/format/tests) + runs-on: ubuntu-latest + # Run on PRs, and on pushes to main + if: ${{ github.event_name != 'push' || github.ref == 'refs/heads/main' }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + id: py + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install Poetry + uses: abatilo/actions-poetry@v3 + with: + poetry-version: "1.8.3" + + - name: Enable in-project venv + run: poetry config virtualenvs.in-project true + + - name: Cache Poetry venv + uses: actions/cache@v4 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.py.outputs.python-version }}-${{ hashFiles('poetry.lock') }} + restore-keys: | + venv-${{ runner.os }}- + + - name: Install dependencies + run: poetry install --no-interaction + + # Runs all hooks defined in pre-commit (e.g., ruff, pytest, mypy) + - name: Run pre-commit on all files + run: | + poetry run pre-commit install + poetry run pre-commit run --all-files From 52dbc3815eddd4d535a40a86ac50d6707a0d97ec Mon Sep 17 00:00:00 2001 From: Victor Guo Date: Mon, 15 Sep 2025 01:06:09 +0000 Subject: [PATCH 2/7] fixed pyproject.toml --- pyproject.toml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 4274d13..df128a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,17 @@ dependencies = [ "pre-commit (>=4.3.0,<5.0.0)" ] +[tool.poetry] +name = "arithmetic" +version = "0.1.0" +description = "Toy arithmetic package" +authors = ["Your Name "] +readme = "README.md" +packages = [{ include = "src/arithmetic" }] + +[tool.poetry.dependencies] +python = "^3.12" + [build-system] requires = ["poetry-core>=2.0.0,<3.0.0"] From 9d7bffa1c020714a0068f08cd492def49a3f71d4 Mon Sep 17 00:00:00 2001 From: Victor Guo Date: Mon, 15 Sep 2025 01:07:32 +0000 Subject: [PATCH 3/7] relocked poetry --- poetry.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index 4177cc6..28cbed8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -940,5 +940,5 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.1" -python-versions = ">=3.12" -content-hash = "c6fe4b288327b501a15d79c555e296323d3da6a16b612a92ac74271600991431" +python-versions = "^3.12" +content-hash = "2208d21945ff72a894dfa1b053afd56efc83d7e50a8d39b29c814fdc7eb94a3e" From 45eb2a312174f7d5b4bed25e9577960b52500e31 Mon Sep 17 00:00:00 2001 From: Victor Guo Date: Mon, 15 Sep 2025 02:59:39 +0000 Subject: [PATCH 4/7] updated ci config's poetry version --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 745c02d..d263893 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,7 @@ jobs: - name: Install Poetry uses: abatilo/actions-poetry@v3 with: - poetry-version: "1.8.3" + poetry-version: "2.2.0" - name: Enable in-project venv run: poetry config virtualenvs.in-project true From c210009d184ac37d6c4f71983283ebaa22eed84d Mon Sep 17 00:00:00 2001 From: PNWCS Date: Sun, 14 Sep 2025 23:04:28 -0500 Subject: [PATCH 5/7] Update ci.yaml --- .github/workflows/ci.yaml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d263893..69fada0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,15 +10,13 @@ concurrency: group: ci-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -# Optional: least-privilege default permissions: contents: read jobs: - precommit: - name: pre-commit (lint/format/tests) + checks: + name: Lint / Format Check / Tests runs-on: ubuntu-latest - # Run on PRs, and on pushes to main if: ${{ github.event_name != 'push' || github.ref == 'refs/heads/main' }} steps: @@ -50,8 +48,18 @@ jobs: - name: Install dependencies run: poetry install --no-interaction - # Runs all hooks defined in pre-commit (e.g., ruff, pytest, mypy) - - name: Run pre-commit on all files + # ---- Static checks (no file modifications in CI) ---- + - name: Ruff lint + run: poetry run ruff check . + + - name: Ruff format (check only) + run: poetry run ruff format --check . + + # ---- Run tests with coverage threshold ---- + - name: Run tests with coverage run: | - poetry run pre-commit install - poetry run pre-commit run --all-files + poetry run pytest \ + -q --maxfail=1 --disable-warnings \ + --cov=src --cov-report=term-missing \ + --cov-report=xml:coverage.xml \ + --cov-fail-under=100 From 169c6262c47251df43f29946843a834dec4e214a Mon Sep 17 00:00:00 2001 From: PNWCS Date: Mon, 15 Sep 2025 13:33:04 -0500 Subject: [PATCH 6/7] Update README.md --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index af2eb1b..1fd278f 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,12 @@ **Workflow**: 1. Fork this repository to your own GitHub account. -2. Create a new branch from `develop` and name it `feature/student1name_student2name`. -3. Clone the repo to AWS VM. -4. Implement the functions until all `pytest` tests pass. -5. Push your code to your Github repo. +2. Clone the repo to AWS VM. +3. Run poetry install to install dependencies +4. Run poetry run pre-commit install to install the pre-commit hook. +5. Create a new branch from `develop` and name it `feature/student1name_student2name`. +7. Implement the functions until all `pytest` tests pass. +8. Make the pre-commit checks all pass and commit the code. +9. Push your code to your Github repo. 5. Submit a Pull Request back to the `develop` branch of the main repo. CI must pass. 6. Wait for code review and grading. From 6a60d5370d9ce08986064f0fada3d3eaa30accd6 Mon Sep 17 00:00:00 2001 From: Sai Karthik Date: Mon, 15 Sep 2025 19:06:08 +0000 Subject: [PATCH 7/7] Added all the arithematic functions --- src/arithmetic/arithmetic.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/arithmetic/arithmetic.py b/src/arithmetic/arithmetic.py index 86f6960..f5920d0 100644 --- a/src/arithmetic/arithmetic.py +++ b/src/arithmetic/arithmetic.py @@ -13,7 +13,8 @@ def add_numbers(a: int, b: int) -> int: Returns: Sum of a and b. """ - raise NotImplementedError + return a + b + # raise NotImplementedError def factorial(n: int) -> int: @@ -28,7 +29,16 @@ def factorial(n: int) -> int: Raises: ValueError: if n is negative """ - raise NotImplementedError + if n < 0: + raise ValueError + else: + if n == 0: + return 1 + else: + fact = 1 + for i in range(1, n + 1): + fact = fact * i + return fact def is_prime(n: int) -> bool: @@ -43,4 +53,10 @@ def is_prime(n: int) -> bool: Returns: True if n is prime; otherwise False. """ - raise NotImplementedError + if n <= 1: + return False + else: + for i in range(2, n): + if n % i == 0: + return False + return True