diff --git a/.github/actions/env/action.yml b/.github/actions/env/action.yml new file mode 100644 index 00000000000..3cefa91ddfb --- /dev/null +++ b/.github/actions/env/action.yml @@ -0,0 +1,35 @@ +name: env +description: Construct env for each operating system +runs: + using: 'composite' + steps: + - shell: bash + run: | + cat >> $GITHUB_ENV << EOF + XDIST_ARGUMENTS=-n auto + PYTEST_ARGUMENTS=--randomly-seed=1 --disable-warnings --reruns 1 --reruns-delay 1 --verbose --durations=3 --showlocals + EOF + + - shell: bash + run: | + cat >> $GITHUB_ENV << EOF + PYTEST_CORE_ARGUMENTS=./src/tribler/core ${PYTEST_ARGUMENTS} + PYTEST_TUNNELS_ARGUMENTS=./src/tribler/core/components/tunnel/tests/test_full_session --tunneltests ${PYTEST_ARGUMENTS} + PYTEST_GUI_ARGUMENTS=./src/tribler/gui --guitests ${PYTEST_ARGUMENTS} + EOF + + - if: runner.os == 'Linux' || runner.os == 'macOS' + shell: bash + run: | + cat >> $GITHUB_ENV << EOF + PYTEST_CORE_ARGUMENTS=${PYTEST_CORE_ARGUMENTS} --looptime + PYTEST_TUNNELS_ARGUMENTS=${PYTEST_TUNNELS_ARGUMENTS} --looptime + PYTEST_GUI_ARGUMENTS=${PYTEST_GUI_ARGUMENTS} --looptime + EOF + + - if: runner.os == 'Linux' + shell: bash + run: | + cat >> $GITHUB_ENV << EOF + XDIST_ARGUMENTS=--tx "2*popen//execmodel=eventlet" + EOF diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 9a562cdd185..c26dcbb44ea 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -43,16 +43,13 @@ jobs: custom_cache_key_element: ${{inputs.ref}} - name: Export env - uses: cardinalby/export-env-action@v2 - with: - envFile: ./.github/workflows/vars/pytest.env - expand: true + uses: ./.github/actions/env - name: Run Pytest with Coverage timeout-minutes: 10 run: | - coverage run --source=./src/tribler/core -p -m pytest ${PYTEST_CORE_ARGUMENTS_LINUX} - coverage run --source=./src/tribler/core -p -m pytest ${PYTEST_TUNNELS_ARGUMENTS_LINUX} + coverage run --source=./src/tribler/core -p -m pytest "${PYTEST_CORE_ARGUMENTS} {XDIST_ARGUMENTS}" + coverage run --source=./src/tribler/core -p -m pytest "${PYTEST_TUNNELS_ARGUMENTS} {XDIST_ARGUMENTS}" coverage combine coverage xml diff --git a/.github/workflows/guitest.yml b/.github/workflows/guitest.yml index 99eb92c4bb7..dc20650d814 100644 --- a/.github/workflows/guitest.yml +++ b/.github/workflows/guitest.yml @@ -68,25 +68,11 @@ jobs: uses: pyvista/setup-headless-display-action@v1 - name: Export env - uses: cardinalby/export-env-action@v2 - with: - envFile: ./.github/workflows/vars/pytest.env - expand: true - - - name: Run GUI tests (Win) - if: runner.os == 'Windows' - run: | - pytest ${PYTEST_GUI_ARGUMENTS_WIN} - - - name: Run GUI tests (Linux) - if: runner.os == 'Linux' - run: | - pytest ${PYTEST_GUI_ARGUMENTS_LINUX} + uses: ./.github/actions/env - - name: Run GUI tests (Mac) - if: runner.os == 'macOS' + - name: Run GUI tests run: | - pytest ${PYTEST_GUI_ARGUMENTS_MAC} + pytest ${PYTEST_GUI_ARGUMENTS} - uses: actions/upload-artifact@v3 if: always() diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b521b719c39..7d3f712e678 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -39,7 +39,7 @@ jobs: env: PYTEST_SENTRY_DSN: ${{secrets.PYTEST_SENTRY_DSN}} - timeout-minutes: 10 + timeout-minutes: 8 steps: - uses: actions/checkout@v3 @@ -58,25 +58,9 @@ jobs: uses: ./.github/actions/windows_dependencies - name: Export env - uses: cardinalby/export-env-action@v2 - with: - envFile: ./.github/workflows/vars/pytest.env - expand: true - - - name: Run Pytest (Win) - if: runner.os == 'Windows' - run: | - pytest ${PYTEST_CORE_ARGUMENTS_WIN} - pytest ${PYTEST_TUNNELS_ARGUMENTS_WIN} - - - name: Run Pytest (Linux) - if: runner.os == 'Linux' - run: | - pytest ${PYTEST_CORE_ARGUMENTS_LINUX} - pytest ${PYTEST_TUNNELS_ARGUMENTS_LINUX} + uses: ./.github/actions/env - - name: Run Pytest (Mac) - if: runner.os == 'macOS' + - name: Run Pytest run: | - pytest ${PYTEST_CORE_ARGUMENTS_MAC} - pytest ${PYTEST_TUNNELS_ARGUMENTS_MAC} + pytest ${PYTEST_CORE_ARGUMENTS} ${XDIST_ARGUMENTS} + pytest ${PYTEST_TUNNELS_ARGUMENTS} ${XDIST_ARGUMENTS} diff --git a/.github/workflows/pytest_custom_ipv8.yml b/.github/workflows/pytest_custom_ipv8.yml index fc381d16e86..444e0b0893a 100644 --- a/.github/workflows/pytest_custom_ipv8.yml +++ b/.github/workflows/pytest_custom_ipv8.yml @@ -72,25 +72,9 @@ jobs: uses: ./.github/actions/windows_dependencies - name: Export env - uses: cardinalby/export-env-action@v2 - with: - envFile: ./.github/workflows/vars/pytest.env - expand: true - - - name: Run Pytest (Win) - if: runner.os == 'Windows' - run: | - pytest ${PYTEST_CORE_ARGUMENTS_WIN} - pytest ${PYTEST_TUNNELS_ARGUMENTS_WIN} - - - name: Run Pytest (Linux) - if: runner.os == 'Linux' - run: | - pytest ${PYTEST_CORE_ARGUMENTS_LINUX} - pytest ${PYTEST_TUNNELS_ARGUMENTS_LINUX} + uses: ./.github/actions/env - - name: Run Pytest (Mac) - if: runner.os == 'macOS' + - name: Run Pytest run: | - pytest ${PYTEST_CORE_ARGUMENTS_MAC} - pytest ${PYTEST_TUNNELS_ARGUMENTS_MAC} + pytest ${PYTEST_CORE_ARGUMENTS} + pytest ${PYTEST_TUNNELS_ARGUMENTS} diff --git a/.github/workflows/vars/pytest.env b/.github/workflows/vars/pytest.env deleted file mode 100644 index f5e1101a82b..00000000000 --- a/.github/workflows/vars/pytest.env +++ /dev/null @@ -1,16 +0,0 @@ -PYTEST_ARGUMENTS='--randomly-seed=1 --disable-warnings --reruns 1 --reruns-delay 1 --verbose --durations=3 --showlocals' - -PYTEST_CORE_ARGUMENTS='./src/tribler/core ${PYTEST_ARGUMENTS}' -PYTEST_CORE_ARGUMENTS_WIN='${PYTEST_CORE_ARGUMENTS} -n auto' -PYTEST_CORE_ARGUMENTS_LINUX='${PYTEST_CORE_ARGUMENTS} --looptime --tx "2*popen//execmodel=eventlet"' -PYTEST_CORE_ARGUMENTS_MAC='${PYTEST_CORE_ARGUMENTS} --looptime -n auto' - -PYTEST_TUNNELS_ARGUMENTS='./src/tribler/core/components/tunnel/tests/test_full_session --tunneltests ${PYTEST_ARGUMENTS}' -PYTEST_TUNNELS_ARGUMENTS_WIN='${PYTEST_TUNNELS_ARGUMENTS} -n auto' -PYTEST_TUNNELS_ARGUMENTS_LINUX='${PYTEST_TUNNELS_ARGUMENTS} --looptime --tx "2*popen//execmodel=eventlet"' -PYTEST_TUNNELS_ARGUMENTS_MAC='${PYTEST_TUNNELS_ARGUMENTS} --looptime -n auto' - -PYTEST_GUI_ARGUMENTS='./src/tribler/gui --guitests ${PYTEST_ARGUMENTS}' -PYTEST_GUI_ARGUMENTS_WIN='${PYTEST_GUI_ARGUMENTS}' -PYTEST_GUI_ARGUMENTS_LINUX='${PYTEST_GUI_ARGUMENTS} --looptime' -PYTEST_GUI_ARGUMENTS_MAC='${PYTEST_GUI_ARGUMENTS} --looptime'