Skip to content

Instantly share code, notes, and snippets.

@martijnbastiaan
Created April 26, 2023 16:20
Show Gist options
  • Save martijnbastiaan/a3aa184a5b3607ed4c805ee95265eda8 to your computer and use it in GitHub Desktop.
Save martijnbastiaan/a3aa184a5b3607ed4c805ee95265eda8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import os
import subprocess
import tempfile
def run(args, cwd):
return subprocess.run(args, cwd=cwd, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
def comb_to_string(comb):
ghc, hashable, primitive = comb
return f"ghc-{ghc}, hashable-{hashable}, primitive-{primitive}"
def combs():
ghc_versions = ["9.2.7", "9.0.2", "8.10.7", "8.8.4", "8.6.5"]
hashable_versions = ["1.4.2.0", "1.4.1.0", "1.4.0.2"]
primitive_versions = ["0.8.0.0", "0.7.4.0"]
for ghc in ghc_versions:
for hashable in hashable_versions:
for primtive in primitive_versions:
yield (ghc, hashable, primtive)
def try_comb(comb):
ghc, hashable, primitive = comb
with tempfile.TemporaryDirectory() as tmpdir:
project_root = os.path.join(tmpdir, "clash-compiler")
run(
["git", "clone", "git@github.com:clash-lang/clash-compiler.git", "--depth", "1"], tmpdir
)
try:
run(
[ "cabal", "build", "clash-lib"
, f"--with-compiler", f"ghc-{ghc}"
, f"--constraint=hashable=={hashable}"
, f"--constraint=primitive=={primitive}"
], project_root)
except subprocess.CalledProcessError as e:
return (True, comb, e.stdout)
return (False, comb, "")
if __name__ == '__main__':
from multiprocessing import Pool
with Pool(6) as p:
for result in p.imap_unordered(try_comb, combs()):
(failed, comb, output) = result
if failed:
print(f"FAIL: {comb_to_string(comb)}")
with open(f"/tmp/fails/{comb_to_string(comb)}.log", "w") as fp:
fp.write(output)
else:
print(f"OK: {comb_to_string(comb)}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment