PR Validation Checker #736
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Validation Checker | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
pr_commented: | |
name: Validate PR | |
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, 'validate') }} | |
needs: set_pending_status | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] # macos-latest not tested due to crashing. | |
version: ["3.9", "3.10"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: refs/pull/${{ github.event.issue.number }}/head | |
submodules: 'true' | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.version }} | |
cache: 'pip' | |
- uses: actions/cache/restore@v4 | |
if: matrix.os == 'windows-latest' | |
id: restore_cache | |
with: | |
path: src/libsodium.dll | |
key: cache_libsodium_dll | |
- run: python -m pip install -r requirements.txt | |
- run: | | |
cd src | |
python run_unit_tests.py -a | |
env: | |
TEST_IPV8_WITH_IPV6: 0 | |
- run: | | |
cd src | |
python run_unit_tests.py -a | |
env: | |
TEST_IPV8_WITH_IPV6: 1 | |
- run: | | |
cd src | |
python run_unit_tests.py -a -k tribler/test_integration -p 2 | |
set_pending_status: | |
if: ${{github.event.issue.pull_request && startsWith(github.event.comment.body, 'validate') }} | |
runs-on: ubuntu-latest | |
outputs: | |
actual_pull_head: ${{ steps.sha_share_step.outputs.actual_pull_head }} | |
steps: | |
- name: Retrieving commit | |
shell: bash | |
run: | | |
{ | |
echo 'actual_pull_head<<EOF' | |
git ls-remote ${{ github.server_url }}/${{ github.repository }}/ refs/pull/${{ github.event.issue.number }}/head | grep -o "^\w*\b" | |
echo | |
echo EOF | |
} >> "$GITHUB_ENV" | |
- name: Sharing commit SHA between jobs | |
id: sha_share_step | |
run: echo "actual_pull_head=${{ env.actual_pull_head }}" >> "$GITHUB_OUTPUT" | |
- name: Set commit pending status | |
uses: guibranco/github-status-action-v2@v1.1.13 | |
with: | |
authToken: ${{secrets.COMMIT_STATUS_TOKEN}} | |
context: 'Cross-env Validation' | |
description: 'Pending..' | |
state: 'pending' | |
sha: ${{ env.actual_pull_head }} | |
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
set_failure_status: | |
if: ${{failure() && github.event.issue.pull_request && startsWith(github.event.comment.body, 'validate') }} | |
needs: [set_pending_status, pr_commented] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set commit failed status | |
env: | |
actual_pull_head: ${{needs.set_pending_status.outputs.actual_pull_head}} | |
uses: guibranco/github-status-action-v2@v1.1.13 | |
with: | |
authToken: ${{secrets.COMMIT_STATUS_TOKEN}} | |
context: 'Cross-env Validation' | |
description: 'Failed!' | |
state: 'failure' | |
sha: ${{ env.actual_pull_head }} | |
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
set_success_status: | |
if: ${{!failure() && github.event.issue.pull_request && startsWith(github.event.comment.body, 'validate') }} | |
needs: [set_pending_status, pr_commented] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set commit success status | |
env: | |
actual_pull_head: ${{needs.set_pending_status.outputs.actual_pull_head}} | |
uses: guibranco/github-status-action-v2@v1.1.13 | |
with: | |
authToken: ${{secrets.COMMIT_STATUS_TOKEN}} | |
context: 'Cross-env Validation' | |
description: 'Success!' | |
state: 'success' | |
sha: ${{ env.actual_pull_head }} | |
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |