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 diff --git a/scripts/run_all_tests.sh b/scripts/run_all_tests.sh index e26095b..afc8e55 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' @@ -21,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(){ @@ -48,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 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'