Skip to content

Commit

Permalink
Split CI matrix run over several runners
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Dec 5, 2024
1 parent cc497fb commit dde6325
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ jobs:
unittest-linux:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
compiler: [g++-10, clang++-18]
dwarf_version: [4, 5]
steps:
- uses: actions/checkout@v4
- name: dependencies
Expand All @@ -147,7 +152,7 @@ jobs:
cpptrace/ci/setup-prerequisites-unittest.sh
- name: build and test
run: |
python3 ci/unittest.py
python3 ci/unittest.py --slice=compiler:${{matrix.compiler}} --slice=dwarf_version:${{matrix.dwarf_version}}
unittest-linux-bazel:
runs-on: ubuntu-22.04
steps:
Expand All @@ -157,10 +162,10 @@ jobs:
sudo apt install -y libtool libncurses5
- name: test dbg
run: |
bazel test //... -c dbg
bazel test //... -c dbg
- name: test opt
run: |
bazel test //... -c opt
bazel test //... -c opt
unittest-macos:
runs-on: macos-14
steps:
Expand Down
24 changes: 22 additions & 2 deletions ci/util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import subprocess
import sys
import itertools
from typing import List
from typing import List, Dict
from colorama import Fore, Back, Style
import re
import time
Expand All @@ -23,6 +23,7 @@ class MatrixRunner:
def __init__(self, matrix, exclude):
self.matrix = matrix
self.exclude = exclude
self.include = self.parse_includes()
self.keys = [*matrix.keys()]
self.values = [*matrix.values()]
self.results = {} # insertion-ordered
Expand All @@ -32,6 +33,17 @@ def __init__(self, matrix, exclude):
self.last_matrix_config = None
self.current_matrix_config = None

def parse_includes(self) -> Dict[str, List[str]]:
includes: Dict[str, List[str]] = dict()
for arg in sys.argv:
if arg.startswith("--slice="):
rest = arg[len("--slice="):]
key, value = rest.split(":")
if key not in includes:
includes[key] = []
includes[key].append(value)
return includes

def run_command(self, *args: List[str], always_output=False, output_matcher=None) -> bool:
self.log(f"{Fore.CYAN}{Style.BRIGHT}Running Command \"{' '.join(args)}\"{Style.RESET_ALL}")
start_time = time.time()
Expand Down Expand Up @@ -78,6 +90,11 @@ def log(self, *args, **kwargs):
def do_exclude(self, matrix_config, exclude):
return all(map(lambda k: matrix_config[k] == exclude[k], exclude.keys()))

def do_include(self, matrix_config, include):
if len(include) == 0:
return True
return all(map(lambda k: matrix_config[k] in include[k], include.keys()))

def assignment_to_matrix_config(self, assignment):
matrix_config = {}
for k, v in zip(self.matrix.keys(), assignment):
Expand All @@ -87,7 +104,10 @@ def assignment_to_matrix_config(self, assignment):
def get_work(self):
work = []
for assignment in itertools.product(*self.matrix.values()):
if any(map(lambda ex: self.do_exclude(self.assignment_to_matrix_config(assignment), ex), self.exclude)):
config = self.assignment_to_matrix_config(assignment)
if any(map(lambda ex: self.do_exclude(config, ex), self.exclude)):
continue
if not self.do_include(config, self.include):
continue
work.append(assignment)
return work
Expand Down

0 comments on commit dde6325

Please sign in to comment.