Skip to content

Commit

Permalink
Add benchmarks action (OpenMined#286)
Browse files Browse the repository at this point in the history
* add benchmarks action

* add code security workflows
  • Loading branch information
bcebere authored Apr 28, 2021
1 parent 3c4959a commit 7902a18
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "CodeQL config"

paths:
- tenseal
- tests
paths-ignore:
- third_party
60 changes: 60 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Benchmarks
on:
push:
branches: [master]
release:
types: [created]

jobs:
benchmark:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8]
os: [macos-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Prepare ENV
run: |
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Install dependencies Ubuntu
run: .github/workflows/scripts/install_req_ubuntu.sh
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Install dependencies MacOS
run: .github/workflows/scripts/install_req_macos.sh
if: ${{ matrix.os == 'macos-latest' }}
- name: Install dependencies Windows
run: .github/workflows/scripts/install_req_windows.bat
if: ${{ matrix.os == 'windows-latest' }}
- name: Install dependencies Windows - msbuild
uses: microsoft/[email protected]
if: ${{ matrix.os == 'windows-latest' }}
- name: Build the library for Ubuntu/MacOS
run: .github/workflows/scripts/build_nix.sh
if: ${{ matrix.os != 'windows-latest' }}
- name: Build the library for Windows
run: .github/workflows/scripts/build_windows.bat
if: ${{ matrix.os == 'windows-latest' }}
- name: Run benchmarks
run: |
pytest tests/python/benchmarks/ --cov-fail-under 0 --benchmark-json pytest_benchmarks_output.json
- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
with:
name: Python-Benchmarks
tool: "pytest"
output-file-path: pytest_benchmarks_output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
benchmark-data-dir-path: "benchmarks/${{ runner.os }}"
# Show alert with commit comment on detecting possible performance regression
alert-threshold: "200%"
comment-on-alert: true
fail-on-alert: true
46 changes: 46 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "CodeQL"

on:
push:
branches: [ master ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'python' ]

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true

- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
third_party/
build/
key: codeql-${{ runner.os }}-${{ matrix.language }}-tensealdeps-${{ hashFiles('third_party/SEAL/cmake/SEALConfig.cmake','.gitmodules') }}
restore-keys: |
codeql-${{ runner.os }}-${{ matrix.language }}-tensealdeps-
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml

- if: matrix.language == 'cpp'
name: Build CPP
run: |
mkdir -p build && cd build
cmake .. && make -j
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
29 changes: 29 additions & 0 deletions .github/workflows/ossar-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow integrates a collection of open source static analysis tools
# with GitHub code scanning. For documentation, or to provide feedback, visit
# https://github.com/github/ossar-action
name: OSSAR

on:
push:
branches: [ master ]

jobs:
OSSAR-Scan:
# OSSAR runs on windows-latest.
# ubuntu-latest and macos-latest support coming soon
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Run open source static analysis tools
- name: Run OSSAR
uses: github/ossar-action@v1
id: ossar

# Upload results to the Security tab
- name: Upload OSSAR results
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ${{ steps.ossar.outputs.sarifFile }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ You can benchmark the implementation at any point by running
$ bazel run -c opt --spawn_strategy=standalone //tests/cpp/benchmarks:benchmark
```

The benchmarks from every PR merge are uploaded [here](https://openmined.github.io/TenSEAL/benchmarks/).

## Tutorials

- [Getting Started](tutorials%2FTutorial%200%20-%20Getting%20Started.ipynb)
Expand Down
3 changes: 3 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ flake8
numpy
pytest>=5.4.1
pytest-benchmark
pytest-cov
pytest-benchmark[histogram]
setuptools>=41.0.0
pygal
pygaljs
scikit-image
torch
torchvision
12 changes: 0 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
[bumpversion]
current_version = 0.3.2
commit = True
tag = True
files = tenseal/version.py
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+)(?P<n>\d+))?
serialize =
{major}.{minor}.{patch}{release}{n}
{major}.{minor}.{patch}

[bumpversion:part:release]
optional_value = gamma
values =
a
b
rc
gamma

[bumpversion:part:n]

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def build_extension(self, ext):
build_args += ["--", "/m"]
else:
cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]
build_args += ["--", "-j"]
build_args += ["--", "-j", "2"]

env = os.environ.copy()
env["CXXFLAGS"] = '{} -DVERSION_INFO=\\"{}\\"'.format(
Expand Down
2 changes: 1 addition & 1 deletion tenseal/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.2"
__version__ = "0.3.3"

0 comments on commit 7902a18

Please sign in to comment.