diff --git a/.github/workflows/!PR.yml b/.github/workflows/!PR.yml index e7030e14428..d6e3405b474 100644 --- a/.github/workflows/!PR.yml +++ b/.github/workflows/!PR.yml @@ -1,7 +1,7 @@ name: PR on: - pull_request: + pull_request_target: types: - opened - synchronize @@ -45,77 +45,88 @@ jobs: - 'build/**' - 'src/**' - 'requirements*' - - + + gatekeeper: # check user's permissions + runs-on: ubuntu-latest + steps: + - name: Check if user has write access + uses: lannonbr/repo-permission-check-action@2bb8c89ba8bf115c4bfab344d6a6f442b24c9a1f + with: + permission: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # PR is Draft and PR is Ready pytest: - needs: changes - if: ${{ needs.changes.outputs.src == 'true' }} + needs: [changes, gatekeeper] +# if: ${{ needs.changes.outputs.src == 'true' }} uses: ./.github/workflows/pytest.yml +# secrets: +# PYTEST_SENTRY_DSN: ${{secrets.PYTEST_SENTRY_DSN}} with: python-version: 3.8 matrix: '{"os": ["windows-latest"]}' - - guitest: - needs: changes - if: ${{ needs.changes.outputs.src == 'true' }} - uses: ./.github/workflows/guitest.yml - with: - python-version: 3.8 - matrix: '{"os": ["windows-latest"]}' - - scripttest: - needs: changes - if: ${{ needs.changes.outputs.scripts == 'true' }} - uses: ./.github/workflows/scripttest.yml - with: - python-version: 3.8 - - coverage: - needs: changes - if: ${{ needs.changes.outputs.src == 'true' }} - uses: ./.github/workflows/coverage.yml - with: - python-version: 3.8 - - # PR is Ready only - pytest_nix: - needs: changes - if: ${{needs.changes.outputs.src == 'true' && !github.event.pull_request.draft}} - uses: ./.github/workflows/pytest.yml - with: - python-version: 3.8 - matrix: '{"os": ["macos-latest", "ubuntu-latest"]}' - - guitest_nix: - needs: changes - if: ${{needs.changes.outputs.src == 'true' && !github.event.pull_request.draft}} - uses: ./.github/workflows/guitest.yml - with: - python-version: 3.8 - matrix: '{"os": ["macos-latest", "ubuntu-latest"]}' - - ubuntu: - needs: changes - if: ${{needs.changes.outputs.build == 'true' && !github.event.pull_request.draft}} - uses: ./.github/workflows/build_ubuntu.yml - with: - upload: false - os: ubuntu-20.04 - python-version: 3.8 - - windows: - needs: changes - if: ${{needs.changes.outputs.build == 'true' && !github.event.pull_request.draft}} - uses: ./.github/workflows/build_windows.yml - with: - upload: false - os: windows-latest - python-version: 3.8 - - documentation: - needs: changes - if: ${{needs.changes.outputs.doc == 'true' && !github.event.pull_request.draft}} - uses: ./.github/workflows/documentation.yml - with: - python-version: 3.8 +# +# guitest: +# needs: changes +# if: ${{ needs.changes.outputs.src == 'true' }} +# uses: ./.github/workflows/guitest.yml +# with: +# python-version: 3.8 +# matrix: '{"os": ["windows-latest"]}' +# +# scripttest: +# needs: changes +# if: ${{ needs.changes.outputs.scripts == 'true' }} +# uses: ./.github/workflows/scripttest.yml +# with: +# python-version: 3.8 +# +# coverage: +# needs: changes +# if: ${{ needs.changes.outputs.src == 'true' }} +# uses: ./.github/workflows/coverage.yml +# with: +# python-version: 3.8 +# +# # PR is Ready only +# pytest_nix: +# needs: changes +# if: ${{needs.changes.outputs.src == 'true' && !github.event.pull_request.draft}} +# uses: ./.github/workflows/pytest.yml +# with: +# python-version: 3.8 +# matrix: '{"os": ["macos-latest", "ubuntu-latest"]}' +# +# guitest_nix: +# needs: changes +# if: ${{needs.changes.outputs.src == 'true' && !github.event.pull_request.draft}} +# uses: ./.github/workflows/guitest.yml +# with: +# python-version: 3.8 +# matrix: '{"os": ["macos-latest", "ubuntu-latest"]}' +# +# ubuntu: +# needs: changes +# if: ${{needs.changes.outputs.build == 'true' && !github.event.pull_request.draft}} +# uses: ./.github/workflows/build_ubuntu.yml +# with: +# upload: false +# os: ubuntu-20.04 +# python-version: 3.8 +# +# windows: +# needs: changes +# if: ${{needs.changes.outputs.build == 'true' && !github.event.pull_request.draft}} +# uses: ./.github/workflows/build_windows.yml +# with: +# upload: false +# os: windows-latest +# python-version: 3.8 +# +# documentation: +# needs: changes +# if: ${{needs.changes.outputs.doc == 'true' && !github.event.pull_request.draft}} +# uses: ./.github/workflows/documentation.yml +# with: +# python-version: 3.8 diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 06844a9bfb2..7eeb271dcb9 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -2,6 +2,11 @@ name: Pytest on: workflow_call: + secrets: + PYTEST_SENTRY_DSN: + description: 'Sentry URL' + required: false + inputs: python-version: default: 3.8 @@ -30,52 +35,56 @@ jobs: shell: bash timeout-minutes: 10 + env: + PYTEST_SENTRY_DSN: ${{secrets.PYTEST_SENTRY_DSN}} steps: - uses: actions/checkout@v3 + - run: + echo $PYTEST_SENTRY_DSN - - name: Create python environment - uses: ./.github/actions/pyenv - with: - python-version: ${{inputs.python-version}} - requirements: requirements-test.txt - - - name: Install dependencies (Windows) - if: runner.os == 'Windows' - uses: ./.github/actions/windows_dependencies - - - name: Export env - uses: cardinalby/export-env-action@v2 - with: - envFile: ./.github/workflows/vars/pytest.env - expand: true - - - name: Add --looptime - if: runner.os != 'Windows' - run: | - echo "PYTEST_CORE_ARGUMENTS=${PYTEST_CORE_ARGUMENTS} --looptime" >> $GITHUB_ENV - echo "PYTEST_TUNNELS_ARGUMENTS=${PYTEST_TUNNELS_ARGUMENTS} --looptime" >> $GITHUB_ENV - - - name: Run Pytest - if: ${{!inputs.enable_profiling}} - run: | - pytest ${PYTEST_CORE_ARGUMENTS} - - - name: Run Pytest (Profiler) - if: ${{inputs.enable_profiling}} - uses: ./.github/actions/profile - with: - artifact_name: pytest_prof.svg - arguments: ${PYTEST_CORE_ARGUMENTS} - - - name: Run Tunnels Tests - if: ${{!inputs.enable_profiling}} - run: | - pytest ${PYTEST_TUNNELS_ARGUMENTS} - - - name: Run Tunnel Tests (Profiler) - if: ${{inputs.enable_profiling}} - uses: ./.github/actions/profile - with: - artifact_name: tunneltest_prof.svg - arguments: ${PYTEST_TUNNELS_ARGUMENTS} +# - name: Create python environment +# uses: ./.github/actions/pyenv +# with: +# python-version: ${{inputs.python-version}} +# requirements: requirements-test.txt +# +# - name: Install dependencies (Windows) +# if: runner.os == 'Windows' +# uses: ./.github/actions/windows_dependencies +# +# - name: Export env +# uses: cardinalby/export-env-action@v2 +# with: +# envFile: ./.github/workflows/vars/pytest.env +# expand: true +# +# - name: Add --looptime +# if: runner.os != 'Windows' +# run: | +# echo "PYTEST_CORE_ARGUMENTS=${PYTEST_CORE_ARGUMENTS} --looptime" >> $GITHUB_ENV +# echo "PYTEST_TUNNELS_ARGUMENTS=${PYTEST_TUNNELS_ARGUMENTS} --looptime" >> $GITHUB_ENV +# +# - name: Run Pytest +# if: ${{!inputs.enable_profiling}} +# run: | +# pytest ${PYTEST_CORE_ARGUMENTS} +# +# - name: Run Pytest (Profiler) +# if: ${{inputs.enable_profiling}} +# uses: ./.github/actions/profile +# with: +# artifact_name: pytest_prof.svg +# arguments: ${PYTEST_CORE_ARGUMENTS} +# +# - name: Run Tunnels Tests +# if: ${{!inputs.enable_profiling}} +# run: | +# pytest ${PYTEST_TUNNELS_ARGUMENTS} +# +# - name: Run Tunnel Tests (Profiler) +# if: ${{inputs.enable_profiling}} +# uses: ./.github/actions/profile +# with: +# artifact_name: tunneltest_prof.svg +# arguments: ${PYTEST_TUNNELS_ARGUMENTS} diff --git a/requirements-test.txt b/requirements-test.txt index bb9c775f9f8..f520142336b 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -8,6 +8,9 @@ pytest-randomly==3.12.0 pytest-timeout==2.1.0 pytest-freezegun==0.4.2 pytest-rerunfailures==10.2 +pytest-sentry==0.1.10 +pytest-profiling==1.7.0 # for pytest profiling + freezegun==1.2.1 coverage==6.3.2 looptime==0.2 @@ -15,5 +18,3 @@ looptime==0.2 asynctest==0.13.0 # this library has to be installed to properly work with ipv8 TestBase. scipy==1.8.0 - -pytest-profiling==1.7.0 # for pytest profiling \ No newline at end of file