Skip to content

Commit

Permalink
Merge pull request hyperledger#43 from andrewwhitehead/fix/conc-upd
Browse files Browse the repository at this point in the history
Reliability improvements
  • Loading branch information
andrewwhitehead authored Apr 19, 2022
2 parents 6505119 + 3a9135a commit 76fcda4
Show file tree
Hide file tree
Showing 34 changed files with 2,884 additions and 1,849 deletions.
141 changes: 73 additions & 68 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ name: "Aries-Askar"

jobs:
check:
name: Run Checks
name: Run checks
strategy:
fail-fast: false
matrix:
os: [macos-11, windows-latest, ubuntu-latest]
os: [ubuntu-latest, macos-11, windows-latest]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -30,36 +31,51 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: 1.56
override: true
components: clippy, rustfmt

- name: Cache cargo resources
uses: Swatinem/rust-cache@v1
with:
sharedKey: deps

- name: Cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace
sharedKey: check
cache-on-failure: true

- name: Cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace

- name: Debug build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-targets

- name: Test
- if: "runner.os == 'Linux'"
name: Start postgres (Linux)
run: |
sudo systemctl start postgresql.service
pg_isready
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres'"
echo "POSTGRES_URL=postgres://postgres:postgres@localhost:5432/test-db" >> $GITHUB_ENV
echo "TEST_FEATURES=pg_test" >> $GITHUB_ENV
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace
args: --workspace --features "${{ env.TEST_FEATURES }}" -- --nocapture --test-threads 1 --skip contention
env:
RUST_BACKTRACE: full
# RUST_LOG: debug

- name: Test askar-crypto no_std
uses: actions-rs/cargo@v1
Expand All @@ -73,52 +89,12 @@ jobs:
command: test
args: --manifest-path ./askar-bbs/Cargo.toml --no-default-features

test-postgres:
name: Postgres
runs-on: ubuntu-latest
needs: [check]

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

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

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Cache cargo resources
uses: Swatinem/rust-cache@v1
with:
sharedKey: deps

- name: Test
uses: actions-rs/cargo@v1
env:
POSTGRES_URL: postgres://postgres:postgres@localhost:5432/test-db
with:
command: test
args: --features pg_test

build-manylinux:
name: Build Library
name: Build (manylinux)
needs: [check]

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
Expand All @@ -136,16 +112,18 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: 1.56
override: true

- name: Cache cargo resources
uses: Swatinem/rust-cache@v1
with:
sharedKey: deps
sharedKey: check

- name: Build library
env:
BUILD_TARGET: ${{ matrix.target }}
# LIBSQLITE3_FLAGS: SQLITE_DEBUG SQLITE_MEMDEBUG
run: sh ./build.sh

- name: Upload library artifacts
Expand All @@ -154,20 +132,21 @@ jobs:
name: library-${{ runner.os }}
path: target/release/${{ matrix.lib }}

build-other:
name: Build Library
build-native:
name: Build (native)
needs: [check]

strategy:
fail-fast: false
matrix:
include:
- os: macos-11
lib: libaries_askar.dylib
target: apple-darwin # creates a universal library
toolchain: beta # beta required for aarch64-apple-darwin target
toolchain: nightly-2021-10-21 # beta required for aarch64-apple-darwin target
- os: windows-latest
lib: aries_askar.dll
toolchain: stable
toolchain: 1.56

runs-on: ${{ matrix.os }}

Expand All @@ -180,16 +159,18 @@ jobs:
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true

- name: Cache cargo resources
uses: Swatinem/rust-cache@v1
with:
sharedKey: deps
sharedKey: check

- name: Build library
env:
BUILD_TARGET: ${{ matrix.target }}
BUILD_TOOLCHAIN: ${{ matrix.toolchain }}
# LIBSQLITE3_FLAGS: SQLITE_DEBUG SQLITE_MEMDEBUG
run: sh ./build.sh

- name: Upload library artifacts
Expand All @@ -199,10 +180,11 @@ jobs:
path: target/release/${{ matrix.lib }}

