Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Sep 30, 2024
1 parent ae9190b commit ebb2482
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 39 deletions.
44 changes: 5 additions & 39 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,18 @@ name: test

on:
push:
workflow_call:
outputs:
should_run_core_integration_tests:
description: 'Whether core integration 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.WATCHED_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
determine_tests:
uses: ./github/workflows/which-tests-to-run.yaml

# ==== Query Service Jobs ====
build-container-query-service:
name: Build Legacy (Query Service) test container
timeout-minutes: 30
runs-on: [self-hosted, builder]
needs: check_paths
if: ${{ needs.check_paths.outputs.should_run_query_tests == 'true' }}
if: ${{ needs.determine_tests.outputs.should_run_query_tests == 'true' }}

# runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -134,7 +100,7 @@ jobs:
needs:
- test-query-service
- check_paths
if: ${{ needs.check_paths.outputs.should_run_query_tests == 'true' }}
if: ${{ needs.determine_tests.outputs.should_run_query_tests == 'true' }}

runs-on: ubuntu-latest

Expand All @@ -149,7 +115,7 @@ jobs:
name: WeaveJS Lint and Compile
runs-on: ubuntu-latest
needs: check_paths
if: ${{ needs.check_paths.outputs.should_run_query_tests == 'true' }}
if: ${{ needs.determine_tests.outputs.should_run_query_tests == 'true' }}
# runs-on: [self-hosted, gke-runner]
steps:
- uses: actions/checkout@v2
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/which-tests-to-run.yaml
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

0 comments on commit ebb2482

Please sign in to comment.