Generate workflow files with a Jinja template (#2687)

* Generate workflow files with a Jinja template

Fixes #2686

* Remove sudo from allowlist_externals

* Update workflows

* Add condition to skip generate-workflows

* Update workflows

* Update .github/workflows/generate_workflows_lib/src/generate_workflows_lib/test.yml.j2

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* Update .github/workflows/generate_workflows_lib/src/generate_workflows_lib/misc.yml.j2

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* Update .github/workflows/generate_workflows_lib/src/generate_workflows_lib/lint.yml.j2

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* Update .github/workflows/generate_workflows_lib/src/generate_workflows_lib/contrib.yml.j2

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* Update workflows

* Update workflows

---------

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
This commit is contained in:
Diego Hurtado
2024-08-06 16:27:38 -06:00
committed by GitHub
parent 2a707bccce
commit f0d8cb39e9
19 changed files with 10051 additions and 284 deletions

14
.github/workflows/generate_workflows.py vendored Normal file
View File

@ -0,0 +1,14 @@
from pathlib import Path
from generate_workflows_lib import (
generate_test_workflow,
generate_lint_workflow,
generate_misc_workflow
)
tox_ini_path = Path(__file__).parent.parent.parent.joinpath("tox.ini")
workflows_directory_path = Path(__file__).parent
generate_test_workflow(tox_ini_path, workflows_directory_path, "ubuntu-latest")
generate_lint_workflow(tox_ini_path, workflows_directory_path)
generate_misc_workflow(tox_ini_path, workflows_directory_path)

View File

@ -0,0 +1,15 @@
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from pathlib import Path
class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
with open(
Path(__file__).parent.parent.parent.parent.joinpath("tox.ini")
) as tox_ini_file_0:
with open(
Path(__file__).parent.joinpath("src/generate_workflows_lib/tox.ini"), "w"
) as tox_ini_file_1:
tox_ini_file_1.write(tox_ini_file_0.read())

View File

@ -0,0 +1,32 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "generate-workflows-lib"
dynamic = ["version"]
description = "A library to generate workflows"
license = "Apache-2.0"
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Typing :: Typed",
]
dependencies = ["Jinja2", "tox"]
[tool.hatch.version]
path = "src/generate_workflows_lib/version.py"
[tool.hatch.build.targets.wheel.hooks.custom]

View File

@ -0,0 +1 @@
tox.ini

View File

