Skip to content

Commit

Permalink
Separate lint into several jobs (#2467)
Browse files Browse the repository at this point in the history
* Separate lint for flask

* Seaparate lint for resource-detector-container

* Add linting workflow

* Update contributing documentation

* Fix lint workflow

* Add fix for resource-detector-container

* Separate lint for sdk-extension-aws

* Separate lint for distro

* Separate lint for opentelemetry-instrumentation

* Separate lint for aiohttp-client

* Separate lint for aiohttp-server

* Separate lint for aiopg

* Separate lint for aws-lambda

* Separate lint for botocore

* Separate lint for boto3sqs

* Separate lint for django

* Separate lint for dbapi

* Separate lint for boto

* Separate lint for elasticsearch

* Separate lint for falcon

* Separate lint for fastapi

* Separate lint for urllib

* Separate lint for urllib3

* Separate lint for requests

* Separate lint for starlette

* Separate lint for jinja2

* Seaparate lint for logging and richconsole

* Separate lint for prometheus-remote-write

* Separate lint for mysql

* Separate lint for mysqlclient

* Separate lint for psycopg2

* Separate lint for psycopg

* Separate lint for pymemcache

* Separate lint for pymongo

* Separate lint for pymysql

* Separate lint for pyramid

* Separate lint for asgi

* Separate lint for asyncpg

* Separate lint for sqlite3

* Separate lint for wsgi

* Separate lint for grpc

* Separate lint for sqlalchemy

* Separate lint for redis

* Separate lint for remoulade

* Separate lint for celery and sklearn

* Separate lint for system-metrics

* Separate lint for threading

* Separate lint for tornado

* Separate lint for tortoiseorm

* Separate lint for httpx

* Separate lint for propagator-aws-xray

* Remove lint

* Separate lint for propagator-ot-trace

* Separate lint for sio-pika

* Separate lint for aio-pika

* Fix aio and sio pika

* Separate lint for kafka-python

* Separate lint for confluent-kafka

* Separate lint for asyncio

* Separate lint for cassandra

* Separate lint for processor-baggage

* Remove lint test environment

* Rename lint workflow file

* Fix sio-pika lint testing package path

* More fixes

* Fix linting for opentelemetry-instrumentation

* Add section for linting with 3.8

* Add missing lint install command for elasticsearch

* Sorted packages
  • Loading branch information
ocelotl authored Apr 30, 2024
1 parent de7ce0f commit 5116305
Show file tree
Hide file tree
Showing 4 changed files with 543 additions and 84 deletions.
121 changes: 121 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Lint tests

on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 955c92e91b5cd4bcfb43c39efcef086b040471d2

jobs:
lint-3_11:
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
package:
- "distro"
- "exporter-prometheus-remote-write"
- "exporter-richconsole"
- "instrumentation-aio-pika"
- "instrumentation-aiohttp-client"
- "instrumentation-aiohttp-server"
- "instrumentation-aiopg"
- "instrumentation-asgi"
- "instrumentation-asyncio"
- "instrumentation-asyncpg"
- "instrumentation-aws-lambda"
- "instrumentation-boto"
- "instrumentation-boto3sqs"
- "instrumentation-botocore"
- "instrumentation-cassandra"
- "instrumentation-celery"
- "instrumentation-confluent-kafka"
- "instrumentation-dbapi"
- "instrumentation-django"
- "instrumentation-elasticsearch"
- "instrumentation-falcon"
- "instrumentation-fastapi"
- "instrumentation-flask"
- "instrumentation-grpc"
- "instrumentation-httpx"
- "instrumentation-jinja2"
- "instrumentation-kafka-python"
- "instrumentation-logging"
- "instrumentation-mysql"
- "instrumentation-mysqlclient"
- "instrumentation-psycopg"
- "instrumentation-psycopg2"
- "instrumentation-pymemcache"
- "instrumentation-pymongo"
- "instrumentation-pymysql"
- "instrumentation-pyramid"
- "instrumentation-redis"
- "instrumentation-remoulade"
- "instrumentation-requests"
- "instrumentation-sio-pika"
- "instrumentation-sqlalchemy"
- "instrumentation-sqlite3"
- "instrumentation-starlette"
- "instrumentation-system-metrics"
- "instrumentation-threading"
- "instrumentation-tornado"
- "instrumentation-tortoiseorm"
- "instrumentation-urllib"
- "instrumentation-urllib3"
- "instrumentation-wsgi"
- "opentelemetry-instrumentation"
- "processor-baggage"
- "propagator-aws-xray"
- "propagator-ot-trace"
- "resource-detector-container"
- "sdk-extension-aws"
os: [ubuntu-20.04]
runs-on: ubuntu-20.04
steps:
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install tox
run: pip install tox
- name: Cache tox environment
# Preserves .tox directory between runs for faster installs
uses: actions/cache@v4
with:
path: |
.tox
~/.cache/pip
key: v7-build-tox-cache-${{ matrix.package }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
- name: run tox
run: tox -e lint-${{ matrix.package }}

lint-3_8:
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
package:
- "instrumentation-sklearn"
os: [ubuntu-20.04]
runs-on: ubuntu-20.04
steps:
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install tox
run: pip install tox
- name: Cache tox environment
# Preserves .tox directory between runs for faster installs
uses: actions/cache@v4
with:
path: |
.tox
~/.cache/pip
key: v7-build-tox-cache-${{ matrix.package }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
- name: run tox
run: tox -e lint-${{ matrix.package }}
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
tox-environment: [ "docker-tests", "spellcheck", "lint", "docs", "generate" ]
tox-environment: [ "docker-tests", "spellcheck", "docs", "generate" ]
name: ${{ matrix.tox-environment }}
runs-on: ubuntu-20.04
steps:
Expand All @@ -25,9 +25,6 @@ jobs:
python-version: "3.10"
- name: Install tox
run: pip install tox
- name: Install libsnappy-dev
if: ${{ matrix.tox-environment == 'lint' }}
run: sudo apt-get install -y libsnappy-dev
- name: Cache tox environment
# Preserves .tox directory between runs for faster installs
uses: actions/cache@v4
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ You can run `tox` with the following arguments:
- `tox -e py311-test-instrumentation-aiopg` to e.g. run the aiopg instrumentation unit tests under a specific
Python version
- `tox -e spellcheck` to run a spellcheck on all the code
- `tox -e lint` to run lint checks on all code
- `tox -e lint-some-package` to run lint checks on `some-package`

`black` and `isort` are executed when `tox -e lint` is run. The reported errors can be tedious to fix manually.
An easier way to do so is:

1. Run `.tox/lint/bin/black .`
2. Run `.tox/lint/bin/isort .`
1. Run `.tox/lint-some-package/bin/black .`
2. Run `.tox/lint-some-package/bin/isort .`

See
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini)
Expand Down
Loading

0 comments on commit 5116305

Please sign in to comment.