From 0742d19d8b072faa3ac6d18b85836ecc9fc90be9 Mon Sep 17 00:00:00 2001 From: Anish Asthana Date: Mon, 10 Apr 2023 16:50:57 -0400 Subject: [PATCH] Update python tests job Signed-off-by: Anish Asthana --- .github/build/Containerfile | 12 ++++-- .github/build/requirements-dev.txt | 6 --- .github/build/requirements.txt | 11 ++++++ .../{precommit.yaml => pre-commit.yaml} | 0 .github/workflows/python-app.yml | 38 ------------------- .github/workflows/unit-tests.yml | 21 ++++++++++ README.md | 5 +-- requirements-dev.txt | 6 --- requirements.txt | 6 +++ 9 files changed, 48 insertions(+), 57 deletions(-) delete mode 100644 .github/build/requirements-dev.txt create mode 100644 .github/build/requirements.txt rename .github/workflows/{precommit.yaml => pre-commit.yaml} (100%) delete mode 100644 .github/workflows/python-app.yml create mode 100644 .github/workflows/unit-tests.yml delete mode 100644 requirements-dev.txt diff --git a/.github/build/Containerfile b/.github/build/Containerfile index 3c1393ccd..6d5788564 100644 --- a/.github/build/Containerfile +++ b/.github/build/Containerfile @@ -5,10 +5,16 @@ LABEL summary="Toolchain for running pre-commit hooks." \ io.k8s.display-name="Pre-Commit Toolchain" USER root -RUN dnf install nodejs +RUN dnf install nodejs -y && \ + dnf clean all && \ + rm -rf /var/cache/dnf +ADD https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz $TMPDIR/ +RUN tar -C /usr/local/bin -xvf $TMPDIR/oc.tar.gz && \ + chmod +x /usr/local/bin/oc && \ + rm $TMPDIR/oc.tar.gz USER $USERID -COPY requirements-dev.txt /tmp/requirements-dev.txt -RUN python -m pip install -r /tmp/requirements-dev.txt +COPY requirements.txt /tmp/requirements.txt +RUN python -m pip install -r /tmp/requirements.txt CMD bash diff --git a/.github/build/requirements-dev.txt b/.github/build/requirements-dev.txt deleted file mode 100644 index 986bc5127..000000000 --- a/.github/build/requirements-dev.txt +++ /dev/null @@ -1,6 +0,0 @@ -pre-commit -poetry -pytest -pytest-mock -coverage -black==22.3.0 diff --git a/.github/build/requirements.txt b/.github/build/requirements.txt new file mode 100644 index 000000000..3a7351acf --- /dev/null +++ b/.github/build/requirements.txt @@ -0,0 +1,11 @@ +openshift-client==1.0.18 +rich==12.5.1 +ray[default]==2.1.0 +kubernetes==26.1.0 +codeflare-torchx==0.6.0.dev0 +pre-commit +poetry +pytest +pytest-mock +coverage +black==22.3.0 diff --git a/.github/workflows/precommit.yaml b/.github/workflows/pre-commit.yaml similarity index 100% rename from .github/workflows/precommit.yaml rename to .github/workflows/pre-commit.yaml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index f22e8f224..000000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,38 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python application - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest==6.2.4 - pip install pytest-mock==3.6.1 - pip install coverage - pip install black==22.3.0 - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Check formatting with black - run: | - black --check . - - name: Test with pytest and check coverage - run: | - coverage run -m --source=src pytest -v tests/unit_test.py - coverage=$(coverage report -m | tail -1 | tail -c 4 | head -c 2) - if (( $coverage < 90 )); then exit 1; else echo "Coverage passed, ${coverage}%"; fi diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 000000000..daf6071d9 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,21 @@ +name: Python Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + unit-tests: + + runs-on: ubuntu-latest + container: + image: quay.io/project-codeflare/codeflare-sdk-precommit:v0.0.3 + steps: + - uses: actions/checkout@v3 + - name: Test with pytest and check coverage + run: | + coverage run -m --source=src pytest -v tests/unit_test.py + coverage=$(coverage report -m | tail -1 | tail -c 4 | head -c 2) + if (( $coverage < 90 )); then exit 1; else echo "Coverage passed, ${coverage}%"; fi diff --git a/README.md b/README.md index 0434e2983..9116ea2ee 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,7 @@ Can be installed via `pip`: `pip install codeflare-sdk` ### Prerequisites We recommend using Python 3.9 for development. -Install development specific dependencies: - `$ pip install -r requirements-dev.txt` - -Additional dependencies can be found in `requirements.txt`: `$ pip install -r requirements.txt` +Install dependencies: `$ pip install -r requirements.txt` ### Pre-commit diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 986bc5127..000000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,6 +0,0 @@ -pre-commit -poetry -pytest -pytest-mock -coverage -black==22.3.0 diff --git a/requirements.txt b/requirements.txt index 1a4b08061..3a7351acf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,9 @@ rich==12.5.1 ray[default]==2.1.0 kubernetes==26.1.0 codeflare-torchx==0.6.0.dev0 +pre-commit +poetry +pytest +pytest-mock +coverage +black==22.3.0