@ -0,0 +1,267 @@
from re import compile as re_compile
from jinja2 import Environment, FileSystemLoader
from pathlib import Path
from tox.config.cli.parse import get_options
from tox.session.state import State
from tox.config.sets import CoreConfigSet
from tox.config.source.tox_ini import ToxIni
from collections import defaultdict
_tox_test_env_regex = re_compile(
r"(?P<python_version>py\w+)-test-"
r"(?P<name>[-\w]+\w)-?(?P<test_requirements>\d+)?"
)
_tox_lint_env_regex = re_compile(r"lint-(?P<name>[-\w]+)")
_tox_contrib_env_regex = re_compile(
r"py38-test-(?P<name>[-\w]+\w)-?(?P<contrib_requirements>\d+)?"
)
def get_tox_envs(tox_ini_path: Path) -> list:
tox_ini = ToxIni(tox_ini_path)
conf = State(get_options(), []).conf
tox_section = next(tox_ini.sections())
core_config_set = (
CoreConfigSet(conf, tox_section, tox_ini_path.parent, tox_ini_path)
)
(
core_config_set.
loaders.
extend(
tox_ini.
get_loaders(
tox_section,
base=[],
override_map=defaultdict(list, {}),
conf=core_config_set
)
)
)
return core_config_set.load("env_list")
def get_test_job_datas(tox_envs: list, operating_systems: list) -> list:
os_alias = {
"ubuntu-latest": "Ubuntu",
"windows-latest": "Windows"
}
python_version_alias = {
"pypy3": "pypy-3.8",
"py38": "3.8",
"py39": "3.9",
"py310": "3.10",
"py311": "3.11",
"py312": "3.12",
}
test_job_datas = []
for operating_system in operating_systems:
for tox_env in tox_envs:
tox_test_env_match = _tox_test_env_regex.match(tox_env)
if tox_test_env_match is None:
continue
groups = tox_test_env_match.groupdict()
aliased_python_version = (
python_version_alias[groups["python_version"]]
)
tox_env = tox_test_env_match.string
test_requirements = groups["test_requirements"]
if test_requirements is None:
test_requirements = " "
else:
test_requirements = f"-{test_requirements} "
test_job_datas.append(
{
"name": f"{tox_env}_{operating_system}",
"ui_name": (
f"{groups['name']}"
f"{test_requirements}"
f"{aliased_python_version} "
f"{os_alias[operating_system]}"
),
"python_version": aliased_python_version,
"tox_env": tox_env,
"os": operating_system
}
)
return test_job_datas
def get_lint_job_datas(tox_envs: list) -> list:
lint_job_datas = []
for tox_env in tox_envs:
tox_lint_env_match = _tox_lint_env_regex.match(tox_env)
if tox_lint_env_match is None:
continue
tox_env = tox_lint_env_match.string
lint_job_datas.append(
{
"name": f"{tox_env}",
"ui_name": f"{tox_lint_env_match.groupdict()['name']}",
"tox_env": tox_env,
}
)
return lint_job_datas
def get_contrib_job_datas(tox_envs: list) -> list:
contrib_job_datas = []
for tox_env in tox_envs:
tox_contrib_env_match = _tox_contrib_env_regex.match(tox_env)
if tox_contrib_env_match is None:
continue
groups = tox_contrib_env_match.groupdict()
tox_env = tox_contrib_env_match.string
contrib_requirements = groups["contrib_requirements"]
if contrib_requirements is None:
contrib_requirements = " "
else:
contrib_requirements = f"-{contrib_requirements} "
contrib_job_datas.append(
{
"ui_name": (
f"{groups['name']}"
f"{contrib_requirements}"
),
"tox_env": tox_env,
}
)
return contrib_job_datas
def get_misc_job_datas(tox_envs: list) -> list:
misc_job_datas = []
_tox_benchmark_env_regex = re_compile(r"benchmark.+")
for tox_env in tox_envs:
if (
_tox_test_env_regex.match(tox_env) is not None or
_tox_lint_env_regex.match(tox_env) is not None or
_tox_contrib_env_regex.match(tox_env) is not None or
_tox_benchmark_env_regex.match(tox_env) is not None
):
continue
misc_job_datas.append(tox_env)
return misc_job_datas
def _generate_workflow(
job_datas: list, name: str, workflow_directory_path: Path
):
# Github seems to limit the amount of jobs in a workflow file, that is why
# they are split in groups of 250 per workflow file.
for file_number, job_datas in enumerate(
[
job_datas[index:index + 250]
for index in range(0, len(job_datas), 250)
]
):
with open(
workflow_directory_path.joinpath(f"{name}_{file_number}.yml"),
"w"
) as test_yml_file:
test_yml_file.write(
Environment(
loader=FileSystemLoader(Path(__file__).parent)
).get_template(f"{name}.yml.j2").render(
job_datas=job_datas, file_number=file_number
)
)
test_yml_file.write("\n")
def generate_test_workflow(
tox_ini_path: Path,
workflow_directory_path: Path,
*operating_systems
) -> None:
_generate_workflow(
get_test_job_datas(get_tox_envs(tox_ini_path), operating_systems),
"test",
workflow_directory_path
)
def generate_lint_workflow(
tox_ini_path: Path,
workflow_directory_path: Path,
) -> None:
_generate_workflow(
get_lint_job_datas(get_tox_envs(tox_ini_path)),
"lint",
workflow_directory_path
)
def generate_contrib_workflow(
workflow_directory_path: Path,
) -> None:
_generate_workflow(
get_contrib_job_datas(
get_tox_envs(Path(__file__).parent.joinpath("tox.ini"))
),
"contrib",
workflow_directory_path
)
def generate_misc_workflow(
tox_ini_path: Path,
workflow_directory_path: Path,
) -> None:
_generate_workflow(
get_misc_job_datas(get_tox_envs(tox_ini_path)),
"misc",
workflow_directory_path
)

View File

