forked from NilFoundation/crypto3
-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (152 loc) · 6.33 KB
/
crypto3-testing-mac.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Crypto3 Build and Test on Mac
on:
workflow_call:
inputs:
concurrency:
type: number
description: "Concurrency level (0 to use number of virtual cores)"
required: false
default: 0
targets:
type: string
description: "Make and CTest targets. If not specified, everything is tested"
required: false
test-paths:
type: string
description: "Folders from which the test must be run"
required: true
boost-version:
type: string
description: "Version of Boost to install"
required: false
default: '1.81.0' # The least version supported by both matrix.os
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: [macos-12]
strategy:
# Set up a matrix to run the following 2 configurations:
# 1. <MacOS, Release, latest G++ compiler toolchain on the default runner image, default generator>
# 2. <MacOS, Release, latest Clang++ compiler toolchain on the default runner image, default generator>
matrix:
cpp_compiler: [g++, clang++]
build_type: [Release]
steps:
- name: Install homebrew
run: >
/bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install.sh
)"
- name: Run brew install
id: brew-install
run: |
brew install \
cmake \
icu4c \
bash
- name: Print toolchain information
run: |
git --version
cc --version
cmake --version
bash --version
which -a bash
echo PATH: $PATH
- name: Checkout Crypto3 repository
uses: actions/checkout@v4
with:
repository: NilFoundation/crypto3
submodules: 'true' # Using true fetches only the top-level submodules
fetch-depth: 1 # Fetch only the latest commit on the triggered branch/ref
- 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: |
# Dependencies dir location
echo "dependencies-dir=${{ github.workspace }}/../dependencies" >> "$GITHUB_OUTPUT"
# Get platform version
platform_version=$(sw_vers -productVersion | awk -F '.' '{print $1}')
echo "platform-version=${platform_version}" >> $GITHUB_OUTPUT
if [ "${{ inputs.concurrency }}" = "0" ]; then
echo "Setting concurrency to number of logical cores"
proc_number=$(sysctl -n hw.logicalcpu)
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: Install boost
uses: MarkusJx/[email protected]
id: install-boost
with:
boost_version: ${{ inputs.boost-version }}
# A list of supported versions can be found here:
# https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
platform_version: ${{ steps.strings.outputs.platform-version }}
boost_install_dir: ${{ steps.strings.outputs.dependencies-dir }}
- name: Configure CMake
run: >
cmake -B build
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DBUILD_TESTS=TRUE
-DENABLE_JUNIT_TEST_OUTPUT=TRUE
-S ${{ github.workspace }}
env:
BOOST_ROOT: "${{ steps.install-boost.outputs.BOOST_ROOT }}"
- name: Build tests
id: build
working-directory: ${{ github.workspace }}/build
run: |
# Not considering failed targets bad. We will handle them as junit test result
build_log_path=${{ github.workspace }}/build/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: ${{ github.workspace }}/build/build.log
- name: Run tests
id: run_tests
working-directory: ${{ github.workspace }}/build
# Not considering failed tests bad. We will compare diff instead
run: |
artifact_dir=${{ github.workspace }}/../results_for_uploading_${{github.sha}}
mkdir -p $artifact_dir
artifact_dir=$(cd ${{ github.workspace }}/../results_for_uploading_${{github.sha}} && pwd)
echo "artifact-dir=$artifact_dir" >> "$GITHUB_OUTPUT"
custom_tests_dir=$artifact_dir/macos-12/${{ matrix.cpp_compiler }}/${{ matrix.build_type }}
mkdir -p $custom_tests_dir
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})" || true
test_paths="${{ inputs.test-paths }}"
for dir in $(echo "${test_paths}" | awk 'NF {$1=$1; print}')
do
mkdir -p $custom_tests_dir/$dir
mv ${{ github.workspace }}/build/$dir/junit_results/* $custom_tests_dir/$dir
done
mv ${{ steps.make-build-report.outputs.build-junit-report }} $custom_tests_dir
- name: Upload tests JUnit results
uses: actions/upload-artifact@v3
with:
name: ${{ env.TESTS_ARTIFACT_NAME }}
path: ${{ steps.run_tests.outputs.artifact-dir }}