From 6e72b3dac90915129aafddf660e96a8863dcce26 Mon Sep 17 00:00:00 2001 From: ARYPROGRAMMER Date: Sun, 8 Dec 2024 23:31:58 +0530 Subject: [PATCH 1/2] feat: CI/CD pipeline to test-PR --- .github/workflows/pr-testing.yml | 80 +++++++++++++++++++ requirements.txt | 7 ++ ...c_program.py => test_quadratic_program.py} | 0 3 files changed, 87 insertions(+) create mode 100644 .github/workflows/pr-testing.yml create mode 100644 requirements.txt rename test/{tests_quadratic_program.py => test_quadratic_program.py} (100%) diff --git a/.github/workflows/pr-testing.yml b/.github/workflows/pr-testing.yml new file mode 100644 index 0000000..4efedee --- /dev/null +++ b/.github/workflows/pr-testing.yml @@ -0,0 +1,80 @@ +name: PR Testing + +on: + pull_request: + branches: + - main + +jobs: + lint-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.9', '3.10', '3.11'] + + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install flake8 black mypy + + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics + + - name: Check formatting with black + run: black --check . + + - name: Type check with mypy + run: mypy . + + - name: Run tests + run: | + pytest tests/* \ + --doctest-modules \ + --junitxml=junit/test-results-${{ matrix.python-version }}.xml + + - name: Upload pytest test results + uses: actions/upload-artifact@v4 + with: + name: pytest-results-${{ matrix.python-version }} + path: junit/test-results-${{ matrix.python-version }}.xml + + if: ${{ always() }} + + # Optional: Codecov coverage reporting (uncomment and configure if you use coverage) + # coverage: + # needs: lint-and-test + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - name: Set up Python + # uses: actions/setup-python@v5 + # with: + # python-version: '3.10' + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip + # pip install -r requirements.txt + # pip install pytest-cov + # - name: Run coverage + # run: | + # pytest --cov=./ --cov-report=xml + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v4 + # env: + # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1aab20d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +scipy==1.7.3 +qpsolvers[open_source_solvers]==4.4.0 +matplotlib==3.5.3 +numpy==1.21.6 +pandas==1.3.4 +scikit-learn==1.0.2 +pytest==6.2.5 \ No newline at end of file diff --git a/test/tests_quadratic_program.py b/test/test_quadratic_program.py similarity index 100% rename from test/tests_quadratic_program.py rename to test/test_quadratic_program.py From 438718eae2573a17444e955d636dab7605208b67 Mon Sep 17 00:00:00 2001 From: Arya Pratap Singh Date: Sun, 2 Feb 2025 20:22:32 +0530 Subject: [PATCH 2/2] workflow-fixed Signed-off-by: Arya Pratap Singh --- .github/workflows/pr-testing.yml | 38 ++++++++++++++++---------------- requirements.txt | 29 ++++++++++++++++++------ 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/.github/workflows/pr-testing.yml b/.github/workflows/pr-testing.yml index 4efedee..96dc4eb 100644 --- a/.github/workflows/pr-testing.yml +++ b/.github/workflows/pr-testing.yml @@ -4,16 +4,18 @@ on: pull_request: branches: - main + push: + branches: + - main jobs: - lint-and-test: + test: runs-on: ubuntu-latest strategy: matrix: python-version: ['3.9', '3.10', '3.11'] steps: - - name: Checkout code uses: actions/checkout@v4 @@ -22,39 +24,37 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: 'pip' + cache-dependency-path: '**/requirements.txt' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install flake8 black mypy + pip install pytest pytest-cov - - name: Lint with flake8 + - name: Add src to PYTHONPATH run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics + echo "PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/src" >> $GITHUB_ENV - - name: Check formatting with black - run: black --check . - - - name: Type check with mypy - run: mypy . + - name: Create test results directory + run: mkdir -p junit - name: Run tests run: | - pytest tests/* \ - --doctest-modules \ - --junitxml=junit/test-results-${{ matrix.python-version }}.xml + pytest test/test_quadratic_program.py \ + --doctest-modules \ + --junitxml=junit/test-results-${{ matrix.python-version }}.xml \ + --cov=src \ + --cov-report=xml - name: Upload pytest test results uses: actions/upload-artifact@v4 with: name: pytest-results-${{ matrix.python-version }} - path: junit/test-results-${{ matrix.python-version }}.xml - - if: ${{ always() }} + path: | + junit/test-results-${{ matrix.python-version }}.xml + coverage.xml + if: always() # Optional: Codecov coverage reporting (uncomment and configure if you use coverage) # coverage: diff --git a/requirements.txt b/requirements.txt index 1aab20d..5fd9de3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,22 @@ -scipy==1.7.3 -qpsolvers[open_source_solvers]==4.4.0 -matplotlib==3.5.3 -numpy==1.21.6 -pandas==1.3.4 -scikit-learn==1.0.2 -pytest==6.2.5 \ No newline at end of file +# Core numerical and scientific libraries +numpy>=1.21.0 +pandas>=1.3.4,<2.0.0 +scipy>=1.10.1 +scikit-learn>=1.0.2,<2.0.0 +pandas + +# Optimization +qpsolvers[open_source_solvers]>=4.4.0 + +pillow +pyparsing +exceptiongroup +pluggy + +# Visualization +matplotlib>=3.5.3,<4.0.0 +iniconfig + +# Testing +pytest>=6.2.5 +pytest-cov>=4.1.0 \ No newline at end of file