From afc8f7990c768452e2a112c31804cc0b9da45414 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 15 Jul 2023 13:52:19 +0200 Subject: [PATCH 1/7] Remove the need for nano-enc docker images - Run testcases with sanitizers directly on ubuntu 22.04 github runners - use space instead of colon as separator for TSAN_OPTIONS and ASAN_OPTIONS - add timeout for core_test (45min) and rpc_test (20min) to produce a report in case of a deadlock --- .github/workflows/code_sanitizers.yml | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/code_sanitizers.yml b/.github/workflows/code_sanitizers.yml index a6797ff25c..d501774757 100644 --- a/.github/workflows/code_sanitizers.yml +++ b/.github/workflows/code_sanitizers.yml @@ -23,36 +23,44 @@ jobs: COMPILER: ${{ matrix.COMPILER }} TEST_USE_ROCKSDB: ${{ matrix.TEST_USE_ROCKSDB }} XSAN: ${{ endsWith(matrix.sanitizer, 'ASAN_INT') && 'ASAN' || matrix.SANITIZER }} - XSAN_SUPPRESSIONS: ${{ endsWith(matrix.SANITIZER, 'TSAN') && 'suppressions=../tsan_suppressions:' || '' }} + XSAN_SUPPRESSIONS: ${{ endsWith(matrix.SANITIZER, 'TSAN') && 'suppressions=../tsan_suppressions' || '' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3.1.0 + - name: Checkout + uses: actions/checkout@v3 with: - submodules: "true" - - name: Git Submodule Update - run: git submodule update --init --recursive + submodules: "recursive" + + - name: Prepare + run: sudo -E ci/prepare/linux/prepare.sh + - name: XSan variable values run: | ( echo "XSAN: '${XSAN}'" echo "XSAN_SUPPRESSIONS: '${XSAN_SUPPRESSIONS}'" ) - - name: Install Dependencies - run: ci/actions/linux/install_deps.sh + - name: Build Tests id: build_tests - run: docker run -e TEST_USE_ROCKSDB -v ${PWD}:/workspace ghcr.io/${{ github.repository }}/nano-env:${{ matrix.COMPILER }} /bin/bash -c \ - "cd /workspace && ${{ matrix.SANITIZER }}=1 ci/build-ci.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 'core_test rpc_test'" + run: ${{ matrix.SANITIZER }}=1 ci/build-ci.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 'core_test rpc_test' + - name: Run core_test id: core_test continue-on-error: true - run: docker run -v ${PWD}:/workspace ghcr.io/${{ github.repository }}/nano-env:${{ matrix.COMPILER }} /bin/bash -c \ - "cd /workspace/build && ${XSAN}_OPTIONS=${XSAN_SUPPRESSIONS}log_exe_name=1:log_path=sanitizer_report ./core_test" + run: | + export ${XSAN}_OPTIONS="${XSAN_SUPPRESSIONS} log_exe_name=1 log_path=sanitizer_report" + timeout -sHUP 45m ./core_test + working-directory: build + - name: Run rpc_test id: rpc_test continue-on-error: true - run: docker run -v ${PWD}:/workspace ghcr.io/${{ github.repository }}/nano-env:${{ matrix.COMPILER }} /bin/bash -c \ - "cd /workspace/build && ${XSAN}_OPTIONS=${XSAN_SUPPRESSIONS}log_exe_name=1:log_path=sanitizer_report ./rpc_test" + run: | + export ${XSAN}_OPTIONS="${XSAN_SUPPRESSIONS} log_exe_name=1 log_path=sanitizer_report" + timeout -sHUP 20m ./rpc_test + working-directory: build + - name: Test Reports id: show_report run: | @@ -63,7 +71,7 @@ jobs: echo "Report Output:" for report in ${reports}; do echo "File: $report" - docker run -v ${PWD}:/workspace ghcr.io/${{ github.repository }}/nano-env:${{ matrix.COMPILER }} /bin/bash -c "cat /workspace/${report}" + cat ${report} echo done issue_reported=true From 057f50716c7642409baa4c9fbe388c3d08372a50 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Fri, 18 Aug 2023 17:16:50 +0200 Subject: [PATCH 2/7] Increase timeout from 90 to 120 minutes --- .github/workflows/code_sanitizers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_sanitizers.yml b/.github/workflows/code_sanitizers.yml index d501774757..c55296312a 100644 --- a/.github/workflows/code_sanitizers.yml +++ b/.github/workflows/code_sanitizers.yml @@ -9,7 +9,7 @@ env: jobs: google_sanitizers_linux: name: ${{ matrix.SANITIZER }} / ROCKSDB=${{ matrix.TEST_USE_ROCKSDB }} / ${{ matrix.COMPILER }} - timeout-minutes: 90 + timeout-minutes: 120 strategy: fail-fast: false matrix: From e0a4194cd18c7394ae822a44d105a70555a7eca7 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Fri, 18 Aug 2023 17:18:32 +0200 Subject: [PATCH 3/7] Prevent error log if no file was created In case no report is created, there is an error message which is not useful : `ls: cannot access 'build/sanitizer_report*': No such file or directory` This case is treated in the else condition already. --- .github/workflows/code_sanitizers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_sanitizers.yml b/.github/workflows/code_sanitizers.yml index c55296312a..964ac9b3c5 100644 --- a/.github/workflows/code_sanitizers.yml +++ b/.github/workflows/code_sanitizers.yml @@ -66,7 +66,7 @@ jobs: run: | ( issue_reported=false - reports=$(ls build/sanitizer_report*) + reports=$(ls build/sanitizer_report* 2>/dev/null) if [[ -n "${reports}" ]]; then echo "Report Output:" for report in ${reports}; do From 50ccef11a7e440231d320b0399f0cffe1a29fdfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:02:34 +0200 Subject: [PATCH 4/7] Fixes --- .github/workflows/code_sanitizers.yml | 56 ++++++++++----------------- .github/workflows/unit_tests.yml | 30 +++++++++----- 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/.github/workflows/code_sanitizers.yml b/.github/workflows/code_sanitizers.yml index 964ac9b3c5..7172be2af2 100644 --- a/.github/workflows/code_sanitizers.yml +++ b/.github/workflows/code_sanitizers.yml @@ -2,28 +2,25 @@ name: Code Sanitizers on: [push, pull_request, workflow_dispatch] -env: - RELEASE: 0 - artifact: 0 - -jobs: - google_sanitizers_linux: - name: ${{ matrix.SANITIZER }} / ROCKSDB=${{ matrix.TEST_USE_ROCKSDB }} / ${{ matrix.COMPILER }} +jobs: + linux_sanitizers: + name: Linux [${{ matrix.SANITIZER }}] [${{ matrix.BACKEND }} | ${{ matrix.COMPILER }}] timeout-minutes: 120 strategy: fail-fast: false matrix: - TEST_USE_ROCKSDB: [0, 1] + BACKEND: [lmdb, rocksdb] COMPILER: [clang] SANITIZER: [ASAN, ASAN_INT, TSAN] runs-on: ubuntu-22.04 - outputs: - issue_reported: ${{ steps.show_report.outputs.issue_reported }} env: COMPILER: ${{ matrix.COMPILER }} - TEST_USE_ROCKSDB: ${{ matrix.TEST_USE_ROCKSDB }} - XSAN: ${{ endsWith(matrix.sanitizer, 'ASAN_INT') && 'ASAN' || matrix.SANITIZER }} - XSAN_SUPPRESSIONS: ${{ endsWith(matrix.SANITIZER, 'TSAN') && 'suppressions=../tsan_suppressions' || '' }} + BACKEND: ${{ matrix.BACKEND }} + SANITIZER: ${{ matrix.SANITIZER }} + TEST_USE_ROCKSDB: ${{ matrix.BACKEND == 'rocksdb' && '1' || '0' }} + DEADLINE_SCALE_FACTOR: ${{ matrix.BACKEND == 'rocksdb' && '2' || '1' }} + ASAN_OPTIONS: log_exe_name=1:log_path=sanitizer_report + TSAN_OPTIONS: log_exe_name=1:log_path=sanitizer_report:suppressions=../tsan_suppressions if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository steps: - name: Checkout @@ -34,35 +31,24 @@ jobs: - name: Prepare run: sudo -E ci/prepare/linux/prepare.sh - - name: XSan variable values - run: | - ( - echo "XSAN: '${XSAN}'" - echo "XSAN_SUPPRESSIONS: '${XSAN_SUPPRESSIONS}'" - ) - - name: Build Tests - id: build_tests - run: ${{ matrix.SANITIZER }}=1 ci/build-ci.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 'core_test rpc_test' + id: build + run: ci/build-tests.sh - - name: Run core_test - id: core_test + - name: Core Tests + if: steps.build.outcome == 'success' && (success() || failure()) continue-on-error: true - run: | - export ${XSAN}_OPTIONS="${XSAN_SUPPRESSIONS} log_exe_name=1 log_path=sanitizer_report" - timeout -sHUP 45m ./core_test - working-directory: build - - - name: Run rpc_test + run: timeout -sKILL 45m ../ci/tests/run-core-tests.sh + working-directory: build + + - name: RPC Tests + if: steps.build.outcome == 'success' && (success() || failure()) id: rpc_test continue-on-error: true - run: | - export ${XSAN}_OPTIONS="${XSAN_SUPPRESSIONS} log_exe_name=1 log_path=sanitizer_report" - timeout -sHUP 20m ./rpc_test - working-directory: build + run: timeout -sKILL 20m ../ci/tests/run-rpc-tests.sh + working-directory: build - name: Test Reports - id: show_report run: | ( issue_reported=false diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index f24e214eec..83925c80c5 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -54,15 +54,18 @@ jobs: - name: Core Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-core-tests.sh + run: ../ci/tests/run-core-tests.sh + working-directory: build - name: RPC Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-rpc-tests.sh + run: ../ci/tests/run-rpc-tests.sh + working-directory: build - name: System Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-system-tests.sh + run: ../ci/tests/run-system-tests.sh + working-directory: build linux_test: name: Linux [${{ matrix.BACKEND }} | ${{ matrix.COMPILER }}] @@ -118,19 +121,23 @@ jobs: - name: Core Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-core-tests.sh + run: ../ci/tests/run-core-tests.sh + working-directory: build - name: RPC Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-rpc-tests.sh + run: ../ci/tests/run-rpc-tests.sh + working-directory: build - name: System Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-system-tests.sh + run: ../ci/tests/run-system-tests.sh + working-directory: build - name: QT Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-qt-tests.sh + run: ../ci/tests/run-qt-tests.sh + working-directory: build windows_test: name: Windows [${{ matrix.BACKEND }}] @@ -185,15 +192,18 @@ jobs: - name: Core Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-core-tests.sh + run: ../ci/tests/run-core-tests.sh + working-directory: build shell: bash - name: RPC Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-rpc-tests.sh + run: ../ci/tests/run-rpc-tests.sh + working-directory: build shell: bash - name: System Tests if: steps.build.outcome == 'success' && (success() || failure()) - run: cd build && ../ci/tests/run-system-tests.sh + run: ../ci/tests/run-system-tests.sh + working-directory: build shell: bash \ No newline at end of file From efb282b3c322b205167761dc9d607497620787e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:36:03 +0200 Subject: [PATCH 5/7] Separate script for printing reports --- .github/workflows/code_sanitizers.yml | 20 ++------------------ ci/tests/show-sanitizer-reports.sh | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 ci/tests/show-sanitizer-reports.sh diff --git a/.github/workflows/code_sanitizers.yml b/.github/workflows/code_sanitizers.yml index 7172be2af2..64e838783c 100644 --- a/.github/workflows/code_sanitizers.yml +++ b/.github/workflows/code_sanitizers.yml @@ -43,26 +43,10 @@ jobs: - name: RPC Tests if: steps.build.outcome == 'success' && (success() || failure()) - id: rpc_test continue-on-error: true run: timeout -sKILL 20m ../ci/tests/run-rpc-tests.sh working-directory: build - name: Test Reports - run: | - ( - issue_reported=false - reports=$(ls build/sanitizer_report* 2>/dev/null) - if [[ -n "${reports}" ]]; then - echo "Report Output:" - for report in ${reports}; do - echo "File: $report" - cat ${report} - echo - done - issue_reported=true - else - echo "No report has been generated." - fi - echo "issue_reported=${issue_reported}" >> $GITHUB_OUTPUT - ) || exit 0 + run: ../ci/tests/show-sanitizer-reports.sh + working-directory: build diff --git a/ci/tests/show-sanitizer-reports.sh b/ci/tests/show-sanitizer-reports.sh new file mode 100644 index 0000000000..27c995c17f --- /dev/null +++ b/ci/tests/show-sanitizer-reports.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +issue_reported=false +reports=$(ls ./sanitizer_report* 2>/dev/null) +if [[ -n "${reports}" ]]; then + echo "Report Output:" + for report in ${reports}; do + echo "File: $report" + cat ${report} + echo + done + issue_reported=true +else + echo "No report has been generated." +fi + +echo "issue_reported=${issue_reported}" >> $GITHUB_OUTPUT \ No newline at end of file From 529033d2e1663c07cf9d797599e7b9aa63beae44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:59:16 +0200 Subject: [PATCH 6/7] Report pretty printing --- .github/workflows/code_sanitizers.yml | 5 ++-- ci/tests/show-sanitizer-reports.sh | 36 +++++++++++++++++++-------- 2 files changed, 29 insertions(+), 12 deletions(-) mode change 100644 => 100755 ci/tests/show-sanitizer-reports.sh diff --git a/.github/workflows/code_sanitizers.yml b/.github/workflows/code_sanitizers.yml index 64e838783c..4ef0b26833 100644 --- a/.github/workflows/code_sanitizers.yml +++ b/.github/workflows/code_sanitizers.yml @@ -47,6 +47,7 @@ jobs: run: timeout -sKILL 20m ../ci/tests/run-rpc-tests.sh working-directory: build - - name: Test Reports + - name: Reports + if: steps.build.outcome == 'success' && (success() || failure()) run: ../ci/tests/show-sanitizer-reports.sh - working-directory: build + working-directory: build diff --git a/ci/tests/show-sanitizer-reports.sh b/ci/tests/show-sanitizer-reports.sh old mode 100644 new mode 100755 index 27c995c17f..ba4f92d608 --- a/ci/tests/show-sanitizer-reports.sh +++ b/ci/tests/show-sanitizer-reports.sh @@ -1,17 +1,33 @@ #!/bin/bash +set -uo pipefail issue_reported=false -reports=$(ls ./sanitizer_report* 2>/dev/null) -if [[ -n "${reports}" ]]; then - echo "Report Output:" - for report in ${reports}; do - echo "File: $report" - cat ${report} - echo + +# Check for sanitizer reports using glob +shopt -s nullglob +reports=(./sanitizer_report*) + +if [[ ${#reports[@]} -gt 0 ]]; then + for report in "${reports[@]}"; do + report_name=$(basename "${report}") + echo "::group::Report: $report_name" + + cat "${report}" + + echo "::endgroup::" + + issue_reported=true done - issue_reported=true else - echo "No report has been generated." + echo "::notice::No report has been generated." fi -echo "issue_reported=${issue_reported}" >> $GITHUB_OUTPUT \ No newline at end of file +echo "issue_reported=${issue_reported}" >> $GITHUB_OUTPUT + +if $issue_reported; then + echo "::error::Issues were reported in the sanitizer report." + exit 1 +else + echo "::notice::No issues found in the sanitizer reports." + exit 0 +fi \ No newline at end of file From 2d711279785199acbe6a7e5e9481cb57d1cd241b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Tue, 5 Sep 2023 22:53:22 +0200 Subject: [PATCH 7/7] Report sanitizer errors without failing whole CI pipeline --- .github/workflows/code_sanitizers.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code_sanitizers.yml b/.github/workflows/code_sanitizers.yml index 4ef0b26833..438f8fd051 100644 --- a/.github/workflows/code_sanitizers.yml +++ b/.github/workflows/code_sanitizers.yml @@ -49,5 +49,6 @@ jobs: - name: Reports if: steps.build.outcome == 'success' && (success() || failure()) + continue-on-error: true run: ../ci/tests/show-sanitizer-reports.sh working-directory: build