Skip to content

Commit

Permalink
Merge pull request #3 from slivingston/ci-fix
Browse files Browse the repository at this point in the history
Fix CI
  • Loading branch information
jgraeb authored Oct 1, 2024
2 parents 7496be4 + af80d55 commit d4b4e3d
Show file tree
Hide file tree
Showing 8 changed files with 1,732 additions and 19 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# configuration for GitHub Actions
name: flowsynth tests
on:
push:
pull_request:

jobs:
build:
name: Build and test
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [
'3.10',
]
steps:
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
cache: true
- name: Setup testing environment
run: |
sudo apt update
sudo apt install -y \
libgraphviz-dev \
graphviz
- name: Install Python dependencies
run: |
pdm install
- name: Build and install Spot
run: |
pdm run python get_spot.py
- name: Run tests
run: |
pdm run pytest -v tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ __pycache__/
*.ipynb_checkpoints
*.log
*.DS_Store
*~
*.json
*.txt

Expand Down
20 changes: 14 additions & 6 deletions get_spot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Download and install spot. (Code adapted from tulip-control/dd/download.py)"""
import hashlib
import tarfile
import urllib.error
import urllib.request
Expand All @@ -9,13 +10,17 @@
import sys

SPOT_VERSION: _ty.Final = '2.12'
SPOT_SHA256: _ty.Final = '26ba076ad57ec73d2fae5482d53e16da95c47822707647e784d8c7cec0d10455'
SPOT_TARBALL: _ty.Final = f'spot-{SPOT_VERSION}.tar.gz'
SPOT_URL: _ty.Final = ('http://www.lrde.epita.fr/dload/spot/'
f'spot-{SPOT_VERSION}.tar.gz')
FILE_PATH = os.path.dirname(os.path.realpath(__file__))
SPOT_PATH = os.path.join(FILE_PATH,f'spot-{SPOT_VERSION}')
ENV_PATH = sys.prefix

def is_hash_correct(filename):
return SPOT_SHA256 == hashlib.sha256(open(filename, 'rb').read()).hexdigest()

def fetch_spot():
filename = SPOT_TARBALL
fetch(SPOT_URL, filename)
Expand All @@ -24,6 +29,8 @@ def fetch_spot():

def fetch(url,filename):
if os.path.isfile(filename):
if not is_hash_correct(filename):
raise RuntimeError(f'File `{filename}` already present but has unexpected hash.')
print(
f'File `{filename}` already present.')
return
Expand All @@ -45,6 +52,8 @@ def fetch(url,filename):
f'{response.url}\n'
'Wrote the downloaded data to file: '
f'`{filename}`\n')
if not is_hash_correct(filename):
raise RuntimeError(f'Downloaded file `{filename}` has unexpected hash.')

def untar(filename):
print(f'++ unpack: {filename}')
Expand All @@ -55,12 +64,11 @@ def untar(filename):
def make_spot():
"""Compile spot."""
path = SPOT_PATH
cmd = ["./configure --prefix "+ ENV_PATH]
print('running: '+str(cmd)+' in '+path)
# subprocess.call(cmd, cwd=path)
subprocess.check_call('./configure --prefix /flowsynth/.venv', shell=True, cwd=path)
subprocess.call(['make'], cwd=path)
subprocess.call(['make','install'], cwd=path)
cmd = f'./configure --prefix {ENV_PATH}'
print(f'running: `{cmd}` in {path}')
subprocess.check_call(cmd, shell=True, cwd=path)
subprocess.check_call(['make'], cwd=path)
subprocess.check_call(['make','install'], cwd=path)

if __name__ == '__main__':
fetch_spot()
1,671 changes: 1,671 additions & 0 deletions pdm.lock

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,3 @@ readme = "README.md"

[project.scripts]
from_json = "flowsynth.main:main"

[tool.pytest.ini_options]
pythonpath = [
"src"
]
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[pytest]
testpaths="./tests/"
pythonpath = src
8 changes: 4 additions & 4 deletions tests/test_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import sys
sys.path.append('../')
from src.flowsynth.components.automata import get_system_automaton, get_tester_automaton, get_product_automaton
from src.flowsynth.components.transition_system import TransitionSystemInput, TranSys
from src.flowsynth.components.product import sync_prod
from src.flowsynth.optimization.optimize import solve
from flowsynth.components.automata import get_system_automaton, get_tester_automaton, get_product_automaton
from flowsynth.components.transition_system import TransitionSystemInput, TranSys
from flowsynth.components.product import sync_prod
from flowsynth.optimization.optimize import solve

def test_sample():
states_list = [0,1,2,3,4,5]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_reactive_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import sys
sys.path.append('../')
from src.flowsynth.components.automata import get_system_automaton, get_tester_automaton, get_product_automaton
from src.flowsynth.components.transition_system import TransitionSystemInput, TranSys
from src.flowsynth.components.product import sync_prod
from src.flowsynth.optimization.optimize import solve
from flowsynth.components.automata import get_system_automaton, get_tester_automaton, get_product_automaton
from flowsynth.components.transition_system import TransitionSystemInput, TranSys
from flowsynth.components.product import sync_prod
from flowsynth.optimization.optimize import solve

def test_reactive():
states_list = ['init', 'd1', 'd2', 'int_goal', 'p1', 'p2', 'goal']
Expand Down

0 comments on commit d4b4e3d

Please sign in to comment.