Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made PR checks only run when relevant files are changed #2399

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/check-backend-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check Backend Changes

on:
workflow_call:
outputs:
run-tests:
description: "Whether to run tests based on backend changes"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be slightly preferrable to have a name for each job/step in the workflow

value: ${{ jobs.check-run-needed.outputs.run-tests }}

jobs:
check-run-needed:
runs-on: ubuntu-latest
outputs:
run-tests: ${{ steps.check.outputs.run-tests }}
steps:
- uses: actions/checkout@v4
- id: check
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q '^backend/'; then
echo "run-tests=true" >> $GITHUB_OUTPUT
else
echo "run-tests=false" >> $GITHUB_OUTPUT
fi
12 changes: 12 additions & 0 deletions .github/workflows/pr-python-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ on:
branches: [ main ]

jobs:
check-changes:
uses: ./.github/workflows/check-backend-changes.yml

mypy-check:
needs: check-changes
if: needs.check-changes.outputs.run-tests == 'true'
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -47,3 +52,10 @@ jobs:
run: |
cd backend
black --check .

skip-tests:
needs: check-changes
if: needs.check-changes.outputs.run-tests == 'false'
runs-on: ubuntu-latest
steps:
- run: echo "No changes in backend, skipping this test."
12 changes: 12 additions & 0 deletions .github/workflows/pr-python-connector-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ env:
CONFLUENCE_ACCESS_TOKEN: ${{ secrets.CONFLUENCE_ACCESS_TOKEN }}

jobs:
check-changes:
uses: ./.github/workflows/check-backend-changes.yml

connectors-check:
needs: check-changes
if: needs.check-changes.outputs.run-tests == 'true'
runs-on: ubuntu-latest

env:
Expand Down Expand Up @@ -55,3 +60,10 @@ jobs:
-H 'Content-type: application/json' \
--data '{"text":"Scheduled Connector Tests failed! Check the run at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}' \
$SLACK_WEBHOOK

skip-tests:
needs: check-changes
if: needs.check-changes.outputs.run-tests == 'false'
runs-on: ubuntu-latest
steps:
- run: echo "No changes in backend, skipping this test."
13 changes: 13 additions & 0 deletions .github/workflows/pr-python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ on:
branches: [ main ]

jobs:
check-changes:
uses: ./.github/workflows/check-backend-changes.yml

backend-check:
needs: check-changes
if: needs.check-changes.outputs.run-tests == 'true'
runs-on: ubuntu-latest

env:
Expand Down Expand Up @@ -34,3 +39,11 @@ jobs:
- name: Run Tests
shell: script -q -e -c "bash --noprofile --norc -eo pipefail {0}"
run: py.test -o junit_family=xunit2 -xv --ff backend/tests/unit


skip-tests:
needs: check-changes
if: needs.check-changes.outputs.run-tests == 'false'
runs-on: ubuntu-latest
steps:
- run: echo "No changes in backend, skipping this test."
12 changes: 12 additions & 0 deletions .github/workflows/run-it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

jobs:
check-changes:
uses: ./.github/workflows/check-backend-changes.yml

integration-tests:
needs: check-changes
if: needs.check-changes.outputs.run-tests == 'true'
runs-on:
group: 'arm64-image-builders'
steps:
Expand Down Expand Up @@ -158,3 +163,10 @@ jobs:
run: |
cd deployment/docker_compose
docker compose -f docker-compose.dev.yml -p danswer-stack down -v

skip-tests:
needs: check-changes
if: needs.check-changes.outputs.run-tests == 'false'
runs-on: ubuntu-latest
steps:
- run: echo "No changes in backend, skipping this test."
Loading