Skip to content

Commit

Permalink
CI: Split jobs
Browse files Browse the repository at this point in the history
This patch adds a ci_script GitHub action and splits the jobs to
run specific tests.

Signed-off-by: Gowtham Suresh Kumar <[email protected]>
  • Loading branch information
gowthamsk-arm committed Feb 22, 2024
1 parent 90b8b3d commit d339be8
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 26 deletions.
23 changes: 23 additions & 0 deletions .github/actions/ci_script/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Run CI Tests"
description: "Run the ci.sh script with the specified flags"
inputs:
ci-flags:
required: true
description: "Flags with which to run the ci.sh tests"
rs-version:
required: true
default: "stable"
description: "Rust version with which to run the tests"

runs:
using: "composite"
steps:
- name: Load Docker
uses: ./.github/actions/load_docker
if: ${{ env.TEST_DOCKER_IMAGE == 'parsec-openssl-provider-test' }}
with:
image-name: "${{ env.TEST_DOCKER_IMAGE }}"
image-path: "/tmp"
- name: Run the container to execute the test script
run: docker run -v $(pwd):/tmp/parsec-openssl-provider -w /tmp/parsec-openssl-provider --env RUST_TOOLCHAIN_VERSION=${{ inputs.rs-version }} -t ${{ env.TEST_DOCKER_IMAGE }} /tmp/parsec-openssl-provider/ci.sh --${{ inputs.ci-flags }}
shell: bash
21 changes: 14 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ jobs:
needs: [build-and-export-test-docker]
steps:
- uses: actions/checkout@v3
- name: Load Docker
uses: ./.github/actions/load_docker
if: ${{ env.TEST_DOCKER_IMAGE == 'parsec-openssl-provider-test' }}
- name: Run the container to execute the test script
uses: ./.github/actions/ci_script
with:
image-name: "${{ env.TEST_DOCKER_IMAGE }}"
image-path: "/tmp"
ci-flags: "build-test"

static-checks:
name: Run static checks
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build-and-export-test-docker]
steps:
- uses: actions/checkout@v3
- name: Run the container to execute the test script
run:
docker run -v $(pwd):/tmp/parsec-openssl-provider -w /tmp/parsec-openssl-provider -t ${{ env.TEST_DOCKER_IMAGE }} ./ci.sh
uses: ./.github/actions/ci_script
with:
ci-flags: "static-checks"
85 changes: 66 additions & 19 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,81 @@

set -ex

echo "OpenSSL version being used:"
openssl version
usage () {
printf "
Continuous Integration test script
# Build parsec provider shared library
pushd parsec-openssl-provider-shared/ &&
cargo build
popd
Usage: ./ci.sh --TEST
where TEST can be one of:
--build-test
--static-checks
"
}

# Try loading the build parsec provider
provider_load_result=$(openssl list -providers -provider-path ./target/debug/ -provider libparsec_openssl_provider_shared)
echo $provider_load_result
error_msg () {
echo "Error: $1"
usage
exit 1
}

test_string='Providers:
# Change rust toolchain version
if [[ ! -z ${RUST_TOOLCHAIN_VERSION:+x} ]]; then
rustup override set ${RUST_TOOLCHAIN_VERSION}
fi

rustup update

BUILD_AND_TEST=
STATIC_CHECKS=

while [ "$#" -gt 0 ]; do
case "$1" in
--build-test )
BUILD_AND_TEST="True"
;;
--static-checks )
STATIC_CHECKS="True"
;;
*)
error_msg "Unknown argument: $1"
;;
esac
shift
done

if [ "$BUILD_AND_TEST" ]; then
echo "OpenSSL version being used:"
openssl version

# Build parsec provider shared library
pushd parsec-openssl-provider-shared/ &&
cargo build
popd

# Try loading the build parsec provider
PROVIDER_LOAD_RESULT=$(openssl list -providers -provider-path ./target/debug/ -provider libparsec_openssl_provider_shared)
echo $PROVIDER_LOAD_RESULT

TEST_STRING='Providers:
libparsec_openssl_provider_shared
name: Parsec OpenSSL Provider
version: 0.1.0
status: active'

if [[ $test_string != $provider_load_result ]]; then
echo "Loaded Provider has unexpected parameters!!!!"
if [[ $TEST_STRING != $PROVIDER_LOAD_RESULT ]]; then
echo "Loaded Provider has unexpected parameters!!!!"
exit 1
fi

echo "Parsec OpenSSL Provider loaded successfully!!!!"
fi

echo "Parsec OpenSSL Provider loaded successfully!!!!"
if [ "$STATIC_CHECKS" ]; then
if cargo fmt --version; then
cargo fmt --all -- --check
fi

if cargo fmt --version; then
cargo fmt --all -- --check
if cargo clippy --version; then
cargo clippy --all-targets -- -D clippy::all -D clippy::cargo
fi
fi

if cargo clippy --version; then
cargo clippy --all-targets -- -D clippy::all -D clippy::cargo
fi

0 comments on commit d339be8

Please sign in to comment.