-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a github workflow to run the contracts test suite
Signed-off-by: Mic Bowman <[email protected]>
- Loading branch information
Showing
2 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# | ||
# 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. This should not be done on the main PDO branch. | ||
|
||
name: Run full PDO contract tests | ||
on: [ 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_NAME: pdo_user | ||
PDO_USER_UID: 55172 | ||
PDO_GROUP_UID: 55172 | ||
|
||
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=$(private-data-objects/bin/get_version -f private-data-objects/VERSION)" >> $GITHUB_ENV | ||
echo "PDO_CONTRACTS_VERSION=$(private-data-objects/bin/get_version -f 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 $(./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 | ||
chown -R $PDO_USER_NAME:$PDO_USER_NAME docker/xfer | ||
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/${PDO_OWNER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2023 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
SCRIPT_NAME=$(basename ${BASH_SOURCE[-1]} ) | ||
source ${PDO_HOME}/bin/lib/common.sh | ||
|
||
# ----------------------------------------------------------------- | ||
# Process command line arguments | ||
# ----------------------------------------------------------------- | ||
F_REGISTRY= | ||
F_VERSION=latest | ||
|
||
F_USAGE='-r|--registry [registry] -v|--version [pdo_version]' | ||
SHORT_OPTS='r:v:' | ||
LONG_OPTS='registry:,version:' | ||
|
||
TEMP=$(getopt -o ${SHORT_OPTS} --long ${LONG_OPTS} -n "${SCRIPT_NAME}" -- "$@") | ||
if [ $? != 0 ] ; then echo "Usage: ${SCRIPT_NAME} ${F_USAGE}" >&2 ; exit 1 ; fi | ||
|
||
eval set -- "$TEMP" | ||
while true ; do | ||
case "$1" in | ||
-r|--registry) F_REGISTRY="$2" ; shift 2 ;; | ||
-v|--version) F_VERSION="$2" ; shift 2 ;; | ||
--help) echo "Usage: ${SCRIPT_NAME} ${F_USAGE}"; exit 0 ;; | ||
--) shift ; break ;; | ||
*) echo "Internal error!" ; exit 1 ;; | ||
esac | ||
done | ||
|
||
# if a registry is specified then make sure it has a trailing '/' | ||
if [ -n "${F_REGISTRY}" ]; then | ||
if [[ "${F_REGISTRY}" != */ ]]; then | ||
F_REGISTRY=${F_REGISTRY}/ | ||
fi | ||
fi | ||
|
||
# check for each of the PDO images | ||
for image in pdo_ccf pdo_services pdo_client ; do | ||
# First check to see if there is a local version that matches | ||
if docker inspect ${F_REGISTRY}$image:${F_VERSION} > /dev/null 2>&1 ; then | ||
continue | ||
fi | ||
|
||
# Pull the image if there is a registry and fail if not | ||
yell Attempt to pull ${F_REGISTRY}$image:${F_VERSION} | ||
docker pull ${F_REGISTRY}$image:${F_VERSION} > /dev/null 2>&1 || \ | ||
die Unable to find ${F_REGISTRY}$image:${F_VERSION} | ||
done | ||
|
||
exit 0 |