From 724b92add0b7a2d320447a8ac54c2c3193246abd Mon Sep 17 00:00:00 2001 From: Mikhail Kumachev Date: Mon, 27 Jan 2025 13:10:41 +0100 Subject: [PATCH] Split unit and integration tests (#1900) Split unit and integration tests. At the moment external contributors can't run integration tests because they have no access to the GCP project used for tests. Split allows to run integration tests only on PR. --- .github/workflows/test.yaml | 8 +++++++- scripts/run_integration_tests | 12 ++++++++++++ scripts/run_tests | 6 ++++-- scripts/run_tests_on_cloudbuild | 4 ++++ tests/api/BUILD | 1 + tests/integration/BUILD | 7 ++++--- 6 files changed, 32 insertions(+), 6 deletions(-) create mode 100755 scripts/run_integration_tests diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cf73d9c2d..2af6b101e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,8 +11,14 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Run tests + - name: Run unit tests uses: gcr.io/cloud-builders/bazel:5.4.0 entrypoint: bash with: args: ./scripts/run_tests + + - name: Run integration tests + uses: gcr.io/cloud-builders/bazel:5.4.0 + entrypoint: bash + with: + args: ./scripts/run_integration_tests diff --git a/scripts/run_integration_tests b/scripts/run_integration_tests new file mode 100755 index 000000000..21a743db3 --- /dev/null +++ b/scripts/run_integration_tests @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +# Run tslint. +bazel run @nodejs//:yarn +bazel build @npm//tslint/bin:tslint && bazel-bin/external/npm/tslint/bin/tslint.sh --project . + +# Run integration tests +bazel test ... \ + --test_tag_filters=integration \ + --build_tests_only \ + --test_env=USE_CLOUD_BUILD_NETWORK=true diff --git a/scripts/run_tests b/scripts/run_tests index f6e9093a9..ac55b4259 100755 --- a/scripts/run_tests +++ b/scripts/run_tests @@ -5,5 +5,7 @@ set -e bazel run @nodejs//:yarn bazel build @npm//tslint/bin:tslint && bazel-bin/external/npm/tslint/bin/tslint.sh --project . -# Run all the tests -bazel test ... --build_tests_only --test_env=USE_CLOUD_BUILD_NETWORK=true +# Run unit tests +bazel test ... \ + --test_tag_filters=-integration \ + --build_tests_only diff --git a/scripts/run_tests_on_cloudbuild b/scripts/run_tests_on_cloudbuild index bbeaf0fec..23d66b609 100755 --- a/scripts/run_tests_on_cloudbuild +++ b/scripts/run_tests_on_cloudbuild @@ -4,4 +4,8 @@ set -e bazel run @nodejs//:yarn config set registry https://us-npm.pkg.dev/artifact-foundry-prod/npm-3p-trusted/ bazel run @nodejs//:npm install +# Run unit tests ./scripts/run_tests + +# Run integration tests +./scripts/run_integration_tests diff --git a/tests/api/BUILD b/tests/api/BUILD index f4930de50..79b72c30b 100644 --- a/tests/api/BUILD +++ b/tests/api/BUILD @@ -11,6 +11,7 @@ ts_test_suite( "//tests/api/projects/never_finishes_compiling:files", "//tests/api/projects/never_finishes_compiling:node_modules", ], + tags = ["integration"], deps = [ "//cli/api", "//cli/api/utils", diff --git a/tests/integration/BUILD b/tests/integration/BUILD index 60eec58e2..5f1ee674c 100644 --- a/tests/integration/BUILD +++ b/tests/integration/BUILD @@ -1,18 +1,19 @@ -package(default_visibility = ["//visibility:public"]) - load("//testing:index.bzl", "ts_test_suite") +package(default_visibility = ["//visibility:public"]) + ts_test_suite( name = "tests", srcs = [ - "utils.ts", "bigquery.spec.ts", + "utils.ts", ], data = [ "//test_credentials:bigquery.json", "//tests/integration/bigquery_project:files", "//tests/integration/bigquery_project:node_modules", ], + tags = ["integration"], deps = [ "//cli/api", "//cli/api/utils",