Skip to content

Commit

Permalink
Incorporate lib build for MacOS into CI (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
vineetjai authored Mar 31, 2020
1 parent 25c5a73 commit 08e4712
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 37 deletions.
Binary file added .DS_Store
Binary file not shown.
42 changes: 33 additions & 9 deletions .github/workflows/pyzpkpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest']
python-version: [3.5, 3.6, 3.7]

steps:
Expand All @@ -24,12 +25,26 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
hash -r
pip3 install -r requirements.txt
pip3 install -r requirements_dev.txt
python setup.py install
if [ ${{ matrix.os }} == ubuntu-latest ]
then
sudo apt-get update
python -m pip install --upgrade pip
hash -r
pip3 install -r requirements.txt
pip3 install -r requirements_dev.txt
python3 setup.py install
elif [ ${{ matrix.os }} == macos-latest ]
then
brew update
python -m pip install --upgrade pip
hash -r
pip3 install -r requirements.txt
pip3 install -r requirements_dev.txt
python3 setup.py install
else
exit 1
fi
shell: bash
- name: Lint, format, and type-check
run: |
pip install flake8
Expand All @@ -40,8 +55,17 @@ jobs:
flake8 test
- name: Building Library
run: |
chmod 557 build.sh
./build.sh
if [ ${{ matrix.os }} == ubuntu-latest ]
then
chmod 557 build.sh
./build.sh
elif [ ${{ matrix.os }} == macos-latest ]
then
chmod 557 build_MacOS.sh
./build_MacOS.sh
else
exit 1
fi
- name: Scan for security issues
run: |
bandit -r syft -ll
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Tests

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
os: [ ubuntu-latest, macos-latest]
python-version: [3.5, 3.6, 3.7]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: actions/[email protected]
id: cache-reqs
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ matrix.python-version }}-pip-${{ hashFiles('requirements*.txt') }}
- name: Install dependencies

run: |
if [ ${{ matrix.os }} == ubuntu-latest ]
then
sudo apt-get update
python -m pip install --upgrade pip
hash -r
pip3 install -r requirements.txt
pip3 install -r requirements_dev.txt
python3 setup.py install
elif [ ${{ matrix.os }} == macos-latest ]
then
brew update
python -m pip install --upgrade pip
hash -r
pip3 install -r requirements.txt
pip3 install -r requirements_dev.txt
python3 setup.py install
else
exit 1
fi
shell: bash
- name: Lint, format, and type-check
run: |
pip3 install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Scan for security issues
run: |
bandit -r syft -ll
- name: Run tests
run: |
coverage run -m pytest test
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash

# Updating libboost to run the cmake (requirement)
# Updating libboost to run the cmake (requirement)
sudo apt-get install libboost-all-dev
# Updating libprocps to run the cmake (requirement)
# Updating libprocps to run the cmake (requirement)
sudo apt-get install libprocps-dev

rm -r libsnark
#Initialization of libsnark
#Sync & Initialization of libsnark
git submodule sync
git submodule init
# Update libsnark in order to pull down the files.
git submodule update --init --recursive
Expand All @@ -21,4 +22,3 @@ cd build
cmake ..

make

39 changes: 28 additions & 11 deletions build_MacOS.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
#!/bin/bash

cd libsnark
mkdir build
cd build
#Initialization of libsnark
git submodule init
#installing Dependencies
brew list cmake || brew install cmake
brew list gmp || brew install gmp
brew list boost || brew install boost
brew list gcc || brew install gcc
bre list pkg-config || brew install pkg-config

# Removing old directory
rm -rf libsnark

#Sync & Initialization of libsnark
git submodule sync
git submodule intit

# Update libsnark in order to pull down the files.
git submodule update --init --recursive
git submodule update --init --recursive
# Reset all submodules
git submodule foreach --recursive git reset --hard

brew install cmake
brew install gmp
brew install boost
brew install gcc
ln -s /usr/local/opt/openssl/include/openssl /usr/local/include
cd libsnark
mkdir build
cd build

#Exporting Flags
LD_LIBRARY_PATH=/usr/local/opt/openssl/lib:"${LD_LIBRARY_PATH}"
CPATH=/usr/local/opt/openssl/include:"${CPATH}"
PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig:"${PKG_CONFIG_PATH}"
export LD_LIBRARY_PATH CPATH PKG_CONFIG_PATH

CPPFLAGS=-I/usr/local/opt/openssl/include
LDFLAGS=-L/usr/local/opt/openssl/lib
PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
cmake -DWITH_PROCPS=OFF -DWITH_SUPERCOP=OFF ..


Expand Down
7 changes: 4 additions & 3 deletions pyzpk/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import torch

def sum(x,y):

return torch.add(x, y)

def sum(x, y):

return torch.add(x, y)
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pytest>=4.5.0
bandit
coverage>=4.5.3
pre-commit
flake8
22 changes: 13 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os
from setuptools import find_packages
from setuptools import setup
#reads a file

# reads a file
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()

#get the requirements from text file "requirements.txt"

# get the requirements from text file "requirements.txt"
def get_requirements(req_file):
"""Read requirements file and return packages and git repos separately"""
requirements = []
Expand All @@ -20,19 +22,21 @@ def get_requirements(req_file):


REQ_DIR = os.path.dirname(os.path.abspath(__file__))
core_reqs, core_dependency_links = get_requirements(os.path.join(REQ_DIR, "requirements.txt"))
core_reqs, core_dependency_links = get_requirements(
os.path.join(REQ_DIR, "requirements.txt")
)
long_description = read("README.md")


setup(
name='pyzpk',
name="pyzpk",
long_description=long_description,
packages=find_packages(),
version = '0.1',
author='',
url='https://github.com/Benardi/PyZPK',
download_url='https://github.com/Benardi/PyZPK/archive/master.zip',
version="0.1",
author="",
url="https://github.com/Benardi/PyZPK",
download_url="https://github.com/Benardi/PyZPK/archive/master.zip",
install_requires=core_reqs,
dependency_links=core_dependency_links,
setup_requires=["pbr"]
setup_requires=["pbr"],
)
2 changes: 1 addition & 1 deletion test/test_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ def test_list(self):
self.assertEqual(result, [5.0, 6.0])


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()

0 comments on commit 08e4712

Please sign in to comment.