diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 00000000..dd91dfa2 --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -0,0 +1,53 @@ +name: Code coverage + +env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + MICROSOFT_EMAIL: gindibay@microsoft.com + USER_NAME: Gurkan Indibay + MAIN_BRANCH: all-citus + DB_USER_NAME: ${{ secrets.STATS_DB_USER_NAME }} + DB_PASSWORD: ${{ secrets.STATS_DB_PASSWORD }} + DB_HOST_AND_PORT: ${{ secrets.STATS_DB_HOST_AND_PORT }} + DB_NAME: ${{ secrets.STATS_DB_NAME }} + PACKAGE_CLOUD_API_TOKEN: ${{ secrets.PACKAGE_CLOUD_API_TOKEN }} + PACKAGE_CLOUD_ADMIN_API_TOKEN: ${{ secrets.PACKAGE_CLOUD_ADMIN_API_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + PACKAGING_PASSPHRASE: ${{ secrets.PACKAGING_PASSPHRASE }} + PLATFORM: el/8 +on: + push: + branches: + - "**" + + workflow_dispatch: + +jobs: + make-install: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Install all scripts + run: make && sudo make install + + code_coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Define git credentials + run: git config --global user.email "${MICROSOFT_EMAIL}"&& git config --global user.name "${USER_NAME}" + + - name: Install package dependencies + run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev python3-testresources + + - name: Install python requirements + run: python -m pip install -r packaging_automation/requirements.txt + + - name: Run code coverage + run: python -m pytest --cov=packaging_automation packaging_automation/tests/ diff --git a/.github/workflows/tool-tests.yml b/.github/workflows/tool-tests.yml index ec1cb98a..61e2ce2f 100644 --- a/.github/workflows/tool-tests.yml +++ b/.github/workflows/tool-tests.yml @@ -45,19 +45,19 @@ jobs: run: python -m prospector - name: Unit tests for "Common tools" - run: python -m pytest -q packaging_automation/tests/test_common_tool_methods.py + run: coverage run -m pytest -q packaging_automation/tests/test_common_tool_methods.py - name: Unit tests for "Update Package Properties" - run: python -m pytest -q packaging_automation/tests/test_update_package_properties.py + run: coverage run --cov-append -m pytest -q packaging_automation/tests/test_update_package_properties.py - name: Unit tests for "Prepare Release" - run: python -m pytest -q packaging_automation/tests/test_prepare_release.py + run: coverage run --cov-append -m pytest -q packaging_automation/tests/test_prepare_release.py - name: Unit tests for "Update Docker" - run: python -m pytest -q packaging_automation/tests/test_update_docker.py + run: coverage run --cov-append -m pytest -q packaging_automation/tests/test_update_docker.py - name: Unit tests for "Update Pgxn" - run: python -m pytest -q packaging_automation/tests/test_update_pgxn.py + run: coverage run --cov-append -m pytest -q packaging_automation/tests/test_update_pgxn.py - name: Packaging Warning Handler - run: python -m pytest -q packaging_automation/tests/test_packaging_warning_handler.py + run: coverage run --cov-append -m pytest -q packaging_automation/tests/test_packaging_warning_handler.py diff --git a/packaging_automation/requirements.in b/packaging_automation/requirements.in index 63c006b8..201762d4 100644 --- a/packaging_automation/requirements.in +++ b/packaging_automation/requirements.in @@ -16,3 +16,4 @@ urllib3 wheel python-dotenv prospector[with_everything] +pytest-cov diff --git a/packaging_automation/requirements.txt b/packaging_automation/requirements.txt index 6540bb5c..b8fab2ca 100644 --- a/packaging_automation/requirements.txt +++ b/packaging_automation/requirements.txt @@ -20,6 +20,8 @@ cffi==1.14.5 # via pynacl chardet==4.0.0 # via requests +coverage[toml]==6.0.2 + # via pytest-cov deprecated==1.2.12 # via pygithub docker==5.0.0 @@ -130,8 +132,12 @@ pyparsing==2.4.7 # via packaging pyroma==3.2 # via prospector -pytest==6.2.4 +pytest-cov==3.0.0 # via -r requirements.in +pytest==6.2.4 + # via + # -r requirements.in + # pytest-cov python-dotenv==0.19.0 # via -r requirements.in python-gnupg==0.4.7 @@ -173,6 +179,8 @@ toml==0.10.2 # pylint # pytest # vulture +tomli==1.2.1 + # via coverage typing-extensions==3.10.0.2 # via mypy urllib3==1.26.6