Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Setup Github workflow #4

Merged
merged 1 commit into from
Feb 15, 2024
Merged
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
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
9 changes: 9 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

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

set -ex

echo "OpenSSL version being used:"
openssl version
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 "some@email.com"
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"
Loading