Skip to content

Commit

Permalink
adding jobs matrix
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Aug 11, 2022
1 parent 427cfcb commit 3bdd36f
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,32 @@ These examples are used as a submodule and cloned for:

facts.json are generated (and validated) by cle, and
atoms.asp (to be generated) are generated (and validated) by spliced.

## Organization

Each subfolder here is a type of structure or design that can be used to generate
facts. Within each subfolder, there is an optional folder of "breaks" with
ABI breakages that we've manually derived for a ground truth. To see
a table of this ground truth, you can see [this Google Doc](https://docs.google.com/spreadsheets/d/1ZuRxphEg3N1FGnw2-viThhoP8CVr_SebSa9jwol6G3s/edit?userstoinvite=thaines.astro%40gmail.com&actionButton=1#gid=0).

## Usage

To manually build on your local machine with whatever compiler is available
(defaults to gcc)

```bash
$ make
```

To choose a specific compiler:

```bash
make CC=g++
```

To generate a matrix for GitHub actions:

```bash
$ python matrix.py
```

86 changes: 86 additions & 0 deletions matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env python3

import argparse
import os
import random
import re
import json
import sys
import tempfile

import yaml

here = os.path.dirname(os.path.abspath(__file__))


def get_parser():
parser = argparse.ArgumentParser(
description="Smeagle-Examples Experiment Submitter",
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument(
"experiment_dir",
help="Base directory with experiment folders",
default=here,
nargs="?",
)
return parser


def recursive_find(base, pattern=None):
"""
Find filenames that match a particular pattern, and yield them.
"""
# We can identify modules by finding module.lua
for root, folders, files in os.walk(base):
for file in files:
fullpath = os.path.abspath(os.path.join(root, file))

if pattern and not re.search(pattern, fullpath):
continue

yield fullpath


def read_yaml(filename):
with open(filename, "r") as fd:
content = yaml.load(fd.read(), Loader=yaml.SafeLoader)
return content


def main():

parser = get_parser()

# If an error occurs while parsing the arguments, the interpreter will exit with value 2
args, extra = parser.parse_known_args()

experiment_dir = os.path.abspath(args.experiment_dir)

# We will build up a matrix of experiments
# We will want to shuffle to not do the same builds at once
matrix = []
seen = set()

# Recursively find experiments
for experiment_cpp in recursive_find(experiment_dir, "example.cpp"):
if "breaks" in experiment_cpp:
continue
dirname = os.path.dirname(experiment_cpp)
if dirname in seen or os.path.basename(dirname).startswith("_"):
continue

matrix.append({"root": dirname})
seen.add(dirname)

print("Generated %s jobs" % len(matrix))
print("Shuffling...")
random.shuffle(matrix)

# Only print matrix to output (and GitHub actions output)
print(matrix)
print("::set-output name=commands::%s\n" % json.dumps(matrix))


if __name__ == "__main__":
main()

0 comments on commit 3bdd36f

Please sign in to comment.