Skip to content

Commit

Permalink
Attempting CI migration. Testing fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iluvmagick committed Feb 15, 2024
1 parent 1c5d92a commit 062ddd5
Show file tree
Hide file tree
Showing 4 changed files with 628 additions and 7 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/pull-request-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
handle-syncwith:
name: Call Reusable SyncWith Handler
uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1.2.0
uses: .github/workflows/reusable-handle-syncwith.yml
with:
ci-cd-ref: 'v1.2.0'
secrets: inherit
Expand All @@ -20,24 +20,22 @@ jobs:
name: Linux Reusable Crypto3 Testing
needs:
- handle-syncwith
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-testing-linux.yml@v1.2.0
uses: .github/workflows/reusable-crypto3-testing-linux.yml

secrets: inherit
with:
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}

targets: ${{ inputs.targets }}
targets: ${{ inputs.targets }}

matrix-test-mac:
name: Mac Reusable Crypto3 Testing
needs:
- handle-syncwith
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-testing-mac.yml@v1.2.0
uses: .github/workflows/reusable-crypto3-testing-mac.yml

secrets: inherit
with:
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}

# TODO(martun): fix this sometime soon. All the targets must work on mac.
targets: crypto3_zk_math_expression_test # ${{ inputs.targets }}
targets: ${{ inputs.targets }}

240 changes: 240 additions & 0 deletions .github/workflows/reusable-crypto3-testing-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
name: Crypto3 Build and Test on Linux Platforms (Reusable)

on:
workflow_call:
inputs:
concurrency:
type: number
description: "Concurrency level (0 to use number of virtual cores)"
required: false
default: 0
submodules-refs:
type: string
description: "Lines with submodules' repo names and refs (e.g. `org/repo: ref`)"
required: false
targets:
type: string
description: "Make and CTest targets. If not specified, everything is tested"
required: false
boost-version:
type: string
description: "Version of Boost to install"
required: false
default: "1.81.0"
env:
TESTS_ARTIFACT_NAME: "test-results"
EVENT_FILE_ARTIFACT_NAME: "event-file"

jobs:
upload-event-file:
# Needed to link test results with PR workflow run
name: "Upload Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v3
with:
name: ${{ env.EVENT_FILE_ARTIFACT_NAME }}
path: ${{ github.event_path }}

build-and-test:
name: "Build and Test using Matrix"
runs-on: [self-hosted, Linux, X64, aws_autoscaling]

env:
CONTAINER_TMP: /opt/
HOST_TMP: /home/runner/work/_temp/
DEBIAN_FRONTEND: noninteractive

container:
image: ubuntu:22.04
volumes:
- /home/runner/work/_temp/:/opt/

strategy:
# Set up a matrix to run the following 2 configurations:
# 1. <Linux, Release, latest G++ compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest Clang++ compiler toolchain on the default runner image, default generator>
matrix:
cpp_compiler: [g++, clang++-12]
build_type: [Release]

steps:
- name: Install dependencies
run: |
env && \
apt update && \
apt install -y \
build-essential \
libssl-dev \
cmake \
clang-12 \
git \
libicu-dev \
curl \
pkg-config \
libc-ares-dev \
liblz4-dev \
libgnutls28-dev \
libprotobuf-dev \
libyaml-cpp-dev \
lksctp-tools \
libsctp-dev \
ragel \
spd \
lsb-release
- name: Print toolchain information
run: |
git --version
cc --version
cmake --version
- name: Get OS version
# Turn input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: os_version
shell: bash
run: |
# Get platform version
platform_version=$(lsb_release -rs)
echo "platform-version=${platform_version}" >> $GITHUB_OUTPUT
- name: Install boost
uses: MarkusJx/[email protected]
id: install-boost
with:
# A list of supported versions can be found here:
# https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
boost_version: ${{ inputs.boost-version }}
platform_version: ${{ steps.os_version.outputs.platform-version }}
boost_install_dir: ${{ env.CONTAINER_TMP }}
toolset: gcc
arch: x86

- name: Checkout Crypto3 repository
# We need full history, because during CMake config stage we are finding the nearest tag
uses: actions/checkout@v4
with:
repository: NilFoundation/crypto3
fetch-depth: 1 # Fetch only the latest commit on the triggered branch/ref
submodules: false

