-
Notifications
You must be signed in to change notification settings - Fork 10
116 lines (96 loc) · 4.43 KB
/
ci-cmake_tests.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
# Run Google Tests (via CTest) using "GitHub Actions" CI
# Adapted from the default template, as well as https://github.com/GHF/googletest-ci (CC license)
name: CI
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
BUILD_TYPE: Debug
defaults:
run:
shell: bash
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test_julia_scripts:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Install Julia
uses: julia-actions/setup-julia@v1
with:
version: "1" # This will automatically pick the latest Julia version
- name: instantiate Julia dependencies
working-directory: ${{runner.workspace}}/LDPC4QKD/codes
run: julia --project -e 'import Pkg; Pkg.instantiate()'
- name: test julia scripts to make sure they are up to date. This is not part of code coverage!
working-directory: ${{runner.workspace}}/LDPC4QKD/codes
run: |
julia --project -- "./ldpc_codegen.jl" --input_code_path '../tests/test_reading_bincscjson_format_block_6144_proto_2x6_313422410401.bincsc.json' --output_path "./tmp.hpp"
expected="f19284d54e32b79564bcf8bd0cdfbf72eb7f7da5e502397660733beeaaa06383 ./tmp.hpp"
actualoutput="$(sha256sum ./tmp.hpp)"
if [ "$actualoutput" != "$expected" ]; then
echo "Error on testing sha256 of output: EXPECTED=$expected ACTUAL=$actualoutput"
exit 2
fi
build__and_test_cpp_programs:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: print workspace directory tree (before configuration)
working-directory: ${{runner.workspace}}
run: tree
- name: Configure CMake
run: cmake -S $GITHUB_WORKSPACE -B ${{runner.workspace}}/build -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DENABLE_COVERAGE:BOOL=ON
- name: Build
working-directory: ${{runner.workspace}}/build
run: cmake --build . --config $BUILD_TYPE
- name: Run demo
working-directory: ${{runner.workspace}}/build/examples
run: ./demo_error_correction
- name: Install lcov and gcov (tools to get C++ coverage information)
working-directory: ${{runner.workspace}}/build/
run: |
set -x # enable debugging in bash
sudo apt-get update
sudo apt-get -qq -y install lcov gcovr
- name: Run unit tests with coverage
working-directory: ${{runner.workspace}}/build/
run: |
set -x # enable debugging in bash
lcov --zerocounters --directory .
# run all unit tests (ctest)
GTEST_OUTPUT=xml:test-results/ GTEST_COLOR=1 ctest -V -C $BUILD_TYPE
# run also the simulator with very few frames to simulate
./benchmarks_error_rate/rate_adapted_fer -cp "./tests/test_reading_bincscjson_format_block_6144_proto_2x6_313422410401.bincsc.json" -mf 3
./benchmarks_error_rate/critical_rate_simulation -cp "./tests/test_reading_bincscjson_format_block_6144_proto_2x6_313422410401.bincsc.json" -rp "./tests/rate_adaption_2x6_block_6144_for_testing.csv" -nf 3
# collect coverage, etc.
gcovr -v --root ../ --xml-pretty --xml coverage.xml --exclude '.*/external/'
echo
cat ./coverage.xml # print coverage information
- name: Publish to codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{runner.workspace}}/build/coverage.xml
fail_ci_if_error: true
- name: Upload test results
uses: actions/upload-artifact@v2
if: failure()
with:
name: test_results_xml
path: |
${{runner.workspace}}/build/tests/test-results/**/*.xml
${{runner.workspace}}/build/coverage.xml
- name: (if failure) print workspace directory tree at very end
if: failure()
working-directory: ${{runner.workspace}}
run: tree