Repository: canonical/cloud-init (branch: main)
Commit date: 2023-12-07T12:43:24Z

Workflow file: .github/workflows/check_format.yml (Lint Tests)
name: Lint Tests
on:
  pull_request:
  push:
    branches:
      - main

concurrency:
  group: 'ci-${{ github.workflow }}-${{ github.ref }}'
  cancel-in-progress: true
defaults:
  run:
    shell: sh -ex {0}

jobs:
  check_format:
    strategy:
      fail-fast: false
      matrix:
        env: [ruff, mypy, pylint, black, isort]
        lint-with:
          - {tip-versions: false, os: ubuntu-20.04}
          - {tip-versions: true, os: ubuntu-latest}
    name: Check ${{ matrix.lint-with.tip-versions && 'tip-' || '' }}${{ matrix.env }}
    runs-on: ${{ matrix.lint-with.os }}
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    steps:
      - name: "Checkout #1"
        uses: actions/checkout@v3.0.0

      - name: "Checkout #2 (for tools/read-version)"
        run: |
          git fetch --unshallow
          git remote add upstream https://git.launchpad.net/cloud-init

      - name: Dependencies
        run: |
          sudo DEBIAN_FRONTEND=noninteractive apt-get -qy update
          sudo DEBIAN_FRONTEND=noninteractive apt-get -qy install tox

      - name: Print version
        run: python3 --version

      - name: Test
        if: ${{ !matrix.lint-with.tip-versions }}
        env:
          # matrix env: not to be confused w/environment variables or testenv
          TOXENV: ${{ matrix.env }}
        run: tox
      - name: Test (tip versions)
        if: matrix.lint-with.tip-versions
        continue-on-error: true
        env:
          TOXENV: tip-${{ matrix.env }}
        run: tox
  schema-format:
    strategy:
      fail-fast: false
    name: Check json format
    runs-on: ubuntu-22.04
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    steps:
      - name: "Checkout #1"
        uses: actions/checkout@v3.0.0

      - name: "Test format"
        run: |
          tools/check_json_format.sh cloudinit/config/schemas/schema-cloud-config-v1.json
          tools/check_json_format.sh cloudinit/config/schemas/schema-network-config-v1.json
          tools/check_json_format.sh cloudinit/config/schemas/versions.schema.cloud-config.json

  doc:
    strategy:
      fail-fast: false
    name: Check docs
    runs-on: ubuntu-22.04
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    steps:
      - name: "Checkout #1"
        uses: actions/checkout@v3.0.0

      - name: "Checkout #2 (for tools/read-version)"
        run: |
          git fetch --unshallow
          git remote add upstream https://git.launchpad.net/cloud-init
      - name: "Install Python 3.10"
        uses: actions/setup-python@v4
        with:
          python-version: '3.10.8'
      - name: "Install dependencies"
        run: |
          sudo DEBIAN_FRONTEND=noninteractive apt-get -qy update
          sudo DEBIAN_FRONTEND=noninteractive apt-get -qy install tox lintian
      - name: "Spellcheck"
        run: |
          make check_spelling
      - name: "Build docs"
        env:
          TOXENV: doc
        run: |
          tox

  shell-lint:
    name: Shell Lint
    runs-on: ubuntu-22.04
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    steps:
      - name: Checkout
        uses: actions/checkout@v3.0.0

      - name: Install ShellCheck
        run: |
          sudo apt-get update
          sudo apt install shellcheck

      - name: Run ShellCheck
        run: |
          shellcheck ./tools/ds-identify

  check-cla-signers:
    runs-on: ubuntu-22.04
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080
    steps:
      - uses: actions/checkout@v3.0.0

      - name: Check CLA signers file
        run: tools/check-cla-signers

env:
  PIP_INDEX_URL: http://localhost:8629/2023-12-07
  UV_INDEX_URL: http://localhost:8629/2023-12-07


