Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/full_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# SPDX-License-Identifier: Apache-2.0
#

# This workflow is intended to be used as a validity test for any
# pull request. That is, this is a minimal functionality that must
# be successfully executed prior to merging a pull request. Note
# that this can be overridden by adding '[skip ci]' in the commit
# name.

name: Run full PDO contract tests
on: [ workflow_dispatch, pull_request ]

jobs:
pdo_ci:
if: "!contains(github.event.commits[0].message, '[skip ci]')"
name: PDO Contracts Full Test
runs-on: ubuntu-22.04

env:
REGISTRY: ghcr.io
OWNER: ${{ github.repository_owner }}
PDO_USER_UID: 55172
PDO_GROUP_UID: 55172
PDO_SOURCE_ROOT: private-data-objects
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
fetch-tags: true

- name: Set the version
run: |
echo "PDO_VERSION=$(${PDO_SOURCE_ROOT}/bin/get_version -f ${PDO_SOURCE_ROOT}/VERSION)" >> $GITHUB_ENV
echo "PDO_CONTRACTS_VERSION=$(bin/get_version)" >> $GITHUB_ENV

- name: Show the version
run: |
echo "PDO_CONTRACTS_VERSION is $PDO_CONTRACTS_VERSION"
echo "PDO_VERSION is $PDO_VERSION"

- name: Configure PDO and build the base images
run: |
if $(docker/require_pdo_images.sh -r ${REGISTRY}/${OWNER} -v ${PDO_VERSION})
then
echo Using pre-built PDO images
else
echo No pre-built PDO images available for version ${PDO_VERSION} from ${REGISTRY}
echo Please populate the registry and retry
exit -1
fi

- name: Build and run contract tests
run: |
git checkout -b ci-test-branch
sudo chown -R $PDO_USER_UID:$PDO_GROUP_UID docker/xfer
sudo chmod -R g+w docker/xfer
make -C docker test \
CONTRACTS_USER_UID=$PDO_USER_UID CONTRACTS_GROUP_UID=$PDO_GROUP_UID \
PDO_VERSION=$PDO_VERSION PDO_REGISTRY=$REGISTRY/$OWNER
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ INCLUDE(wawaka_common)
LIST(APPEND WASM_LIBRARIES ${WW_COMMON_LIB})
LIST(APPEND WASM_INCLUDES ${WW_COMMON_INCLUDES})

FILE(GLOB CONTRACT_FAMILIES "*-contract")
FILE(GLOB CONTRACT_FAMILIES RELATIVE ${CMAKE_SOURCE_DIR} "*-contract")

# A local cmake file (Local.cmake) allows for local overrides of
# variables. In particular, this is useful to set CONTRACT_FAMILIES
Expand All @@ -43,6 +43,15 @@ INCLUDE(Local.cmake OPTIONAL)

ENABLE_TESTING()

# Contract families must contain common-contract and
# it should be the first built; this just makes sure
# it is include

LIST(REMOVE_ITEM CONTRACT_FAMILIES common-contract)
LIST(PREPEND CONTRACT_FAMILIES common-contract)

MESSAGE(STATUS "BUILD CONTRACT FAMILIES ${CONTRACT_FAMILIES}")

FOREACH(FAMILY IN ITEMS ${CONTRACT_FAMILIES})
ADD_SUBDIRECTORY(${FAMILY})
ENDFOREACH()
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TEST_LOG_LEVEL ?= warn
TEST_LOG_FILE ?= __screen__
TEST_SERVICE_HOST ?= $(PDO_HOSTNAME)
TEST_LEDGER ?= $(PDO_LEDGER_URL)
TEST_LIST ?= ^system

VERSION=${shell ${SOURCE_ROOT}/bin/get_version}

Expand All @@ -51,7 +52,7 @@ test : install
-DTEST_LOG_FILE=$(TEST_LOG_FILE) \
-DTEST_LEDGER=$(TEST_LEDGER) \
-DTEST_SERVICE_HOST=$(TEST_SERVICE_HOST)
@ make -C build test ARGS='-V'
@ make -C build test ARGS='-V -R "$(TEST_LIST)"'

clean :
@ echo Remove build directory
Expand Down
2 changes: 2 additions & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
v0.2.0 cc37e8428d9564256bbdff63714113eb63795f3e automated testing enabled; pdo 0.4.1
v0.1.0 b57f345c67b6babb8b386d695b6c7e665b76e8b0 initial commit of exchange and digital asset families; pdo 0.2.63
69 changes: 38 additions & 31 deletions bin/get_version
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,42 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import os
import pathlib
import subprocess
import sys
import warnings

count = 0
commit = ''
dirty = ''

try :
output = subprocess.check_output(['git', 'describe', '--dirty'])
(version, *rest) = output.decode('utf-8').strip().split('-')
(major, minor, patch) = version.strip('v').split('.')

