Skip to content

generate_workflows_lib: leverage github matrix in CI #3547

Open
@xrmx

Description

@xrmx
Contributor

There has been discussions in the past on leveraging github matrix instead of providing our explicit own. Benefit of this would be less and smaller workflow files.

I sketched how a first step in that direct may look in the snippet below (on top of a rendered test workflow for core); the benefit of this would be around 10 lines of llines removed from workflows files for each tox target.

Since these workflows are generated from tox targets the missing step in our workflow generation scripts would be to group them by tested library.

We also need to benchmark if any change there would affect CI run timings.

diff --git a/.github/workflows/test_0.yml b/.github/workflows/test_0.yml
index 6136b9288..0c306b750 100644
--- a/.github/workflows/test_0.yml
+++ b/.github/workflows/test_0.yml
@@ -25,27 +25,35 @@ env:
        'main'
     ) || 'main' }}
   PIP_EXISTS_ACTION: w
+  py39: "3.9"
+  py310: "3.10"
+  py311: "3.11"
+  py312: "3.12"
+  py313: "3.13"
+  pypy: "pypy-3.9"
 
 jobs:
 
-  py39-test-opentelemetry-api_ubuntu-latest:
-    name: opentelemetry-api 3.9 Ubuntu
+  test-opentelemetry-api_ubuntu-latest:
     runs-on: ubuntu-latest
     timeout-minutes: 30
+    strategy:
+      matrix:
+        version: [py39, py310, py311, py312, py313, pypy]
     steps:
       - name: Checkout repo @ SHA - ${{ github.sha }}
         uses: actions/checkout@v4
 
-      - name: Set up Python 3.9
+      - name: Set up Python ${{ env[matrix.version] }}
         uses: actions/setup-python@v5
         with:
-          python-version: "3.9"
+          python-version: ${{ env[matrix.version] }}
 
       - name: Install tox
         run: pip install tox
 
       - name: Run tests
-        run: tox -e py39-test-opentelemetry-api -- -ra
+        run: tox -e ${{ matrix.version }}-test-opentelemetry-api -- -ra
 
   py310-test-opentelemetry-api_ubuntu-latest:
     name: opentelemetry-api 3.10 Ubuntu

Activity

emdneto

emdneto commented on Jun 9, 2025

@emdneto
Member

yeah I think it can works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @xrmx@emdneto

        Issue actions

          generate_workflows_lib: leverage github matrix in CI · Issue #3547 · open-telemetry/opentelemetry-python-contrib