Skip to content

Commit

Permalink
TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
narrieta@microsoft committed Jan 15, 2025
1 parent 4f7fce2 commit 8b0e715
Showing 1 changed file with 41 additions and 25 deletions.
66 changes: 41 additions & 25 deletions .github/workflows/ci_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,41 @@ on:

jobs:
execute-tests:
name: "Python ${{ matrix.python-version }} Unit Tests"
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
#
# Some of the Python versions we test are not supported by the setup-python Github Action. For those versions, we use a
# pre-built virtual environment.
#
- python-version: "2.6"
use_virtual_environment: true
- python-version: "2.7"
use_virtual_environment: true
- python-version: "3.4"
use_virtual_environment: true
# - python-version: "3.5"
# # workaround found in https://github.com/actions/setup-python/issues/866
# # for issue "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:728)" on Python 3.5
# pip_trusted_host: "pypi.python.org pypi.org files.pythonhosted.org"
# - python-version: "3.6"
# - python-version: "3.7"
# - python-version: "3.8"
# - python-version: "3.9"
# additional-nose-opts: "--with-coverage --cover-erase --cover-inclusive --cover-branches --cover-package=azurelinuxagent"
# - python-version: "3.10"
# - python-version: "3.11"

name: "Python ${{ matrix.python-version }} Unit Tests"
runs-on: ubuntu-20.04
- python-version: "3.5"
# workaround found in https://github.com/actions/setup-python/issues/866
# for issue "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:728)" on Python 3.5
pip_trusted_host: "pypi.python.org pypi.org files.pythonhosted.org"
- python-version: "3.6"
- python-version: "3.7"
- python-version: "3.8"
- python-version: "3.9"
additional-nose-opts: "--with-coverage --cover-erase --cover-inclusive --cover-branches --cover-package=azurelinuxagent"
- python-version: "3.10"
- python-version: "3.11"

steps:

- name: Checkout WALinuxAgent
uses: actions/checkout@v3

#
# We either install Python and the test dependencies, or download a pre-built virtual environment, depending on the
# use_virtual_environment flag.
#
- name: Setup Python ${{ matrix.python-version }}
if: matrix.use_virtual_environment == false
uses: actions/setup-python@v4
Expand All @@ -64,13 +69,16 @@ jobs:
sudo apt-get install -y curl bzip2 sudo
curl -sSf --retry 5 -o /tmp/python-${{ matrix.python-version }}.tar.bz2 https://dcrdata.blob.core.windows.net/python/python-${{ matrix.python-version }}.tar.bz2
sudo tar xjf /tmp/python-${{ matrix.python-version }}.tar.bz2 --directory /
# #
# # The virtual environments for 2.6 and 3.4 have dependencies on OpenSSL 1.0, which is not available beyond Ubuntu 16. We use this script to patch the environments.
# #
# if [[ "${{ matrix.python-version }}" =~ ^2\.6|3\.4$ ]]; then
# sudo ./tests/python_eol/patch_python_venv.sh "${{ matrix.python-version }}"
# fi
#
# The virtual environments for 2.6 and 3.4 have dependencies on OpenSSL 1.0, which is not available beyond Ubuntu 16. We use this script to patch the environments.
#
if [[ "${{ matrix.python-version }}" =~ ^2\.6|3\.4$ ]]; then
sudo ./tests/python_eol/patch_python_venv.sh "${{ matrix.python-version }}"
fi
#
# Execute the tests
#
- name: Execute Unit Tests
run: |
if [[ "${{ matrix.use_virtual_environment}}" == "true" ]]; then
Expand All @@ -80,13 +88,18 @@ jobs:
./ci/pytest.sh
else
if [[ "${{ matrix.use_virtual_environment}}" == "true" ]]; then
export NOSEOPTS="--verbose ${{ matrix.additional-nose-opts }}"
export NOSEOPTS="--verbose ${{ matrix.additional-nose-opts }}" # the pytest version on the venv does not support the --with-timer option.
else
export NOSEOPTS="--verbose --with-timer ${{ matrix.additional-nose-opts }}"
fi
./ci/nosetests.sh
fi
#
# Execute pylint even when the tests fail (but only if the dependencies were installed successfully)
#
# Note that the virtual environments do not include pylint, so we skip those Python versions.
#
- name: Run pylint
if: matrix.use_virtual_environment == false && (success() || (failure() && (steps.install-dependencies.outcome == 'success' || steps.install-venv.outcome == 'success')))
run: |
Expand Down Expand Up @@ -129,7 +142,10 @@ jobs:
pylint $PYLINT_OPTIONS $PYLINT_FILES
- name: Compile Coverage
#
# Lastly, compile code coverage
#
- name: Compile Code Coverage
if: matrix.python-version == '3.9'
run: |
echo looking for coverage files :
Expand All @@ -138,7 +154,7 @@ jobs:
sudo env "PATH=$PATH" coverage xml
sudo env "PATH=$PATH" coverage report
- name: Upload Coverage
- name: Upload Code Coverage
if: matrix.python-version == '3.9'
uses: codecov/codecov-action@v3
with:
Expand Down

0 comments on commit 8b0e715

Please sign in to comment.