-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae9190b
commit ebb2482
Showing
2 changed files
with
47 additions
and
39 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Determine which tests to run | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_call: | ||
outputs: | ||
should_run_query_tests: | ||
description: 'Whether query tests should run' | ||
value: ${{ jobs.check_paths.outputs.should_run_query_tests }} | ||
|
||
env: | ||
QUERY_SERVICE_PATHS: 'weave-js/ weave_query/' | ||
|
||
jobs: | ||
check_paths: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should_run_query_tests: ${{ steps.query_service.outputs.should_run_query_tests }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
ref: ${{ github.head_ref }} | ||
- run: git fetch origin ${{ github.base_ref }} | ||
- id: query_service | ||
run: | | ||
if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
base_sha=$(git rev-parse origin/${{ github.base_ref }}) | ||
head_sha=$(git rev-parse HEAD) | ||
changed_files=$(git diff --name-only $base_sha $head_sha) | ||
else | ||
changed_files=$(git diff --name-only HEAD^) | ||
fi | ||
for path in ${{ env.QUERY_SERVICE_PATHS }}; do | ||
if echo "$changed_files" | grep -q "$path"; then | ||
echo "should_run_query_tests=true" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
done | ||
echo "should_run_query_tests=false" >> $GITHUB_OUTPUT |