# first case: this is a dirty tagged release, only dirty flag
if len(rest) == 1 :
assert rest[0] == 'dirty'
dirty = 'dirty'
# second case: this is a committed post tag release
elif len(rest) == 2 :
count = rest[0]
commit = rest[1]
# third case: this is a dirty, committed post tag release
elif len(rest) == 3 :
assert rest[2] == 'dirty'
count = rest[0]
commit = rest[1]
dirty = rest[2]

print('{}.{}.{}'.format(major, minor, count))
except Exception as e :
warnings.warn('failed to compute version, using default')
print('0.0.0')

pdo_source_root=pathlib.Path(__file__).parent.parent
version_file = pdo_source_root / 'VERSION'

parser = argparse.ArgumentParser()

parser.add_argument(
'--version-file', '-f',
help=f'File where version information is stored (default: {version_file})',
type=str)

options = parser.parse_args()

if options.version_file :
version_file = pathlib.Path(options.version_file)
pdo_source_root = version_file.parent

# the version file is a tab separated list of version numbers and git commit hashes in reverse
# order (newest is at the top of the file)
with open(version_file, 'r') as vf :
(version, commit, *rest) = vf.readline().strip().split('\t')

# the version is of the form x.y.z, there may be an optional 'v' at the beginning of the version
# string
(major, minor, patch) = version.strip('v').split('.')

# compute the number of commits since the tagged version was
# committed to the repository
command = ['git', 'rev-list', commit + '...HEAD', '--count']
output = subprocess.run(command, cwd=pdo_source_root, capture_output=True, text=True)
count = output.stdout.strip()

# the actual patch version number is the recorded patch number added to the number of commits
# since the version was committed
print('{}.{}.{}'.format(major, minor, int(patch) + int(count)))
66 changes: 53 additions & 13 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# limitations under the License.
# ------------------------------------------------------------------------------

# Ensure that the default target builds the contracts
all : build_contracts

# Include local customizations if they are available
-include make.loc

Expand All @@ -23,10 +26,10 @@
# that the user/group identifiers need to have write access to the xfer directory
CONTRACTS_USER_UID ?= $(shell id -u)
CONTRACTS_GROUP_UID ?= $(shell id -g)
CONTRACTS_USER_NAME ?= $(shell whoami)

DOCKER_COMMAND ?= docker

DOCKER_COMPOSE_COMMAND ?= docker-compose
ifndef DOCKER_COMPOSE_COMMAND
DOCKER_COMPOSE_COMMAND := $(shell command -v docker-compose 2> /dev/null)
ifndef DOCKER_COMPOSE_COMMAND
Expand Down Expand Up @@ -66,15 +69,19 @@ PDO_VERSION ?= $$( \
echo "latest"; \
fi )

PDO_REPSITORY ?= ''
# This variable ensures that the registry ends with a '/'. The additional
# variable ensures that the substitution is applied; conditional assignment
# of the registry appears to prevent early evaluation of the expression.
PDO_REGISTRY_SAFE := $(if $(PDO_REGISTRY),$(patsubst %/,%,$(PDO_REGISTRY))/)

# DOCKER BUILD
DOCKER_USERNAME = $(LOGNAME)
DOCKER_BUILDARGS += --build-arg UNAME=$(CONTRACTS_USER_NAME)
DOCKER_BUILDARGS += --build-arg UID=$(CONTRACTS_USER_UID)
DOCKER_BUILDARGS += --build-arg GID=$(CONTRACTS_GROUP_UID)
DOCKER_BUILDARGS += --build-arg CONTRACTS_VERSION=$(CONTRACTS_VERSION)
DOCKER_BUILDARGS += --build-arg PDO_VERSION=$(PDO_VERSION)
DOCKER_BUILDARGS += --build-arg PDO_REPOSITORY=$(PDO_REPOSITORY)
DOCKER_BUILDARGS += --build-arg PDO_REGISTRY=$(PDO_REGISTRY_SAFE)
DOCKER_ARGS = $(DOCKER_BUILDARGS)