build-py:
name: Build Python
needs: [build-manylinux, build-other]
name: Build Python packages
needs: [build-manylinux, build-native]

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
python-version: [3.7]
Expand Down Expand Up @@ -236,19 +218,42 @@ jobs:
name: library-${{ runner.os }}
path: wrappers/python/aries_askar/

- name: Build and test python package
- if: "runner.os == 'Linux'"
name: Start postgres (Linux)
run: |
sudo systemctl start postgresql.service
pg_isready
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres'"
echo "POSTGRES_URL=postgres://postgres:postgres@localhost:5432/test-db" >> $GITHUB_ENV
- name: Build package
shell: sh
run: |
python setup.py bdist_wheel --python-tag=py3 --plat-name=${{ matrix.plat-name }}
pip install pytest pytest-asyncio dist/*
python -m pytest
TEST_STORE_URI=sqlite://test.db python -m pytest
working-directory: wrappers/python

- if: "runner.os == 'Linux'"
name: Auditwheel
name: Audit wheel
run: auditwheel show wrappers/python/dist/*

- name: Test package
shell: sh
run: |
pip install pytest pytest-asyncio dist/*
echo "-- Test SQLite in-memory --"
python -m pytest --log-cli-level=WARNING -k "not contention"
echo "-- Test SQLite file DB --"
TEST_STORE_URI=sqlite://test.db python -m pytest --log-cli-level=WARNING -k "not contention"
if [ -n "$POSTGRES_URL" ]; then
echo "-- Test Postgres DB --"
TEST_STORE_URI="$POSTGRES_URL" python -m pytest --log-cli-level=WARNING -k "not contention"
fi
working-directory: wrappers/python
env:
no_proxy: "*" # python issue 30385
RUST_BACKTRACE: full
# RUST_LOG: debug

- name: Upload python package
uses: actions/upload-artifact@v2
with:
Expand Down
13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["askar-bbs", "askar-crypto"]

[package]
name = "aries-askar"
version = "0.2.4"
version = "0.2.5"
authors = ["Hyperledger Aries Contributors <aries@lists.hyperledger.org>"]
edition = "2018"
description = "Hyperledger Aries Askar secure storage"
Expand All @@ -27,7 +27,7 @@ rustdoc-args = ["--cfg", "docsrs"]
default = ["all_backends", "ffi", "logger"]
all_backends = ["any", "postgres", "sqlite"]
any = []
ffi = ["any", "ffi-support", "logger", "option-lock"]
ffi = ["any", "ffi-support", "logger"]
jemalloc = ["jemallocator"]
logger = ["env_logger", "log"]
postgres = ["sqlx", "sqlx/postgres", "sqlx/tls"]
Expand All @@ -38,7 +38,7 @@ pg_test = ["postgres"]
hex-literal = "0.3"

[dependencies]
async-lock = "2.4"
async-lock = "2.5"
async-stream = "0.3"
bs58 = "0.4"
chrono = "0.4"
Expand All @@ -53,7 +53,6 @@ itertools = "0.10"
jemallocator = { version = "0.3", optional = true }
log = { version = "0.4", optional = true }
num_cpus = { version = "1.0", optional = true }
option-lock = { version = "0.3", optional = true }
once_cell = "1.5"
percent-encoding = "2.0"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -67,18 +66,18 @@ uuid = { version = "0.8", features = ["v4"] }
zeroize = "1.4"

[dependencies.askar-crypto]
version = "0.2"
version = "0.2.5"
path = "./askar-crypto"
features = ["all_keys", "any_key", "argon2", "crypto_box", "std"]

[dependencies.sqlx]
version = "0.5.11"
version = "0.5.12"
default-features = false
features = ["chrono", "runtime-tokio-rustls"]
optional = true

[profile.release]
lto = true
lto = true
codegen-units = 1

[[test]]
Expand Down
2 changes: 1 addition & 1 deletion askar-crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "askar-crypto"
version = "0.2.4"
version = "0.2.5"
authors = ["Hyperledger Aries Contributors <aries@lists.hyperledger.org>"]
edition = "2018"
description = "Hyperledger Aries Askar cryptography"
Expand Down
Loading

0 comments on commit 76fcda4

Please sign in to comment.