From 878df68f06e15a58471867abc78ae76b70d884d6 Mon Sep 17 00:00:00 2001 From: Andrew Truong Date: Tue, 1 Oct 2024 14:48:32 -0400 Subject: [PATCH] test --- .../workflows/check-which-tests-to-run.yaml | 46 +++++++++++++++++++ .github/workflows/notify-wandb-core.yaml | 6 +-- 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/check-which-tests-to-run.yaml diff --git a/.github/workflows/check-which-tests-to-run.yaml b/.github/workflows/check-which-tests-to-run.yaml new file mode 100644 index 000000000000..36c39e5ffa78 --- /dev/null +++ b/.github/workflows/check-which-tests-to-run.yaml @@ -0,0 +1,46 @@ +name: Check which tests to run + +env: + WEAVE_QUERY_PATHS: 'weave_query/' + CORE_INTEGRATION_PATHS: 'weave-js/ weave_query/' + # Everything else is implicitly trace server + +jobs: + check: + runs-on: ubuntu-latest + outputs: + weave_query_tests: ${{ steps.weave_query.outputs.run_tests }} + core_integration_tests: ${{ steps.core_integration.outputs.run_tests }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true + ref: ${{ github.head_ref }} + - run: git fetch origin ${{ github.base_ref }} + - 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 + - id: weave_query + run: | + for path in ${{ env.WEAVE_QUERY_PATHS }}; do + if echo "$changed_files" | grep -q "$path"; then + echo "run_tests=true" >> $GITHUB_OUTPUT + exit 0 + fi + done + echo "run_tests=false" >> $GITHUB_OUTPUT + - id: core_integration + run: | + for path in ${{ env.CORE_INTEGRATION_PATHS }}; do + if echo "$changed_files" | grep -q "$path"; then + echo "run_tests=true" >> $GITHUB_OUTPUT + exit 0 + fi + done + echo "run_tests=false" >> $GITHUB_OUTPUT diff --git a/.github/workflows/notify-wandb-core.yaml b/.github/workflows/notify-wandb-core.yaml index 2050979ca857..3d126acb6a17 100644 --- a/.github/workflows/notify-wandb-core.yaml +++ b/.github/workflows/notify-wandb-core.yaml @@ -17,17 +17,17 @@ on: jobs: notify-wandb-core: + needs: check-which-tests-to-run runs-on: ubuntu-latest steps: - name: Print payload run: | echo "Sending payload:" - echo '{"ref_name": "${{ github.ref_name }}", "sha": "${{ github.sha }}", "run_core_integration_tests": ${{ github.event.inputs.run_core_integration_tests || false }}}' - + echo '{"ref_name": "${{ github.ref_name }}", "sha": "${{ github.sha }}", "run_core_integration_tests": ${{ needs.check-which-tests-to-run.outputs.core_integration_tests }}}' - name: Repository dispatch uses: peter-evans/repository-dispatch@v2 with: token: ${{ secrets.WANDB_CORE_ACCESS_TOKEN }} repository: wandb/core event-type: weave-package-updated - client-payload: '{"ref_name": "${{ github.ref_name }}", "sha": "${{ github.sha }}", "run_core_integration_tests": ${{ github.event.inputs.run_core_integration_tests || false }}}' + client-payload: '{"ref_name": "${{ github.ref_name }}", "sha": "${{ github.sha }}", "run_core_integration_tests": ${{ needs.check-which-tests-to-run.outputs.core_integration_tests }}}'