diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index fa019cb9eedab..e516817f70aac 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -46,6 +46,11 @@ on: required: false type: string default: '' + download-artifact-name: + description: Name of an artifact to download into the workspace before running + required: false + type: string + default: '' artifact-name: description: Name of artifact to upload required: false @@ -146,6 +151,12 @@ jobs: path: ${{ inputs.cache-name }} key: ${{ inputs.cache-name }}- restore-keys: ${{ inputs.cache-name }}- + - name: Download artifact + if: inputs.download-artifact-name != '' + uses: actions/download-artifact@v8 + with: + name: ${{ inputs.download-artifact-name }} + continue-on-error: true - name: Set Python version if: inputs.python-version != '' run: echo '${{ inputs.python-version }}' > py/.python-version diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 99e4521671096..805c07e9ba1a8 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -2,10 +2,6 @@ name: CI - Python on: workflow_call: - inputs: - targets: - required: true - type: string workflow_dispatch: permissions: @@ -67,12 +63,16 @@ jobs: name: Integration Tests Remote needs-display: true rerun-with-debug: true + download-artifact-name: targets run: > + [ -s bazel-targets-py.txt ] || echo //py/... > bazel-targets-py.txt; + { echo "tests(//py:test-remote) intersect set("; cat bazel-targets-py.txt; echo ")"; } > query.txt; + bazel query --query_file=query.txt --output=label > remote-targets.txt; ./scripts/github-actions/bazel-test-if-targets.sh --keep_going --flaky_test_attempts 3 --local_test_jobs 1 - $(bazel query "tests(//py:test-remote) intersect set(${{ inputs.targets || '//py/...' }})" --output=label 2>/dev/null) + --target_pattern_file=remote-targets.txt browser-tests: name: Browser Tests @@ -90,13 +90,17 @@ jobs: needs-display: true os: ${{ matrix.os }} rerun-with-debug: true + download-artifact-name: targets run: > + [ -s bazel-targets-py.txt ] || echo //py/... > bazel-targets-py.txt; + { echo "tests(//py:test-${{ matrix.browser }}) intersect set("; cat bazel-targets-py.txt; echo ")"; } > query.txt; + bazel query --query_file=query.txt --output=label > browser-targets.txt; ./scripts/github-actions/bazel-test-if-targets.sh --keep_going --flaky_test_attempts 3 --local_test_jobs 1 --skip_incompatible_explicit_targets - $(bazel query "tests(//py:test-${{ matrix.browser }}) intersect set(${{ inputs.targets || '//py/...' }})" --output=label 2>/dev/null) + --target_pattern_file=browser-targets.txt selenium-manager-tests: name: Selenium Manager Tests @@ -110,7 +114,9 @@ jobs: needs-display: true os: ${{ matrix.os }} rerun-with-debug: true + download-artifact-name: targets run: > + [ -s bazel-targets-py.txt ] || echo //py/... > bazel-targets-py.txt; ./scripts/github-actions/bazel-test-if-targets.sh --local_test_jobs 1 --flaky_test_attempts 3 @@ -118,4 +124,4 @@ jobs: --build_tests_only --skip_incompatible_explicit_targets --test_tag_filters=se-manager - ${{ inputs.targets || '//py/...' }} + --target_pattern_file=bazel-targets-py.txt diff --git a/.github/workflows/ci-ruby.yml b/.github/workflows/ci-ruby.yml index dfb2bed39778f..192de97107386 100644 --- a/.github/workflows/ci-ruby.yml +++ b/.github/workflows/ci-ruby.yml @@ -2,10 +2,6 @@ name: CI - Ruby on: workflow_call: - inputs: - targets: - required: true - type: string workflow_dispatch: inputs: smoke: @@ -66,7 +62,9 @@ jobs: needs-display: true os: ${{ matrix.os }} rerun-with-debug: true + download-artifact-name: targets run: > + [ -s bazel-targets-rb.txt ] || echo //rb/... > bazel-targets-rb.txt; ./scripts/github-actions/bazel-test-if-targets.sh --keep_going --flaky_test_attempts 2 @@ -77,7 +75,7 @@ jobs: --test_env=SE_SKIP_DRIVER_IN_PATH=true --test_env=SKIP_PENDING=true --test_tag_filters=unit,os-sensitive,se-manager,skip-rbe - ${{ inputs.targets || '//rb/...' }} + --target_pattern_file=bazel-targets-rb.txt os-tests-full: name: ${{ matrix.os }}-full diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59f8cca17a3a4..11f1d413e2a34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,8 +66,8 @@ jobs: outputs: java: ${{ steps.read.outputs.java }} grid: ${{ steps.read.outputs.grid }} - py_targets: ${{ steps.read.outputs.py_targets }} - rb_targets: ${{ steps.read.outputs.rb_targets }} + py: ${{ steps.read.outputs.py }} + rb: ${{ steps.read.outputs.rb }} dotnet: ${{ steps.read.outputs.dotnet }} rust: ${{ steps.read.outputs.rust }} steps: @@ -91,9 +91,10 @@ jobs: process_binding() { local pattern=$1 tag=$2 local lang_targets - lang_targets=$(echo "$targets" | tr ' ' '\n' | awk -v p="^${pattern}[:/]" '$0 ~ p' | tr '\n' ' ' | sed 's/ *$//') + lang_targets=$(echo "$targets" | tr ' ' '\n' | awk -v p="^${pattern}[:/]" '$0 ~ p') if [ -n "$lang_targets" ]; then - echo "${tag}_targets=$lang_targets" >> "$GITHUB_OUTPUT" + echo "$tag=true" >> "$GITHUB_OUTPUT" + echo "$lang_targets" > "bazel-targets-${tag}.txt" fi } check_binding "//java" "java" @@ -102,6 +103,12 @@ jobs: check_binding "//rust" "rust" process_binding "//rb" "rb" process_binding "//py" "py" + - name: Upload target files + uses: actions/upload-artifact@v7 + with: + name: targets + path: bazel-targets-*.txt + if-no-files-found: ignore dotnet: name: .NET needs: read-targets @@ -124,17 +131,13 @@ jobs: name: Python needs: read-targets uses: ./.github/workflows/ci-python.yml - if: needs.read-targets.outputs.py_targets != '' - with: - targets: ${{ needs.read-targets.outputs.py_targets }} + if: needs.read-targets.outputs.py != '' ruby: name: Ruby needs: read-targets uses: ./.github/workflows/ci-ruby.yml - if: needs.read-targets.outputs.rb_targets != '' - with: - targets: ${{ needs.read-targets.outputs.rb_targets }} + if: needs.read-targets.outputs.rb != '' rust: name: Rust diff --git a/scripts/github-actions/rerun-failures.sh b/scripts/github-actions/rerun-failures.sh index 28e18078a1dd6..d3eaa38c2afac 100755 --- a/scripts/github-actions/rerun-failures.sh +++ b/scripts/github-actions/rerun-failures.sh @@ -32,14 +32,14 @@ fi if [[ "$RUN_CMD" == *"/ci-build.sh"* ]]; then base_cmd="bazel test --config=rbe-ci --build_tests_only --keep_going" else - # Strip the targets (literal `//...` or a trailing `$(...)` query) to get the base command. - base_cmd=$(echo "$RUN_CMD" | sed -E 's| \$\(.*$||; s| //[^ ]*||g') + # Reduce the run command to its bazel invocation + base_cmd=$(sed -E 's/^.*;[[:space:]]*//; s/ --target_pattern_file=[^[:space:]]+//; s| //[^ ]*||g' <<<"$RUN_CMD") fi -targets=$(tr '\n' ' ' < build/failures/_run1.txt) -echo "Rerunning tests: $base_cmd --test_env=SE_DEBUG=true --flaky_test_attempts=1 $targets" +rerun_cmd="$base_cmd --test_env=SE_DEBUG=true --flaky_test_attempts=1 --target_pattern_file=build/failures/_run1.txt" +echo "Rerunning tests: $rerun_cmd" set +e { - $base_cmd --test_env=SE_DEBUG=true --flaky_test_attempts=1 $targets + $rerun_cmd } 2>&1 | tee build/bazel-console2.log status=$? set -e