From 84ded667ea0e14d922908cd310284650f8eb6d43 Mon Sep 17 00:00:00 2001 From: drew2a Date: Mon, 21 Nov 2022 11:49:15 +0100 Subject: [PATCH] Add `gatekeeper.yml` --- .github/workflows/!PR.yml | 138 +++++++++++++++--------------- .github/workflows/gatekeeper.yml | 31 +++++++ .github/workflows/pytest.yml | 94 ++++++++++---------- .github/workflows/vars/pytest.env | 1 - 4 files changed, 149 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/gatekeeper.yml diff --git a/.github/workflows/!PR.yml b/.github/workflows/!PR.yml index e7030e14428..b6aaa5918e3 100644 --- a/.github/workflows/!PR.yml +++ b/.github/workflows/!PR.yml @@ -1,11 +1,9 @@ name: PR on: - pull_request: - types: - - opened - - synchronize - - ready_for_review + workflow_run: + workflows: [ gatekeeper ] + types: [ completed ] jobs: changes: # detect changes @@ -52,70 +50,72 @@ jobs: needs: changes if: ${{ needs.changes.outputs.src == 'true' }} uses: ./.github/workflows/pytest.yml + secrets: + PYTEST_SENTRY_DSN: ${{github.event.workflow_run.gatekeeper.outputs.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/gatekeeper.yml b/.github/workflows/gatekeeper.yml new file mode 100644 index 00000000000..b8c29564850 --- /dev/null +++ b/.github/workflows/gatekeeper.yml @@ -0,0 +1,31 @@ +name: gatekeeper +# This workflow shares subset of secrets from the main repo for PRs from fork repos +# if the user has write access to the main repo + +on: + pull_request_target: + types: + - opened + - synchronize + - ready_for_review + +jobs: + run: + runs-on: ubuntu-latest + outputs: + pytest-sentry-dsn: ${{ steps.setter.outputs.pytest-sentry-dsn }} + + steps: + - name: Check if user has write access + uses: lannonbr/repo-permission-check-action@2bb8c89ba8bf115c4bfab344d6a6f442b24c9a1f + with: + permission: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Share secrets + id: setter + if: success() + run: | + echo "pytest-sentry-dsn=${{secrets.PYTEST_SENTRY_DSN}}" >> $GITHUB_OUTPUT + \ No newline at end of file diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 06844a9bfb2..e8b60117fcb 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -30,52 +30,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/.github/workflows/vars/pytest.env b/.github/workflows/vars/pytest.env index b1061b05cc6..e8f228ca237 100644 --- a/.github/workflows/vars/pytest.env +++ b/.github/workflows/vars/pytest.env @@ -3,4 +3,3 @@ PYTEST_COMMON_ARGUMENTS='--randomly-seed=1 --disable-warnings --reruns 1 --reru PYTEST_CORE_ARGUMENTS='./src/tribler/core ${PYTEST_COMMON_ARGUMENTS}' PYTEST_TUNNELS_ARGUMENTS='./src/tribler/core/components/tunnel/tests/test_full_session --tunneltests ${PYTEST_COMMON_ARGUMENTS}' PYTEST_GUI_ARGUMENTS='./src/tribler/gui --guitests ${PYTEST_COMMON_ARGUMENTS}' -PYTEST_SENTRY_DSN=https://4c299e96dcae424a8bdd61dee346b749@sentry.tribler.org/8 \ No newline at end of file