# Workaround: https://github.com/actions/checkout/issues/1169
- name: Mark directory as safe
run: |
git config --system --add safe.directory $PWD
- name: Checkout submodules
run: |
git submodule update --init --recursive --depth=1
- name: Checkout submodules to specified refs
if: inputs.submodules-refs != ''
uses: NilFoundation/ci-cd/actions/[email protected]
with:
paths: ${{ github.workspace }}/**
refs: ${{ inputs.submodules-refs }}

- name: Determine submodule path
id: get-submodule-path
run: |
# Parsing .gitmodules to find the path of the submodule repository.
submodule_path=$(git config --file .gitmodules --get-regexp path | awk -v repo_name="${{ github.event.repository.name }}" '$0 ~ "submodule\\."repo_name"\\.path" { sub(/.*path /, ""); print }')
echo "Submodule path is ${submodule_path:-$GITHUB_WORKSPACE/libs/${{ github.event.repository.name }}}"
echo "submodule-path=$submodule_path" >> $GITHUB_OUTPUT
- name: Checkout current repository as umbrella submodule lib
uses: actions/checkout@v4
with:
path: ${{ steps.get-submodule-path.outputs.submodule-path }}
fetch-depth: 1

- name: Set usefull strings
# Turn input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
# CMake locations
docker_workspace_path="$PWD"
umbrella_build_dir="$docker_workspace_path/build"
submodule_build_dir="$umbrella_build_dir/${{ steps.get-submodule-path.outputs.submodule-path }}"
echo "docker-workspace-path=$docker_workspace_path" >> "$GITHUB_OUTPUT"
echo "umbrella-build-dir=$umbrella_build_dir" >> "$GITHUB_OUTPUT"
echo "submodule-build-dir=$submodule_build_dir" >> "$GITHUB_OUTPUT"
echo "submodule-test-dir=$submodule_build_dir/test" >> "$GITHUB_OUTPUT"
# Dependencies dir location
echo "dependencies-dir=${{ github.workspace }}/../dependencies" >> "$GITHUB_OUTPUT"
if [ "${{ inputs.concurrency }}" = "0" ]; then
echo "Setting concurrency to number of logical cores"
proc_number=$(nproc)
else
echo "Setting concurrency to user-defined value"
proc_number=${{ inputs.concurrency }}
fi
echo "proc-number=${proc_number}" >> $GITHUB_OUTPUT
- name: Set up dependencies directory
run: |
mkdir -p "${{ steps.strings.outputs.dependencies-dir }}"
- name: Clean index.lock files if checkout step was cancelled or failed
if: cancelled() || failure()
run: |
find .git -name 'index.lock' -exec rm -v {} \;
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.umbrella-build-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DBUILD_TESTS=TRUE
-DENABLE_JUNIT_TEST_OUTPUT=TRUE
-S ${{ steps.strings.outputs.docker-workspace-path }}
env:
BOOST_ROOT: "${{ steps.install-boost.outputs.BOOST_ROOT }}"

- name: Build tests inside submodule
id: build-submodule
working-directory: ${{ steps.strings.outputs.submodule-test-dir }}
run: |
# Not considering failed targets bad. We will handle them as junit test result
build_log_path=${{ steps.strings.outputs.submodule-build-dir }}/build.log
targets_str=$(echo "${{ inputs.targets }}" | awk '{$1=$1};1' | sed '/^$/d' | tr '\n' ' ' | sed 's/ $//')
make -k -j ${{ steps.strings.outputs.proc-number }} ${targets_str} 2>&1 | tee ${build_log_path}
echo "build-log=$build_log_path" >> "$GITHUB_OUTPUT"
- name: Generate JUnit Report from build result
id: make-build-report
uses: NilFoundation/ci-cd/actions/build-log-to-junit@v1
with:
build-log: ${{ steps.build-submodule.outputs.build-log }}

- name: Run tests inside submodule test dir
working-directory: ${{ steps.strings.outputs.submodule-test-dir }}
# Not considering failed tests bad. We will compare diff instead
run: |
targets_str=$(echo "${{ inputs.targets }}" | awk '{$1=$1};1' | sed '/^$/d' | tr '\n' '|' | sed 's/|$//')
ctest -v -j ${{ steps.strings.outputs.proc-number }} -R "(${targets_str})" || exit 0
- name: Move test results to dir for uploading
id: prepare-for-uploading
run: |
artifact_dir=${{ steps.strings.outputs.docker-workspace-path }}/../results_for_uploading_${{github.sha}}
mkdir -p $artifact_dir
artifact_dir=$(cd ${{ steps.strings.outputs.docker-workspace-path }}/../results_for_uploading_${{github.sha}} && pwd)
custom_tests_dir=$artifact_dir/ubuntu-22.04/${{ matrix.cpp_compiler }}/${{ matrix.build_type }}
mkdir -p $custom_tests_dir
mv ${{ steps.strings.outputs.submodule-test-dir }}/junit_results/* $custom_tests_dir
mv ${{ steps.make-build-report.outputs.build-junit-report }} $custom_tests_dir
echo "artifact-dir=$artifact_dir" >> "$GITHUB_OUTPUT"
- name: Upload tests JUnit results
uses: actions/upload-artifact@v3
with:
name: ${{ env.TESTS_ARTIFACT_NAME }}
path: ${{ steps.prepare-for-uploading.outputs.artifact-dir }}
Loading

0 comments on commit 062ddd5

Please sign in to comment.