Skip to content

Fixed empty sha on validate action status setting #173

Fixed empty sha on validate action status setting

Fixed empty sha on validate action status setting #173

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.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.version }}
- run: python -m pip install -r requirements.txt
- run: python run_all_tests.py -a
env:
TEST_IPV8_WITH_IPV6: 0
- run: python run_all_tests.py -a
env:
TEST_IPV8_WITH_IPV6: 1
set_pending_status:
if: ${{github.event.issue.pull_request && startsWith(github.event.comment.body, 'validate') }}
runs-on: ubuntu-latest
steps:
- name: Retrieving commit
shell: bash
run: |
{
echo 'actual_pull_head<<EOF'
git ls-remote https://github.com/Tribler/py-ipv8/ refs/pull/${{ github.event.issue.number }}/head | grep -o "^\w*\b"
echo
echo EOF
} >> "$GITHUB_ENV"
- name: Set commit pending status
uses: guibranco/[email protected]
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'Cross-env Validation'
description: 'Pending..'
state: 'pending'
sha: ${{ env.actual_pull_head }}
target_url: https://github.com/Tribler/py-ipv8/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
uses: guibranco/[email protected]
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'Cross-env Validation'
description: 'Failed!'
state: 'failure'
sha: ${{ env.actual_pull_head }}
target_url: https://github.com/Tribler/py-ipv8/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
uses: guibranco/[email protected]
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'Cross-env Validation'
description: 'Success!'
state: 'success'
sha: ${{ env.actual_pull_head }}
target_url: https://github.com/Tribler/py-ipv8/actions/runs/${{ github.run_id }}