Failed build logs:
step_name: Check pylint/6_Test.txt
log: ##[group]Run tox
[36;1mtox[0m
shell: /usr/bin/sh -ex {0}
env:
  TOXENV: pylint
##[endgroup]
+ tox
GLOB sdist-make: /home/runner/work/cloud-init/cloud-init/setup.py
pylint create: /home/runner/work/cloud-init/cloud-init/.tox/pylint
pylint installdeps: pylint===2.13.9, -r/home/runner/work/cloud-init/cloud-init/test-requirements.txt, -r/home/runner/work/cloud-init/cloud-init/integration-requirements.txt
pylint inst: /home/runner/work/cloud-init/cloud-init/.tox/.tmp/package/1/cloud-init-23.4+28.ge396f22f.zip
pylint installed: adal==1.2.7,appdirs==1.4.4,applicationinsights==0.11.10,argcomplete==3.1.6,astroid==2.11.7,attrs==23.1.0,autopage==0.5.2,azure-cli-core==2.55.0,azure-cli-telemetry==1.1.0,azure-common==1.1.28,azure-core==1.29.5,azure-identity==1.15.0,azure-mgmt-compute==30.3.0,azure-mgmt-core==1.4.0,azure-mgmt-network==25.1.0,azure-mgmt-resource==23.0.1,bcrypt==4.1.1,boto3==1.33.9,botocore==1.33.9,cachetools==5.3.2,certifi==2023.11.17,cffi==1.16.0,charset-normalizer==3.3.2,circuitbreaker==1.4.0,cliff==4.4.0,cloud-init==23.4+28.ge396f22f,cmd2==2.4.3,configobj==5.0.8,coverage==7.3.2,cryptography==41.0.7,debtcollector==2.5.0,decorator==5.1.1,dill==0.3.7,distro==1.8.0,dogpile.cache==1.2.2,exceptiongroup==1.2.0,google-api-core==2.14.0,google-api-python-client==2.109.0,google-auth==2.25.1,google-auth-httplib2==0.1.1,googleapis-common-protos==1.61.0,httplib2==0.22.0,humanfriendly==10.0,ibm-cloud-sdk-core==3.18.0,ibm-platform-services==0.47.1,ibm-vpc==0.20.0,idna==3.6,importlib-metadata==7.0.0,importlib-resources==6.1.1,iniconfig==2.0.0,iso8601==2.1.0,isodate==0.6.1,isort==5.12.0,Jinja2==3.1.2,jmespath==1.0.1,jsonpatch==1.33,jsonpointer==2.4,jsonschema==4.20.0,jsonschema-specifications==2023.11.2,keystoneauth1==5.4.0,knack==0.11.0,lazy-object-proxy==1.9.0,MarkupSafe==2.1.3,mccabe==0.7.0,msal==1.26.0,msal-extensions==1.0.0,msgpack==1.0.7,msrest==0.7.1,msrestazure==0.6.4,netaddr==0.9.0,netifaces==0.11.0,oauthlib==3.2.2,oci==2.117.0,openstacksdk==1.4.0,os-service-types==1.7.0,osc-lib==2.9.0,oslo.config==9.2.0,oslo.i18n==6.2.0,oslo.serialization==5.2.0,oslo.utils==6.3.0,packaging==23.2,paramiko==3.3.1,passlib==1.7.4,pbr==6.0.0,pkginfo==1.9.6,pkgutil-resolve-name==1.3.10,platformdirs==4.1.0,pluggy==1.3.0,portalocker==2.8.2,prettytable==3.9.0,protobuf==3.19.6,psutil==5.9.6,pyasn1==0.5.1,pyasn1-modules==0.3.0,pycloudlib==1!5.11.0,pycparser==2.21,pygments==2.17.2,PyJWT==2.8.0,pylint==2.13.9,PyNaCl==1.5.0,pyOpenSSL==23.3.0,pyparsing==2.4.7,pyperclip==1.8.2,pyserial==3.5,pytest==7.4.3,pytest-cov==4.1.0,pytest-mock==3.12.0,python-cinderclient==9.4.0,python-dateutil==2.8.2,python-keystoneclient==5.2.0,python-novaclient==18.4.0,python-openstackclient==6.4.0,pytz==2023.3.post1,PyYAML==6.0.1,qemu.qmp==0.0.3,referencing==0.31.1,requests==2.31.0,requests-oauthlib==1.3.1,requestsexceptions==1.4.0,responses==0.24.1,rfc3986==2.0.0,rpds-py==0.13.2,rsa==4.9,s3transfer==0.8.2,simplejson==3.19.2,six==1.16.0,stevedore==5.1.0,tabulate==0.9.0,toml==0.10.0,tomli==2.0.1,typing-extensions==4.8.0,tzdata==2023.3,uritemplate==4.1.1,urllib3==2.1.0,wcwidth==0.2.12,wrapt==1.16.0,zipp==3.17.0
pylint run-test-pre: PYTHONHASHSEED='1481622646'
pylint run-test: commands[0] | /home/runner/work/cloud-init/cloud-init/.tox/pylint/bin/python -m pylint cloudinit/ tests/ tools/ conftest.py setup.py
************* Module tests.unittests.test_net_activators
tests/unittests/test_net_activators.py:329: [E0213(no-self-argument), TestNetworkManagerActivatorBringUp.fake_isfile_no_nmconn] Method should have "self" as first argument
tests/unittests/test_net_activators.py:330: [E1101(no-member), TestNetworkManagerActivatorBringUp.fake_isfile_no_nmconn] Instance of 'TestNetworkManagerActivatorBringUp' has no 'endswith' member

------------------------------------
Your code has been rated at 10.00/10

ERROR: InvocationError for command /home/runner/work/cloud-init/cloud-init/.tox/pylint/bin/python -m pylint cloudinit/ tests/ tools/ conftest.py setup.py (exited with code 2)
___________________________________ summary ____________________________________
ERROR:   pylint: commands failed
##[error]Process completed with exit code 1.


Changed files:
tests/unittests/test_net_activators.py

Fix diff:
diff --git a/tests/unittests/test_net_activators.py b/tests/unittests/test_net_activators.py
index 0b3c11c1a..c14425fd6 100644
--- a/tests/unittests/test_net_activators.py
+++ b/tests/unittests/test_net_activators.py
@@ -326,15 +326,12 @@ class TestActivatorsBringDown:
 
 
 class TestNetworkManagerActivatorBringUp:
-    def fake_isfile_no_nmconn(filename):
-        return False if filename.endswith(".nmconnection") else True
-
     @patch("cloudinit.subp.subp", return_value=("", ""))
     @patch(
         "cloudinit.net.network_manager.available_nm_ifcfg_rh",
         return_value=True,
     )
-    @patch.object(os.path, "isfile", side_effect=fake_isfile_no_nmconn)
+    @patch.object(os.path, "isfile")
     @patch("os.path.exists", return_value=True)
     def test_bring_up_interface_no_nm_conn(
         self, m_exists, m_isfile, m_plugin, m_subp
@@ -344,6 +341,12 @@ class TestNetworkManagerActivatorBringUp:
         present and ifcfg interface config files are also present. In this
         case, we should use ifcfg files.
         """
+
+        def fake_isfile_no_nmconn(filename):
+            return False if filename.endswith(".nmconnection") else True
+
+        m_isfile.side_effect = fake_isfile_no_nmconn
+
         expected_call_list = [
             (
                 (
@@ -377,6 +380,7 @@ class TestNetworkManagerActivatorBringUp:
                 {},
             ),
         ]
+
         index = 0
         assert NetworkManagerActivator.bring_up_interface("eth0")
         for call in m_subp.call_args_list:
@@ -388,7 +392,7 @@ class TestNetworkManagerActivatorBringUp:
         "cloudinit.net.network_manager.available_nm_ifcfg_rh",
         return_value=False,
     )
-    @patch.object(os.path, "isfile", side_effect=fake_isfile_no_nmconn)
+    @patch.object(os.path, "isfile")
     @patch("os.path.exists", return_value=True)
     def test_bring_up_interface_no_plugin_no_nm_conn(
         self, m_exists, m_isfile, m_plugin, m_subp
@@ -398,6 +402,11 @@ class TestNetworkManagerActivatorBringUp:
         not present. In this case, we can't use ifcfg file and the
         interface bring up should fail.
         """
+
+        def fake_isfile_no_nmconn(filename):
+            return False if filename.endswith(".nmconnection") else True
+
+        m_isfile.side_effect = fake_isfile_no_nmconn
         assert not NetworkManagerActivator.bring_up_interface("eth0")
 
     @patch("cloudinit.subp.subp", return_value=("", ""))