TEST #128
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Unit tests | ||
on: | ||
push: | ||
branches: [ "*" ] | ||
pull_request: | ||
branches: [ "*" ] | ||
workflow_dispatch: | ||
jobs: | ||
execute-tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- 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 | ||
steps: | ||
- name: Checkout WALinuxAgent | ||
uses: actions/checkout@v3 | ||
- name: Setup Python ${{ matrix.python-version }} | ||
if: matrix.use_virtual_environment == false | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
env: | ||
PIP_TRUSTED_HOST: ${{ matrix.pip_trusted_host }} | ||
- name: Install dependencies | ||
if: matrix.use_virtual_environment == false | ||
id: install-dependencies | ||
run: | | ||
sudo env "PATH=$PATH" python -m pip install --upgrade pip | ||
sudo env "PATH=$PATH" pip install -r requirements.txt | ||
sudo env "PATH=$PATH" pip install -r test-requirements.txt | ||
sudo env "PATH=$PATH" pip install --upgrade pylint | ||
- name: Setup Python ${{ matrix.python-version }} Virtual Environment | ||
if: matrix.use_virtual_environment == true | ||
id: install-venv | ||
run: | | ||
sudo apt-get update | ||
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 | ||
- name: Run pylint | ||
if: matrix.use_virtual_environment == false | ||
run: | | ||
# | ||
# List of files/directories to be checked by pylint. | ||
# The end-to-end tests run only on Python 3.9 and we lint them only on that version. | ||
# | ||
PYLINT_FILES="azurelinuxagent setup.py makepkg.py tests" | ||
if [[ "${{ matrix.python-version }}" == "3.9" ]]; then | ||
PYLINT_FILES="$PYLINT_FILES tests_e2e" | ||
fi | ||
# | ||
# Command-line options for pylint. | ||
# * "unused-private-member" is not implemented on 3.5 and will produce "E0012: Bad option value 'unused-private-member' (bad-option-value)" | ||
# so we suppress "bad-option-value". | ||
# * 3.9 will produce "no-member" for several properties/methods that are added to the mocks used by the unit tests (e.g | ||
# "E1101: Instance of 'WireProtocol' has no 'aggregate_status' member") so we suppress that warning. | ||
# * On 3.9 pylint crashes when parsing azurelinuxagent/daemon/main.py (see https://github.com/pylint-dev/pylint/issues/9473), so we ignore it. | ||
# * 'no-self-use' ("R0201: Method could be a function") was moved to an optional extension on 3.8 and is no longer used by default. It needs | ||
# to be suppressed for previous versions (3.0-3.7), though. | ||
# * 'contextmanager-generator-missing-cleanup' are false positives if yield is used inside an if-else block for contextmanager generator functions. | ||
# (https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/contextmanager-generator-missing-cleanup.html). | ||
# This is not implemented on versions (3.0-3.7) Bad option value 'contextmanager-generator-missing-cleanup' (bad-option-value) | ||
# * 3.9-3.11 will produce "too-many-positional-arguments" for several methods that are having more than 5 args, so we suppress that warning. | ||
# (R0917: Too many positional arguments (8/5) (too-many-positional-arguments)) | ||
PYLINT_OPTIONS="--rcfile=ci/pylintrc --jobs=0" | ||
if [[ "${{ matrix.python-version }}" == "3.9" ]]; then | ||
PYLINT_OPTIONS="$PYLINT_OPTIONS --disable=no-member,too-many-positional-arguments --ignore=main.py" | ||
fi | ||
if [[ "${{ matrix.python-version }}" =~ ^3\.(10|11)$ ]]; then | ||
PYLINT_OPTIONS="$PYLINT_OPTIONS --disable=too-many-positional-arguments" | ||
fi | ||
if [[ "${{ matrix.python-version }}" =~ ^3\.[0-7]$ ]]; then | ||
PYLINT_OPTIONS="$PYLINT_OPTIONS --disable=no-self-use,bad-option-value" | ||
fi | ||
echo "PYLINT_OPTIONS: $PYLINT_OPTIONS" | ||
echo "PYLINT_FILES: $PYLINT_FILES" | ||
pylint $PYLINT_OPTIONS $PYLINT_FILES | ||
- name: Execute Unit Tests | ||
if: success() || (failure() && (steps.install-dependencies.outcome == 'success' || steps.install-venv.outcome == 'success') | ||
Check failure on line 117 in .github/workflows/ci_pr.yml GitHub Actions / CI Unit testsInvalid workflow file
|
||
run: | | ||
if [[ "${{ matrix.use_virtual_environment}}" == "true" ]]; then | ||
source /home/waagent/virtualenv/python${{ matrix.python-version }}/bin/activate | ||
fi | ||
if [[ "${{ matrix.python-version }}" =~ ^3\.[1-9][0-9]+$ ]]; then | ||
./ci/pytest.sh | ||
else | ||
if [[ "${{ matrix.use_virtual_environment}}" == "true" ]]; then | ||
export NOSEOPTS="--verbose ${{ matrix.additional-nose-opts }}" | ||
else | ||
export NOSEOPTS="--verbose --with-timer ${{ matrix.additional-nose-opts }}" | ||
fi | ||
./ci/nosetests.sh | ||
fi | ||
- name: Compile Coverage | ||
if: matrix.python-version == '3.9' | ||
run: | | ||
echo looking for coverage files : | ||
ls -alh | grep -i coverage | ||
sudo env "PATH=$PATH" coverage combine coverage.*.data | ||
sudo env "PATH=$PATH" coverage xml | ||
sudo env "PATH=$PATH" coverage report | ||
- name: Upload Coverage | ||
if: matrix.python-version == '3.9' | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
file: ./coverage.xml |