CI #121
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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="37eed538eb42205587dc1b6a4a805a16a9797c4cbcb478cc019f338b9d090c80 ./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@v2 | |
with: | |
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 |