@ -0,0 +1,47 @@
# Do not edit this file.
# This file is generated automatically by executing tox -e generate-workflows
name: Contrib {{ file_number }}
on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: ${% raw %}{{ github.sha }}{% endraw %}
CONTRIB_REPO_SHA: main
PIP_EXISTS_ACTION: w
jobs:
{%- for job_data in job_datas %}
{{ job_data.tox_env }}:
name: {{ job_data.ui_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout contrib repo @ SHA - ${% raw %}{{ env.CONTRIB_REPO_SHA }}{% endraw %}
uses: actions/checkout@v4
with:
repository: open-telemetry/opentelemetry-python-contrib
ref: ${% raw %}{{ env.CONTRIB_REPO_SHA }}{% endraw %}
- name: Checkout core repo @ SHA - ${% raw %}{{ github.sha }}{% endraw %}
uses: actions/checkout@v4
with:
repository: open-telemetry/opentelemetry-python
path: opentelemetry-python-core
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"
architecture: "x64"
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e {{ job_data.tox_env }} -- -ra
{%- endfor %}

View File

@ -0,0 +1,37 @@
# Do not edit this file.
# This file is generated automatically by executing tox -e generate-workflows
name: Lint {{ file_number }}
on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: main
CONTRIB_REPO_SHA: main
PIP_EXISTS_ACTION: w
jobs:
{%- for job_data in job_datas %}
{{ job_data.name }}:
name: {{ job_data.ui_name }}
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${% raw %}{{ github.sha }}{% endraw %}
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e {{ job_data.tox_env }}
{%- endfor %}

View File

@ -0,0 +1,67 @@
# Do not edit this file.
# This file is generated automatically by executing tox -e generate-workflows
name: Misc {{ file_number }}
on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: main
CONTRIB_REPO_SHA: main
PIP_EXISTS_ACTION: w
jobs:
{%- for job_data in job_datas %}
{{ job_data }}:
name: {{ job_data }}
runs-on: ubuntu-latest
{%- if job_data == "generate-workflows" %}
if: |
!contains(github.event.pull_request.labels.*.name, 'Skip generate-workflows')
&& github.actor != 'opentelemetrybot'
{%- endif %}
steps:
- name: Checkout repo @ SHA - ${% raw %}{{ github.sha }}{% endraw %}
uses: actions/checkout@v4
{%- if job_data == "public-symbols-check" %}
with:
fetch-depth: 0
- name: Checkout main
run: git checkout main
- name: Pull origin
run: git pull --rebase=false origin main
- name: Checkout pull request
run: git checkout ${% raw %}{{ github.event.pull_request.head.sha }}{% endraw %}
{%- endif %}
{%- if job_data != "shellcheck" %}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
{%- endif %}
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e {{ job_data }}
{%- if job_data == "generate-workflows" %}
- name: Check workflows are up to date
run: git diff --exit-code || (echo 'Generated workflows are out of date, run "tox -e generate-workflows" and commit the changes in this PR.' && exit 1)
{%- endif %}
{%- if job_data == "generate" %}
- name: Check workflows are up to date
run: git diff --exit-code || (echo 'Generated code is out of date, run "tox -e generate" and commit the changes in this PR.' && exit 1)
{%- endif %}
{%- endfor %}

View File

@ -0,0 +1,42 @@
# Do not edit this file.
# This file is generated automatically by executing tox -e generate-workflows
name: Test {{ file_number }}
on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: main
CONTRIB_REPO_SHA: main
PIP_EXISTS_ACTION: w
jobs:
{%- for job_data in job_datas %}
{{ job_data.name }}:
name: {{ job_data.ui_name }}
runs-on: {{ job_data.os }}
steps:
- name: Checkout repo @ SHA - ${% raw %}{{ github.sha }}{% endraw %}
uses: actions/checkout@v4
- name: Set up Python {{ job_data.python_version }}
uses: actions/setup-python@v5
with:
python-version: "{{ job_data.python_version }}"
- name: Install tox
run: pip install tox
{%- if job_data.os == "windows-latest" %}
- name: Configure git to support long filenames
run: git config --system core.longpaths true
{%- endif %}
- name: Run tests
run: tox -e {{ job_data.tox_env }} -- -ra
{%- endfor %}

View File

@ -0,0 +1 @@
__version__ = "0.1.0"

View File

@ -1,119 +0,0 @@
name: Contrib Repo Tests
on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: main
jobs:
instrumentations-0:
env:
# We use these variables to convert between tox and GHA version literals
py38: 3.8
py39: 3.9
py310: "3.10"
py311: "3.11"
py312: "3.12"
pypy3: pypy-3.8
RUN_MATRIX_COMBINATION: ${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
python-version: [py38, py39, py310, py311, py312, pypy3]
package:
# Do not add more instrumentations here, add them in instrumentations_1.yml.
# The reason for this separation of instrumentations into more than one YAML file is
# the limit of jobs that can be run from a Github actions matrix:
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
# "A matrix will generate a maximum of 256 jobs per workflow run. This limit applies
# to both GitHub-hosted and self-hosted runners."
- "aiohttp-client"
- "aiohttp-server"
- "aiopg"
- "aio-pika"
- "asgi"
- "asyncpg"
- "aws-lambda"
- "boto"
- "boto3sqs"
- "botocore"
- "cassandra"
- "celery"
- "confluent-kafka"
- "dbapi"
- "django"
- "elasticsearch"
- "falcon"
- "fastapi"
- "flask"
- "grpc"
- "httpx"
- "jinja2"
- "kafka-python"
- "logging"
- "mysql"
- "mysqlclient"
- "sio-pika"
- "psycopg2"
- "pymemcache"
- "pymongo"
- "pymysql"
- "pyramid"
- "redis"
- "remoulade"
- "requests"
- "sqlalchemy"
- "sqlite3"
- "starlette"
- "system-metrics"
- "tornado"
- "tortoiseorm"
os: [ubuntu-20.04]
exclude:
- python-version: py312
package: "boto"
- python-version: py312
package: "kafka-python"
- python-version: pypy3
package: "aiopg"
- python-version: pypy3
package: "asyncpg"
- python-version: pypy3
package: "boto"
- python-version: pypy3
package: "boto3sqs"
- python-version: pypy3
package: "botocore"
- python-version: pypy3
package: "psycopg2"
- python-version: pypy3
package: "remoulade"
- python-version: pypy3
package: "requests"
- python-version: pypy3
package: "confluent-kafka"
- python-version: pypy3
package: "grpc"
steps:
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python ${{ env[matrix.python-version] }}
uses: actions/setup-python@v5
with:
python-version: ${{ env[matrix.python-version] }}
- 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-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('gen-requirements.txt', 'dev-requirements.txt') }}
- name: run tox
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra

View File

@ -1,95 +0,0 @@
name: Lint tests
on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: main
jobs:
lint-3_12:
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-azure"
- "resource-detector-container"
- "sdk-extension-aws"
- "util-http"
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.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- 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 }}

