Repository: canonical/cloud-init (branch: wsl-datasource)
Commit date: 2024-01-18T13:21:59Z

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
      - name: "Spellcheck"
        run: |
          tox
        env:
          TOXENV: doc-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/2024-01-18
  UV_INDEX_URL: http://localhost:8629/2024-01-18


Failed build logs:
step_name: Check ruff/6_Test.txt
log: ##[group]Run tox
[36;1mtox[0m
shell: /usr/bin/sh -ex {0}
env:
  TOXENV: ruff
##[endgroup]
+ tox
GLOB sdist-make: /home/runner/work/cloud-init/cloud-init/setup.py
ruff create: /home/runner/work/cloud-init/cloud-init/.tox/ruff
ruff installdeps: ruff===0.0.285
ruff inst: /home/runner/work/cloud-init/cloud-init/.tox/.tmp/package/1/cloud-init-23.4+92.g10cdeb55.zip
ruff installed: attrs==23.2.0,certifi==2023.11.17,charset-normalizer==3.3.2,cloud-init==23.4+92.g10cdeb55,configobj==5.0.8,idna==3.6,importlib-resources==6.1.1,Jinja2==3.1.3,jsonpatch==1.33,jsonpointer==2.4,jsonschema==4.21.0,jsonschema-specifications==2023.12.1,MarkupSafe==2.1.3,netifaces==0.11.0,oauthlib==3.2.2,pkgutil-resolve-name==1.3.10,pyserial==3.5,PyYAML==6.0.1,referencing==0.32.1,requests==2.31.0,rpds-py==0.17.1,ruff==0.0.285,six==1.16.0,urllib3==2.1.0,zipp==3.17.0
ruff run-test-pre: PYTHONHASHSEED='1811068208'
ruff run-test: commands[0] | /home/runner/work/cloud-init/cloud-init/.tox/ruff/bin/python -m ruff cloudinit/ tests/ tools/ packages/bddeb packages/brpm conftest.py setup.py
tests/unittests/sources/test_wsl.py:10:20: F401 [*] `typing.Optional` imported but unused
Found 1 error.
[*] 1 potentially fixable with the --fix option.
ERROR: InvocationError for command /home/runner/work/cloud-init/cloud-init/.tox/ruff/bin/python -m ruff cloudinit/ tests/ tools/ packages/bddeb packages/brpm conftest.py setup.py (exited with code 1)
___________________________________ summary ____________________________________
ERROR:   ruff: commands failed
##[error]Process completed with exit code 1.


Changed files:
tests/unittests/sources/test_wsl.py

Fix diff:
diff --git a/tests/unittests/sources/test_wsl.py b/tests/unittests/sources/test_wsl.py
index 9653cfa42..03b3a1f7d 100644
--- a/tests/unittests/sources/test_wsl.py
+++ b/tests/unittests/sources/test_wsl.py
@@ -7,7 +7,7 @@
 import os
 from copy import deepcopy
 from email.mime.multipart import MIMEMultipart
-from typing import Optional, cast
+from typing import cast
 
 from cloudinit import helpers, util
 from cloudinit.sources import DataSourceWSL as wsl