# The CONTRACT_FAMILIES variable contains a list of contract families
Expand All @@ -87,8 +94,6 @@ CONTRACT_FAMILIES ?= $(notdir $(wildcard $(CONTRACTS_SOURCE_ROOT)/*-contract))
# PDO contracts has changed
TIMESTAMP := $(shell /bin/date "+%Y%m%d%H%M%S")

all : build_contracts

rebuild_contracts : repository models
$(DOCKER_COMMAND) build $(DOCKER_ARGS) \
--build-arg REBUILD=$(TIMESTAMP) \
Expand All @@ -97,6 +102,7 @@ rebuild_contracts : repository models

build_contracts : DOCKER_BUILDARGS+=--build-arg CONTRACT_FAMILIES="$(CONTRACT_FAMILIES)"
build_contracts : repository models
- echo "Build contract families: $(CONTRACT_FAMILIES)"
$(DOCKER_COMMAND) build $(DOCKER_ARGS) \
--tag pdo_contracts:$(CONTRACTS_VERSION) \
--file $(DOCKER_DIR)/pdo_contracts.dockerfile .
Expand All @@ -121,7 +127,6 @@ build_pdo_images : repository
PDO_SOURCE_ROOT=$(DOCKER_DIR)/repository/private-data-objects \
make -C $(DOCKER_DIR)/repository/private-data-objects/docker clean_repository


# -----------------------------------------------------------------
# -----------------------------------------------------------------
# For the purposes of testing, we just use the resnet model for
Expand Down Expand Up @@ -219,27 +224,62 @@ endif
TEST_COMPOSE_ARGS += -f test.yaml

test : clean_config clean_repository build_contracts
- PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
- PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
$(DOCKER_COMPOSE_COMMAND) $(TEST_COMPOSE_ARGS) $(COMPOSE_PROFILES) up --abort-on-container-exit
PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
$(DOCKER_COMPOSE_COMMAND) $(TEST_COMPOSE_ARGS) down

JUPYTER_COMPOSE_ARGS += -f test_jupyter.yaml

test_jupyter : clean_config clean_repository build_contracts
- PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
- PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
$(DOCKER_COMPOSE_COMMAND) $(JUPYTER_COMPOSE_ARGS) $(COMPOSE_PROFILES) up --abort-on-container-exit
PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
$(DOCKER_COMPOSE_COMMAND) $(JUPYTER_COMPOSE_ARGS) down

JUPYTER_MULTIUSER_COMPOSE_ARGS += -f test_multiuser_jupyter.yaml

test_multiuser_jupyter : clean_config clean_repository build_contracts
- PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
- PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
$(DOCKER_COMPOSE_COMMAND) $(JUPYTER_MULTIUSER_COMPOSE_ARGS) $(COMPOSE_PROFILES) up --abort-on-container-exit
PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
$(DOCKER_COMPOSE_COMMAND) $(JUPYTER_MULTIUSER_COMPOSE_ARGS) down

# The example target builds and runs only the example contract family. This
# is intended to be a very simple way to test drive PDO contracts as a user
# and as a contract developer.

example : CONTRACT_FAMILIES=example-contract
example : clean_config clean_repository build_contracts
- PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
CONTRACTS_SOURCE_ROOT=$(CONTRACTS_SOURCE_ROOT) \
$(DOCKER_COMPOSE_COMMAND) $(TEST_COMPOSE_ARGS) up --abort-on-container-exit
PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
$(DOCKER_COMPOSE_COMMAND) $(TEST_COMPOSE_ARGS) down

example_jupyter : CONTRACT_FAMILIES=exchange-contract example-contract
example_jupyter : clean_config clean_repository build_contracts
- PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
CONTRACTS_SOURCE_ROOT=$(CONTRACTS_SOURCE_ROOT) \
$(DOCKER_COMPOSE_COMMAND) $(JUPYTER_COMPOSE_ARGS) up --abort-on-container-exit
PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
$(DOCKER_COMPOSE_COMMAND) $(JUPYTER_COMPOSE_ARGS) down

# The developer target creates a container with no contracts built or
# installed. When the container starts, the current contract source
# root is mounted at /project/pdo/dev. In addition, a Jupyter server
# is started. The Jupyter launcher provides a shell window that can be
# used to interact with the PDO installation to build and install
# contracts.
DEVELOP_COMPOSE_ARGS += -f test_dev.yaml
developer : CONTRACT_FAMILIES=
developer : clean_config build_contracts
- PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
CONTRACTS_SOURCE_ROOT=$(CONTRACTS_SOURCE_ROOT) \
$(DOCKER_COMPOSE_COMMAND) $(DEVELOP_COMPOSE_ARGS) up --abort-on-container-exit
PDO_REGISTRY=$(PDO_REGISTRY_SAFE) PDO_VERSION=$(PDO_VERSION) CONTRACTS_VERSION=$(CONTRACTS_VERSION) \
$(DOCKER_COMPOSE_COMMAND) $(JUPYTER_COMPOSE_ARGS) down

# -----------------------------------------------------------------
# Cleaning is a bit interesting because the containers don't go away
# unless they are told to very nicely. Until they go away they hold onto
Expand All @@ -257,7 +297,7 @@ clean_config :
@ rm -f $(DOCKER_DIR)/xfer/services/keys/*.pem $(DOCKER_DIR)/xfer/services/etc/*.toml
@ rm -f $(DOCKER_DIR)/xfer/services/etc/site.psh

clean : clean_images clean_config clean_repository clean_models
clean : clean_images clean_config clean_repository

.PHONY: clean clean_images clean_config clean_repository clean_models
.PHONY: test
Expand Down
2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Four configuration variables should be set as necessary:
user.
* `PDO_VERSION` -- the version identifier for PDO images; this
defaults to `latest`.
* `PDO_REPOSITORY` -- the docker repository from which PDO docker images
* `PDO_REGISTRY` -- the docker repository from which PDO docker images
may be retrieved; this defaults to `""` so that local images will be
used by default.
* `CONTRACTS_VERSION` -- the version that will be used to tag the PDO
Expand Down
Loading