1061
.github/workflows/lint_0.yml vendored Normal file

File diff suppressed because it is too large Load Diff

129
.github/workflows/misc_0.yml vendored Normal file
View File

@ -0,0 +1,129 @@
# Do not edit this file.
# This file is generated automatically by executing tox -e generate-workflows
name: Misc 0
on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: main
CONTRIB_REPO_SHA: main
PIP_EXISTS_ACTION: w
jobs:
spellcheck:
name: spellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e spellcheck
docker-tests:
name: docker-tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e docker-tests
docs:
name: docs
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e docs
generate:
name: generate
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e generate
- name: Check workflows are up to date
run: git diff --exit-code || (echo 'Generated code is out of date, run "tox -e generate" and commit the changes in this PR.' && exit 1)
generate-workflows:
name: generate-workflows
runs-on: ubuntu-latest
if: |
!contains(github.event.pull_request.labels.*.name, 'Skip generate-workflows')
&& github.actor != 'opentelemetrybot'
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e generate-workflows
- name: Check workflows are up to date
run: git diff --exit-code || (echo 'Generated workflows are out of date, run "tox -e generate-workflows" and commit the changes in this PR.' && exit 1)
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e shellcheck

View File

@ -1,19 +0,0 @@
name: Shellcheck
on:
push:
branches-ignore:
- 'release/*'
pull_request:
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install shellcheck
run: sudo apt update && sudo apt install --assume-yes shellcheck
- name: Run shellcheck
run: find . -name \*.sh | xargs shellcheck --severity=warning

