Skip to content

Instantly share code, notes, and snippets.

@mfurquimdev
Created February 21, 2023 15:05
Show Gist options
  • Save mfurquimdev/04b0539f6e4d4b9c16b4974cdf3eac11 to your computer and use it in GitHub Desktop.
Save mfurquimdev/04b0539f6e4d4b9c16b4974cdf3eac11 to your computer and use it in GitHub Desktop.
Automatically run Haskell unit tests inside docker upon change on ./src/* files
#!/bin/bash
pushd pangram
stack test --allow-different-user --install-ghc
#!/bin/bash
inotifywait -q -m -e close_write -r pangram/src/ | while read -r path event filename;
do
clear
echo -e "\n\n\033[1;7;37mExecuting ./execute.sh because $path$filename was $event\033[0;1;0m"
./execute.sh
done;
#!/bin/bash
./install_dependencies.sh
./update_yaml.py
./execute.sh
./hotload.sh
#!/bin/bash
apt update && apt install -y inotify-tools python3-pip
pip3 install pyyaml
#!/bin/bash
docker run -it --rm -v "${PWD}:/app" -w /app haskell ./init.sh
#!/usr/bin/python3
from yaml import dump
from yaml import load
from yaml import YAMLError
try:
from yaml import CLoader as Loader
from yaml import CDumper as Dumper
except ImportError:
from yaml import Loader
from yaml import Dumper
import pprint
with open("pangram/package.yaml", "r") as stream:
try:
data = load(stream, Loader=Loader)
except YAMLError as exc:
print(exc)
def append_if_not_present(m_list, item):
"""Append item if not present in m_list"""
if m_list is None:
m_list = [item]
else:
if item not in m_list:
m_list.append(item)
return m_list
data["library"]["dependencies"] = append_if_not_present(
data["library"]["dependencies"],
"containers",
)
data["tests"]["test"]["dependencies"] = append_if_not_present(
data["tests"]["test"]["dependencies"],
"containers",
)
pprint.pprint(data)
with open("pangram/package.yaml", "w") as stream:
try:
output = dump(data, Dumper=Dumper)
stream.write(output)
except YAMLError as exc:
print(exc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment