Skip to content

Commit

Permalink
Merge pull request #56 from nucypher/ferveo-light-tdec
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec authored Apr 5, 2023
2 parents a02e6d8 + 681d9c5 commit 8fa25b6
Show file tree
Hide file tree
Showing 77 changed files with 11,744 additions and 2,834 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Adopted from: https://github.com/nucypher/rust-umbral/blob/master/.github/workflows/wheels.yml

name: Wheels

on: workflow_dispatch

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest, macos-11 ]

env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel"
CIBW_BEFORE_BUILD_LINUX: "pip3 install --upgrade keyrings.alt"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'
CIBW_SKIP: "cp36-* pp* *-win32 *musllinux*" # only using manylinux to build

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- if: runner.os == 'Windows'
run: |
echo 'PATH=/c/Python38:/c/Python38/Scripts:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/Strawberry/c/bin:$PATH' >> $GITHUB_ENV
echo 'RUSTFLAGS=-Ctarget-feature=+crt-static' >> $GITHUB_ENV
echo 'RUSTFLAGS=-Ctarget-feature=+crt-static' >> $GITHUB_ENV
echo 'CIBW_BEFORE_BUILD=python -m pip install --upgrade pip' >> $GITHUB_ENV
- if: runner.os != 'Linux'
name: Setup env when not using docker
run: |
python -m pip install --upgrade wheel setuptools setuptools-rust
- if: runner.os == 'Linux'
name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: arm64

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'

- name: Install cibuildwheel
run: |
# Install cibuildwheel from git for CIBW_ARCHS_LINUX support
python -m pip install cibuildwheel==2.9.0
- if: runner.os == 'Linux'
run: |
cp -r ./ferveo ./ferveo-python/ferveo
cp -r ./ferveo-common ./ferveo-python/ferveo-common
cp -r ./tpke ./ferveo-python/tpke
- if: runner.os == 'Linux'
working-directory: ./ferveo-python
name: Relocate dependencies in cargo.toml
run: |
sed -i 's/..\/ferveo/.\/ferveo/g' Cargo.toml
sed -i 's/..\/tpke/.\/tpke/g' Cargo.toml
- name: Build wheels
working-directory: ./ferveo-python
run: |
pwd
ls -la
cd ferveo-python && python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v2
with:
path: ./ferveo-python/wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'

- name: Install setuptools and setuptools-rust
working-directory: ./ferveo-python
run: |
python -m pip install --upgrade wheel setuptools setuptools-rust
# Assuming here that the version of the Python bindings
# is matched to the version of the main Rust crate (as it should be at all times),
# and we are running this at a release commit.
- name: Replace the relative path to `ferveo` in Cargo.toml with the specific version
working-directory: ./ferveo-python
run: python replace_version.py relative-to-published

- name: Build sdist
working-directory: ./ferveo-python
run: python setup.py sdist

# Roll back the changes
- name: Replace the specific version of `ferveo` in Cargo.toml with the relative path
if: always()
working-directory: ./ferveo-python
run: python replace_version.py published-to-relative

- uses: actions/upload-artifact@v2
with:
path: ./ferveo-python/dist/*.tar.gz

upload_pypi:
needs: [ build_wheels, build_sdist ]
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: actions/download-artifact@v2
with:
name: artifact
path: wheelhouse

- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
56 changes: 54 additions & 2 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
matrix:
include:
- target: x86_64-unknown-linux-gnu
rust: 1.63 # MSRV, `cargo msrv`
rust: 1.64 # MSRV, `cargo msrv`
- target: x86_64-unknown-linux-gnu
rust: stable
steps:
Expand All @@ -77,6 +77,56 @@ jobs:
- run: cargo check --all-features
- run: cargo test --release --all-features

wasm-test:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.64 # MSRV
- stable
target:
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- run: cargo install wasm-pack
- run: wasm-pack test --node
working-directory: tpke-wasm

yarn-test:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
target:
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- run: cargo install wasm-pack
- run: wasm-pack build --target nodejs
working-directory: tpke-wasm
- uses: borales/[email protected]
with:
cmd: --cwd tpke-wasm/examples/node install
- uses: borales/[email protected]
with:
cmd: --cwd tpke-wasm/examples/node build
- uses: borales/[email protected]
with:
cmd: --cwd tpke-wasm/examples/node test

codecov:
runs-on: ubuntu-latest
needs: [ test ]
Expand Down Expand Up @@ -128,10 +178,12 @@ jobs:
restore-keys: ${{ runner.os }}-cargo-
- name: Run benchmark for base branch comparison
uses: boa-dev/criterion-compare-action@v3
if: github.event_name == 'pull_request'
# Only PRs to main
if: github.event_name == 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'nucypher/ferveo'
with:
cwd: ${{ matrix.component }}
branchName: ${{ github.base_ref }}
features: "test-common"

# The next steps have been adapted from https://raw.githubusercontent.com/unicode-org/icu4x/main/.github/workflows/build-test.yml

Expand Down
Loading

0 comments on commit 8fa25b6

Please sign in to comment.