View File

@ -1,40 +0,0 @@
name: Contrib Repo Tests
on:
push:
branches-ignore:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: main
jobs:
misc:
strategy:
fail-fast: false
matrix:
tox-environment: [ "docker-tests", "spellcheck", "docs", "generate" ]
name: ${{ matrix.tox-environment }}
runs-on: ubuntu-20.04
steps:
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- 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-misc-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt', 'gen-requirements.txt', 'docs-requirements.txt') }}
- name: run tox
run: tox -e ${{ matrix.tox-environment }}
- name: Ensure generated code is up to date
if: matrix.tox-environment == 'generate'
run: git diff --exit-code || (echo 'Generated code is out of date, please run "tox -e generate" and commit the changes in this PR.' && exit 1)

4517
.github/workflows/test_0.yml vendored Normal file

File diff suppressed because it is too large Load Diff

3797
.github/workflows/test_1.yml vendored Normal file

File diff suppressed because it is too large Load Diff

35
tox.ini
View File

@ -73,11 +73,8 @@ envlist =
; 1: django~=3.0
; 2: django>=4.0b1,<5.0 backports.zoneinfo==0.2.1
; 3: django>=4.0b1,<5.0
py3{8,9}-test-instrumentation-django-0
py3{8,9}-test-instrumentation-django-1
py3{8,9}-test-instrumentation-django-2
py3{10,11,12}-test-instrumentation-django-1
py3{10,11,12}-test-instrumentation-django-3
py3{8,9}-test-instrumentation-django-{0,1,2}
py3{10,11,12}-test-instrumentation-django-{1,3}
pypy3-test-instrumentation-django-{0,1}
lint-instrumentation-django
@ -109,8 +106,8 @@ envlist =
; 0: falcon ==1.4.1
; 1: falcon >=2.0.0,<3.0.0
; 2: falcon >=3.0.0,<4.0.0
py3{8,9}-test-instrumentation-falcon-0
py3{8,9,10,11,12}-test-instrumentation-falcon-{1,2}
py3{8,9}-test-instrumentation-falcon-{0,1,2}
py3{10,11,12}-test-instrumentation-falcon-{1,2}
pypy3-test-instrumentation-falcon-{0,1,2}
lint-instrumentation-falcon
@ -254,7 +251,6 @@ envlist =
; 0: grpcio==1.62.0
; 1: grpcio==1.63.0
py3{8,9,10,11,12}-test-instrumentation-grpc-{0,1}
pypy3-test-instrumentation-grpc-{0,1}
lint-instrumentation-grpc
; opentelemetry-instrumentation-sqlalchemy
@ -355,7 +351,6 @@ envlist =
; opentelemetry-instrumentation-confluent-kafka
py3{8,9,10,11,12}-test-instrumentation-confluent-kafka
pypy3-test-instrumentation-confluent-kafka
lint-instrumentation-confluent-kafka
; opentelemetry-instrumentation-asyncio
@ -376,8 +371,9 @@ envlist =
spellcheck
docker-tests
docs
generate
generate-workflows
shellcheck
[testenv]
deps =
@ -387,7 +383,8 @@ deps =
; FIXME: add coverage testing
; FIXME: add mypy testing
allowlist_externals = sh
allowlist_externals =
sh
setenv =
; override CORE_REPO_SHA via env variable when testing other branches/commits than main
@ -1318,3 +1315,19 @@ commands =
{toxinidir}/scripts/generate_instrumentation_bootstrap.py
{toxinidir}/scripts/generate_instrumentation_readme.py
{toxinidir}/scripts/generate_instrumentation_metapackage.py
[testenv:generate-workflows]
commands_pre =
pip install {toxinidir}/.github/workflows/generate_workflows_lib
commands =
python {toxinidir}/.github/workflows/generate_workflows.py
[testenv:shellcheck]
commands_pre =
sh -c "sudo apt update -y && sudo apt install --assume-yes shellcheck"
commands =
sh -c "find {toxinidir} -name \*.sh | xargs shellcheck --severity=warning"