Skip to content

Commit

Permalink
Add pytest-sentry (test)
Browse files Browse the repository at this point in the history
  • Loading branch information
drew2a committed Nov 21, 2022
1 parent 4ea5f08 commit d534eca
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 116 deletions.
149 changes: 80 additions & 69 deletions .github/workflows/!PR.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PR

on:
pull_request:
pull_request_target:
types:
- opened
- synchronize
Expand Down Expand Up @@ -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
99 changes: 54 additions & 45 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Pytest

on:
workflow_call:
secrets:
PYTEST_SENTRY_DSN:
description: 'Sentry URL'
required: false

inputs:
python-version:
default: 3.8
Expand Down Expand Up @@ -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}
5 changes: 3 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ 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

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

0 comments on commit d534eca

Please sign in to comment.