From 1757b5aaee6fb5f9998c40431c100fc596533fd8 Mon Sep 17 00:00:00 2001 From: "jan.nowotsch" Date: Fri, 12 Dec 2025 11:05:48 +0100 Subject: [PATCH 1/3] [shell] fix shebang Make the shebang the first line of run_all_tests, which actually makes it to have an effect. Before the shebang was moved to after the copyright header by the S-Core copyright header check. Since that check has been fixed to accept something else than the copyright header at the top of the file, the shebang can be moved to the correct place. --- scripts/run_all_tests.sh | 3 ++- test/run_all_tests.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/run_all_tests.sh b/scripts/run_all_tests.sh index e26095b..6ab0eb8 100755 --- a/scripts/run_all_tests.sh +++ b/scripts/run_all_tests.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # ******************************************************************************* # Copyright (c) 2025 Contributors to the Eclipse Foundation # @@ -10,7 +11,7 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -#!/usr/bin/env bash + set -u GREEN='\033[0;32m' diff --git a/test/run_all_tests.sh b/test/run_all_tests.sh index 9379b26..75082b0 100755 --- a/test/run_all_tests.sh +++ b/test/run_all_tests.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # ******************************************************************************* # Copyright (c) 2025 Contributors to the Eclipse Foundation # @@ -10,7 +11,7 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -#!/usr/bin/env bash + set -u GREEN='\033[0;32m' From 7dab254bdd969ade2a66b452d8984467f29beb87 Mon Sep 17 00:00:00 2001 From: "jan.nowotsch" Date: Fri, 12 Dec 2025 11:11:56 +0100 Subject: [PATCH 2/3] [tests] add workspace modes Extend run_all_tests to support an optional argument that allows to select which tests to run, either all, only tests in the main workspace or only tests in the test workspace. This shall help to reduce the CI resource usage. In particular the amount of disk storage needed, if only either of the test workspaces is executed on a separate CI node. --- scripts/run_all_tests.sh | 99 +++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/scripts/run_all_tests.sh b/scripts/run_all_tests.sh index 6ab0eb8..afc8e55 100755 --- a/scripts/run_all_tests.sh +++ b/scripts/run_all_tests.sh @@ -22,6 +22,7 @@ RESET='\033[0m' declare -A command_status declare -a command_order exit_code=0 +[ $# -gt 0 ] && workspace=$1 || workspace="all" interrupt_handler(){ @@ -49,51 +50,57 @@ run_command(){ command_order+=("$name") } -# Run bazel test with workspace mode and python 3.9. -# TODO re-enable once the score targets (like //:docs) support bazel workspace mode and more than python 3.12 -# run_command "bazel --output_base=$HOME/.cache/bazel_tools_python/workspace_output_base test --config=use_workspace_mode --config=python_3_9 //..." "tests (workspace mode and python 3.9)" - -# Run bazel test with bzlmod mode and python 3.12. -run_command "bazel --output_base=$HOME/.cache/bazel_tools_python/python_3_12_output_base test --config=python_3_12 //..." "tests (bzlmod mode and python 3.12)" - -# Run bazel test with bzlmod mode. -run_command "bazel test //..." "tests (bzlmod mode)" - -# Run python quality tools. -run_command "bazel build --config=ruff_check --keep_going //..." "ruff_check" -run_command "bazel build --config=ruff_format --keep_going //..." "ruff_format" -run_command "bazel build --config=pylint --keep_going //..." "pylint" -run_command "bazel build --config=black --keep_going //..." "black" -run_command "bazel build --config=isort --keep_going //..." "isort" -run_command "bazel build --config=mypy --keep_going //..." "mypy" - -# Run test workspace tests. -run_command "test/run_all_tests.sh" "tests (in test workspace)" - -# Run buildifier. -run_command "bazel run bazel/buildifier:check" "buildifier" - -# Run Eclipse-specific checks. -run_command "bazel run //:copyright.check -- --fix" "eclipse copyright check" -run_command "bazel test //:format.check" "eclipse format check" - -# Run security vulnerability scan. -run_command "third_party/pip/check_vulnerabilities.sh" "security scan" - -# Print execution summary -printf '%-37s | %-10s\n' "Command Name" "Status" -printf '%-37s | %-10s\n' "-------------------------------------" "----------" - -for name in "${command_order[@]}"; do - status="${command_status[$name]}" - - if [[ "$status" == "SUCCEEDED" ]]; then - printf "%-37s | ${GREEN}%-10s${RESET}\n" "$name" "$status" - else - printf "%-37s | ${RED}%-10s${RESET}\n" "$name" "$status" - fi -done - -printf '%-37s | %-10s\n' "-------------------------------------" "----------" +if [ "${workspace}" == "all" -o "${workspace}" == "main" ];then + # Run bazel test with workspace mode and python 3.9. + # TODO re-enable once the score targets (like //:docs) support bazel workspace mode and more than python 3.12 + # run_command "bazel --output_base=$HOME/.cache/bazel_tools_python/workspace_output_base test --config=use_workspace_mode --config=python_3_9 //..." "tests (workspace mode and python 3.9)" + + # Run bazel test with bzlmod mode and python 3.12. + run_command "bazel --output_base=$HOME/.cache/bazel_tools_python/python_3_12_output_base test --config=python_3_12 //..." "tests (bzlmod mode and python 3.12)" + + # Run bazel test with bzlmod mode. + run_command "bazel test //..." "tests (bzlmod mode)" + + # Run python quality tools. + run_command "bazel build --config=ruff_check --keep_going //..." "ruff_check" + run_command "bazel build --config=ruff_format --keep_going //..." "ruff_format" + run_command "bazel build --config=pylint --keep_going //..." "pylint" + run_command "bazel build --config=black --keep_going //..." "black" + run_command "bazel build --config=isort --keep_going //..." "isort" + run_command "bazel build --config=mypy --keep_going //..." "mypy" + + # Run buildifier. + run_command "bazel run bazel/buildifier:check" "buildifier" + + # Run Eclipse-specific checks. + run_command "bazel run //:copyright.check -- --fix" "eclipse copyright check" + run_command "bazel test //:format.check" "eclipse format check" + + # Run security vulnerability scan. + run_command "third_party/pip/check_vulnerabilities.sh" "security scan" +fi + +if [ "${workspace}" == "all" -o "${workspace}" == "test" ];then + # Run test workspace tests. + run_command "test/run_all_tests.sh" "tests (in test workspace)" +fi + +if [ "${workspace}" == "all" -o "${workspace}" == "main" ];then + # Print execution summary + printf '%-37s | %-10s\n' "Command Name" "Status" + printf '%-37s | %-10s\n' "-------------------------------------" "----------" + + for name in "${command_order[@]}"; do + status="${command_status[$name]}" + + if [[ "$status" == "SUCCEEDED" ]]; then + printf "%-37s | ${GREEN}%-10s${RESET}\n" "$name" "$status" + else + printf "%-37s | ${RED}%-10s${RESET}\n" "$name" "$status" + fi + done + + printf '%-37s | %-10s\n' "-------------------------------------" "----------" +fi exit $exit_code From 767e77eeb4ca399fef5b73a4e5cbd090b1473fba Mon Sep 17 00:00:00 2001 From: "jan.nowotsch" Date: Fri, 12 Dec 2025 11:12:14 +0100 Subject: [PATCH 3/3] [ci] Add github test actions Add github actions to run tests in the main and test workspace. --- .github/workflows/tests-main-workspace.yaml | 25 +++++++++++++++++++++ .github/workflows/tests-test-workspace.yaml | 25 +++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/tests-main-workspace.yaml create mode 100644 .github/workflows/tests-test-workspace.yaml diff --git a/.github/workflows/tests-main-workspace.yaml b/.github/workflows/tests-main-workspace.yaml new file mode 100644 index 0000000..9673c3b --- /dev/null +++ b/.github/workflows/tests-main-workspace.yaml @@ -0,0 +1,25 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +name: Run all tests of the main workspace +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + run-all-tests: + name: run main workspace tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: bazelbuild/setup-bazelisk@v3 + - run: ./scripts/run_all_tests.sh main diff --git a/.github/workflows/tests-test-workspace.yaml b/.github/workflows/tests-test-workspace.yaml new file mode 100644 index 0000000..1b3d88d --- /dev/null +++ b/.github/workflows/tests-test-workspace.yaml @@ -0,0 +1,25 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + +name: Run tests in test workspace +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + run-all-tests: + name: run test workspace tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: bazelbuild/setup-bazelisk@v3 + - run: ./scripts/run_all_tests.sh test