open-telemetry / open-telemetry/opentelemetry-python-contrib

generate_workflows_lib: leverage github matrix in CI

Open
#3,547 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build & infra
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

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 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated .github/workflows/test_0.yml and trace it back to the workflow generation scripts and tox targets. Group targets by tested library, then compare generated workflows with the proposed GitHub matrix approach. Benchmark CI run timings and confirm that the generated workflows remain correct while reducing duplication.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, python
Domain
build-system, ci-cd
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.