Skip to content

Commit

Permalink
Test: Add basic ci script and test files
Browse files Browse the repository at this point in the history
This patch only adds rudimentary files for the CI and test setup.
A comprehensive PR with detailed setup will be added later.

Signed-off-by: Gowtham Suresh Kumar <[email protected]>
  • Loading branch information
gowthamsk-arm committed Feb 13, 2024
1 parent 577ea32 commit 7923102
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/actions/load_docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Load docker image"
description: "Load docker image"
inputs:
image-name:
required: true
description: "Docker image name"
image-path:
required: true
description: "Path to save the docker image"

runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.image-name }}
path: ${{ inputs.image-path }}
- name: Load image
run: docker load --input ${{ inputs.image-path }}/${{ inputs.image-name }}.tar
shell: bash
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Continuous Integration

on:
pull_request:
workflow_dispatch:
inputs:
trigger_docker:
description: "'parsec-openssl-provider-test' if docker build should be triggered"
required: false
default: ""
push:

env:
TEST_DOCKER_IMAGE: ${{ github.event.inputs.trigger_docker || 'ghcr.io/parallaxsecond/parsec-openssl-provider-test' }}

jobs:
build-and-export-test-docker:
runs-on: ubuntu-latest
# For running this job we need to manually trigger the CI and set the variable
if: ${{ github.event.inputs.trigger_docker == 'parsec-openssl-provider-test' }}
steps:
- uses: actions/checkout@v3
- name: Build the docker container
run: pushd tests/docker_image && docker build -t parsec-openssl-provider-test -f parsec-openssl-provider-test.Dockerfile . && popd
- name: Export the docker container
run: docker save parsec-openssl-provider-test > /tmp/parsec-openssl-provider-test.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: parsec-openssl-provider-test
path: /tmp/parsec-openssl-provider-test.tar

build-and-test:
name: Build Parsec OpenSSL Provider and run tests
runs-on: ubuntu-latest
if: ${{ always() }}
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' }}
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 -t ${{ env.TEST_DOCKER_IMAGE }} ./ci.sh
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/target
Cargo.lock
.vscode
*/Cargo.lock
*/target
14 changes: 14 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Copyright 2023 Contributors to the Parsec project.
# SPDX-License-Identifier: Apache-2.0

set -ex

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

# Try loading the build parsec provider
openssl version
openssl list -providers -provider-path ./target/debug/ -provider libparsec_openssl_provider_shared
30 changes: 30 additions & 0 deletions tests/docker_image/parsec-openssl-provider-test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023 Contributors to the Parsec project.
# SPDX-License-Identifier: Apache-2.0
FROM ubuntu:22.04

RUN apt-get update && apt-get -y upgrade
RUN apt install -y autoconf-archive libcmocka0 libcmocka-dev procps
RUN apt install -y iproute2 build-essential git pkg-config gcc libtool automake libssl-dev uthash-dev doxygen libjson-c-dev
RUN apt install -y --fix-missing wget python3 cmake clang
RUN apt install -y libini-config-dev libcurl4-openssl-dev curl libgcc1
RUN apt install -y python3-distutils libclang-11-dev protobuf-compiler python3-pip
RUN apt install -y libgcrypt20-dev uuid-dev
RUN apt install -y libssl-dev git gcc openssl

# Setup git config
RUN git config --global user.email "[email protected]"
RUN git config --global user.name "Parsec Team"

WORKDIR /tmp

# Install Rust toolchain for all users
# This way of installing allows all users to call the same binaries, but non-root
# users cannot modify the toolchains or install new ones.
# See: https://github.com/rust-lang/rustup/issues/1085
ENV RUSTUP_HOME /opt/rust
ENV CARGO_HOME /opt/rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path
ENV PATH="/root/.cargo/bin:/opt/rust/bin:${PATH}"

# For running tests Parsec is configured with the socket in /tmp/
ENV PARSEC_SERVICE_ENDPOINT="unix:/tmp/parsec.sock"

0 comments on commit 7923102

Please sign in to comment.