From a50588092e75833db614dea03b23e430f5f35983 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Sat, 25 Mar 2023 11:56:18 -0500 Subject: [PATCH] run tests in parallel, only collect coverage on ubuntu --- .github/scripts/integration_test_runner.sh | 8 +++++ .github/scripts/tool_test_runner.sh | 4 +++ .github/scripts/unit_test_runner.sh | 3 ++ .github/workflows/test.yml | 37 +++++++--------------- 4 files changed, 26 insertions(+), 26 deletions(-) create mode 100644 .github/scripts/integration_test_runner.sh create mode 100644 .github/scripts/tool_test_runner.sh create mode 100644 .github/scripts/unit_test_runner.sh diff --git a/.github/scripts/integration_test_runner.sh b/.github/scripts/integration_test_runner.sh new file mode 100644 index 000000000..a8d4058b9 --- /dev/null +++ b/.github/scripts/integration_test_runner.sh @@ -0,0 +1,8 @@ +# setup hardhat for compilation tests +pushd tests/e2e/compilation/test_data/test_node_modules/ +npm install hardhat +popd + +# used to pass --cov=$path and --cov-append to pytest +pytest $1 tests/e2e/ -n auto +python -m coverage report diff --git a/.github/scripts/tool_test_runner.sh b/.github/scripts/tool_test_runner.sh new file mode 100644 index 000000000..531d0f704 --- /dev/null +++ b/.github/scripts/tool_test_runner.sh @@ -0,0 +1,4 @@ +npm install --global ganache +# used to pass --cov=$path and --cov-append to pytest +pytest $1 tests/tools/read-storage/test_read_storage.py +python -m coverage report \ No newline at end of file diff --git a/.github/scripts/unit_test_runner.sh b/.github/scripts/unit_test_runner.sh new file mode 100644 index 000000000..cd9dc540c --- /dev/null +++ b/.github/scripts/unit_test_runner.sh @@ -0,0 +1,3 @@ +# used to pass --cov=$path and --cov-append to pytest +pytest $1 tests/unit/ +python -m coverage report \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index adb5cf3b1..0b4baeb46 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest", "windows-2022"] + type: ["unit", "integration", "tool"] steps: - uses: actions/checkout@v3 - name: Set up Python 3.8 @@ -36,34 +37,18 @@ jobs: solc-select install 0.8.0 solc-select use 0.8.0 - - name: e2e / detectors + - name: ${{ matrix.type }} + env: + TEST_TYPE: ${{ matrix.type }} + # Only run coverage on ubuntu-latest. run: | - pytest --cov=slither --cov-append tests/e2e/detectors/test_detectors.py -n auto - python -m coverage report + if [ ${{ matrix.os }} = "ubuntu-latest" ]; then + TEST_ARGS="--cov=slither --cov-append" + elif [ ${{ matrix.os }} = "windows-2022" ]; then + TEST_ARGS="" + fi + bash "./.github/scripts/${TEST_TYPE}_test_runner.sh" - - name: e2e / ast parsing - run: | - pytest --cov=slither --cov-append tests/e2e/solc_parsing/test_ast_parsing.py -n auto - python -m coverage report - - - name: e2e / compilation - run: | - pushd tests/e2e/compilation/test_data/test_node_modules/ - npm install hardhat - popd - pytest --cov=slither --cov-append tests/e2e/compilation/ - python -m coverage report - - - name: unit / core, slithir, utils - run: | - pytest --cov=slither --cov-append tests/unit/ - python -m coverage report - - - name: tools / slither-read-storage - run: | - npm install --global ganache - pytest --cov=slither --cov-append tests/tools/read-storage/test_read_storage.py - python -m coverage report - uses: ./.github/actions/upload-coverage # only aggregate test coverage over linux-based tests to avoid any OS-specific filesystem information stored in