From 39b7550ece4f49b609a6a2ec887493c538b84f30 Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Wed, 16 Dec 2020 16:22:50 -0800 Subject: [PATCH] Add GitHub action to lint python code. Only takes a minute or two, so it's good to have "always on" in production and custom branches. Just for comparison, also run -1 version (3.7) and +1 version (3.9). --- .github/workflows/python-lint.yml | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/python-lint.yml diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml new file mode 100644 index 00000000000000..f17fcf3ede6adb --- /dev/null +++ b/.github/workflows/python-lint.yml @@ -0,0 +1,63 @@ +# This is a basic workflow to help you get started with Actions + +name: Lint all Python code + +# Triggers the workflow on push or pull request events +on: + push: + pull_request: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "pylint" + pylint: + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + # The type of runner that the job will run on + env: + PYTHON_CMD: "python${{ matrix.python-version }}" + PLARGS: "${{ matrix.extra_args }}" + + strategy: + matrix: + python-version: ['3.8'] + experimental: [false] + extra_args: [''] + include: + - python-version: '3.7' + experimental: true + extra_args: "--disable=not-context-manager" + - python-version: '3.9' + experimental: true + extra_args: "--disable=unsubscriptable-object,inherit-non-class" + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Checkout submodules + run: git submodule update --init --recursive + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + ${PYTHON_CMD} -m pip install --upgrade pip + ${PYTHON_CMD} -m pip install wheel pylint + sudo apt install -y libcurl4-openssl-dev + ${PYTHON_CMD} -m pip install numpy sympy psutil raven setproctitle cffi \ + json-rpc websocket-client nose hexdump matplotlib crcmod tqdm requests \ + zmq logentries PyJWT scipy libusb1 SCons Cython jinja2 atomicwrites \ + pyserial pyyaml pycapnp smbus2 parameterized pycurl azure-storage-blob==2.1.0 \ + dictdiffer + + - name: script + run: | + pylint --extension-pkg-whitelist=zmq -j 0 -E --reports=y ${PLARGS} `find ./ -name \*.py | grep -v '^[.]/external' | \ + sed 's|[.]/||;s|/.*||' | sort -u`