Set compiler paths #11
Workflow file for this run
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
name: QA - RPC Fuzzer Tests | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * 0' # Runs every Sunday at 00:00 AM UTC | |
push: | |
branches: | |
- fuzzer-github-actions | |
jobs: | |
fuzzer-test-suite: | |
runs-on: self-hosted | |
env: | |
ERIGON_DATA_DIR: /opt/erigon-versions/reference-version/datadir | |
RPC_PAST_TEST_DIR: /opt/rpc-past-tests | |
ERIGON_QA_PATH: /opt/erigon-qa | |
steps: | |
- name: Checkout Silkworm Repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: "1" # Fetch only the last commit, not the entire history | |
- name: Install Compiler (Clang 15) | |
run: | | |
whoami | |
# Ensure the correct version of Clang is installed | |
# sudo apt-get install -y libc++-15-dev libc++abi-15-dev clang-15 | |
# Set the compiler paths | |
# sudo ln -sfv /usr/bin/clang-15 /usr/bin/clang | |
# sudo ln -sfv /usr/bin/clang++-15 /usr/bin/clang++ | |
# sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 | |
# sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 | |
ln -sfv /usr/bin/clang-15 /usr/bin/clang | |
ln -sfv /usr/bin/clang++-15 /usr/bin/clang++ | |
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 | |
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 | |
- name: Clean Build Directory | |
run: rm -rf ${{runner.workspace}}/silkworm/build | |
- name: Create Build Environment | |
run: cmake -E make_directory ${{runner.workspace}}/silkworm/build | |
- name: Preinstall Conan packages | |
working-directory: ${{runner.workspace}}/silkworm | |
run: conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/linux_x64_clang_13_release . | |
- name: Configure CMake | |
working-directory: ${{runner.workspace}}/silkworm/build | |
run: CC=/lib/llvm-15/bin/clang CXX=/lib/llvm-15/bin/clang cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=linux_x64_clang_13_release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON | |
- name: Build Silkworm Fuzzer Test | |
working-directory: ${{runner.workspace}}/silkworm/build | |
run: CC=/lib/llvm-15/bin/clang CXX=/lib/llvm-15/bin/clang cmake --build . --target rpcdaemon_fuzzer_test -j 8 | |
- name: Prepare Corpus Directories | |
working-directory: ${{runner.workspace}}/silkworm/build/cmd/test | |
run: | | |
echo "Ensure persistent directories for fuzzing corpus are created" | |
mkdir -p $RPC_PAST_TEST_DIR/silkworm-fuzzer/corpus | |
mkdir -p $RPC_PAST_TEST_DIR/silkworm-fuzzer/crashes | |
echo "Create corpus artifacts from execution-api specification" | |
mkdir -p artifacts | |
for file in ../../../third_party/execution-apis/tests/*/*.io; do cp --backup=numbered "$file" artifacts; done | |
for file in artifacts/*; do sed -i '2,$d' "$file"; done | |
for file in artifacts/*; do sed -i 's/^>> //' "$file"; done | |
- name: Pause the Erigon instance dedicated to db maintenance | |
run: | | |
python3 $ERIGON_QA_PATH/test_system/db-producer/pause_production.py || true | |
- name: Execute Silkworm Fuzzer Test | |
working-directory: ${{runner.workspace}}/silkworm/build/cmd/test | |
id: test_step | |
run: | | |
set +e # Disable exit on error | |
./rpcdaemon_fuzzer_test $RPC_PAST_TEST_DIR/silkworm-fuzzer/corpus artifacts -max_total_time=86400 -detect_leaks=0 | |
# To enable running multiple tests in parallel, use the following command | |
# ./rpcdaemon_fuzzer_test $RPC_PAST_TEST_DIR/silkworm-fuzzer/corpus artifacts -max_total_time=86400 -detect_leaks=0 -jobs=8 | |
# Check test runner exit status | |
if [ $test_exit_status -eq 0 ]; then | |
echo "tests completed successfully" | |
echo | |
echo "TEST_RESULT=success" >> "$GITHUB_OUTPUT" | |
else | |
echo "error detected during tests" | |
echo "TEST_RESULT=failure" >> "$GITHUB_OUTPUT" | |
# Save failed results to a directory with timestamp and commit hash | |
cp crash-* $RPC_PAST_TEST_DIR/silkworm-fuzzer/crashes/ | |
fi | |
- name: Clean up | |
if: always() | |
run: | | |
# Resume the Erigon instance dedicated to db maintenance | |
python3 $ERIGON_QA_PATH/test_system/db-producer/resume_production.py || true | |
# Reset compiler paths | |
# sudo update-alternatives --remove cc /usr/bin/clang | |
# sudo update-alternatives --remove c++ /usr/bin/clang++ | |
# sudo rm -f /usr/bin/clang | |
# sudo rm -f /usr/bin/clang++ | |
update-alternatives --remove cc /usr/bin/clang | |
update-alternatives --remove c++ /usr/bin/clang++ | |
rm -f /usr/bin/clang | |
rm -f /usr/bin/clang++ | |
- name: Action for Success | |
if: steps.test_step.outputs.TEST_RESULT == 'success' | |
run: echo "::notice::Tests completed successfully" | |
- name: Action for Failure | |
if: steps.test_step.outputs.TEST_RESULT != 'success' | |
run: | | |
echo "::error::Error detected during tests" | |
exit 1 | |