Skip to content

Commit

Permalink
Merge pull request #767 from roboflow/qol/do-not-run-tests-if-branch-…
Browse files Browse the repository at this point in the history
…not-up-to-date-with-main

Do not run tests if branch is not up to date with main
  • Loading branch information
grzegorz-roboflow authored Nov 5, 2024
2 parents 4656d70 + c85740c commit 894dfac
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/integration_tests_inference_cli_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ on:
workflow_dispatch:

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build-dev-test:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-small
group: public-depot
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/integration_tests_inference_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ on:
workflow_dispatch:

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build-dev-test:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/integration_tests_workflows_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ on:
workflow_dispatch:

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build-dev-test:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-16
group: public-depot
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/is_mergeable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Check if PR is mergeable

on:
workflow_call:
outputs:
mergeable_state:
description: "Set to 'clean' if branch is mergeable, otherwise set to 'not_clean'"
value: ${{ jobs.is_mergeable.outputs.mergeable_state }}

jobs:
is_mergeable:
outputs:
mergeable_state: ${{ steps.mergeable_check.outputs.mergeable_state }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
timeout-minutes: 15
steps:
- name: 🛎️ Checkout main
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
ref: main
- name : Store main sha in context
run: echo "main_sha=$(git rev-parse main)" >> "${GITHUB_ENV}"
- name: Calculate depth
run: echo "FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
- name: 🛎️ Checkout branch with all history
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
ref: ${{ github.event.pull_request.head.sha }}
- name: Check and store mergable state
id: mergeable_check
run: |
echo "Check if main is ancestor of ${{ github.event.pull_request.head.sha }} (branch HEAD)";
if $(git merge-base --is-ancestor ${{ env.main_sha }} ${{ github.event.pull_request.head.sha }}); then
echo "Branch is mergeable";
echo "mergeable_state=clean" >> "$GITHUB_OUTPUT";
else
echo "Branch needs to be updated";
echo "mergeable_state=not_clean" >> "$GITHUB_OUTPUT";
fi
5 changes: 5 additions & 0 deletions .github/workflows/static_code_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ on:
branches: [main]

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build-dev-test:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-small
group: public-depot
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test_package_install_inference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ permissions:
id-token: write

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test_package_install_inference_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ permissions:
id-token: write

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/test_package_install_inference_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ permissions:
id-token: write

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
Expand All @@ -20,6 +25,11 @@ jobs:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: test
env:
- mergeable_state: ${{needs.is_mergeable.outputs.mergeable_state}}
run: |
echo "$mergeable_state"
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🐍 Set up Python 3.9 to create wheels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ permissions:
id-token: write

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test_package_install_inference_sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ permissions:
id-token: write

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ permissions:
id-token: write

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-8
group: public-depot
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/unit_tests_inference_cli_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ on:
workflow_dispatch:

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build-dev-test:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-4
group: public-depot
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/unit_tests_inference_sdk_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ on:
workflow_dispatch:

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build-dev-test:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-4
group: public-depot
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/unit_tests_inference_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ on:
workflow_dispatch:

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build-dev-test:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-4
group: public-depot
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/unit_tests_workflows_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ on:
workflow_dispatch:

jobs:
call_is_mergeable:
uses: ./.github/workflows/is_mergeable.yml
secrets: inherit
build-dev-test:
needs: call_is_mergeable
if: ${{ github.event_name != 'pull_request' || needs.call_is_mergeable.outputs.mergeable_state != 'not_clean' }}
runs-on:
labels: depot-ubuntu-22.04-4
group: public-depot
Expand Down

0 comments on commit 894dfac

Please sign in to comment.