Skip to content

Commit

Permalink
Make cloud build for dataform-open-source work for pull requests (dat…
Browse files Browse the repository at this point in the history
…aform-co#1728)

* Update machine type and references to non dataform-open-source

* Disable remote cache

* Temporarily disable tests that require working BQ credentials

* Make CLI test disablement only for run

* Nit tidy
  • Loading branch information
Ekrekr authored May 7, 2024
1 parent f41a19d commit f9c47fc
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 119 deletions.
11 changes: 6 additions & 5 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ build --test_output=errors --action_env="GTEST_COLOR=1"
# TODO: Fix all the underlying issues here.
build --incompatible_py3_is_default=false

# TODO(ekrekr): explore re-enabling these, if open source development is too slow.
# The following flags enable the remote cache so action results can be shared
# across machines, developers, and workspaces.
build:remote-cache --remote_cache=grpcs://remotebuildexecution.googleapis.com
build:remote-cache --remote_instance_name=projects/dataform-corp/instances/dataform-co
build:remote-cache --remote_timeout=3600
build:remote-cache --auth_enabled=true
build:remote-cache --google_default_credentials=true
# build:remote-cache --remote_cache=grpcs://remotebuildexecution.googleapis.com
# build:remote-cache --remote_instance_name=projects/dataform-open-source/instances/dataform-co
# build:remote-cache --remote_timeout=3600
# build:remote-cache --auth_enabled=true
# build:remote-cache --google_default_credentials=true
3 changes: 2 additions & 1 deletion cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ ts_test_suite(
data = [
":node_modules",
"//packages/@dataform/core:package_tar",
"//test_credentials:bigquery.json",
# TODO(ekrekr): re-add these once we have working BQ credentials.
# "//test_credentials:bigquery.json",
"@nodejs//:node",
"@nodejs//:npm",
],
Expand Down
126 changes: 61 additions & 65 deletions cli/index_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,7 @@ defaultAssertionDataset: dataform_assertions

// Initialize a project using the CLI, don't install packages.
await getProcessResult(
execFile(nodePath, [
cliEntryPointPath,
"init",
projectDir,
"dataform-integration-tests",
"US"
])
execFile(nodePath, [cliEntryPointPath, "init", projectDir, "dataform-open-source", "US"])
);

// Install packages manually to get around bazel read-only sandbox issues.
Expand Down Expand Up @@ -219,14 +213,14 @@ select 1 as \${dataform.projectConfig.vars.testVar2}
type: "table",
enumType: "TABLE",
target: {
database: "dataform-integration-tests",
database: "dataform-open-source",
schema: "dataform_test_schema_suffix",
name: "example"
},
canonicalTarget: {
schema: "dataform",
name: "example",
database: "dataform-integration-tests"
database: "dataform-open-source"
},
query: "\n\nselect 1 as testValue2\n",
disabled: false,
Expand All @@ -238,7 +232,7 @@ select 1 as \${dataform.projectConfig.vars.testVar2}
warehouse: "bigquery",
defaultSchema: "dataform",
assertionSchema: "dataform_assertions",
defaultDatabase: "dataform-integration-tests",
defaultDatabase: "dataform-open-source",
defaultLocation: "US",
vars: {
testVar1: "testValue1",
Expand All @@ -250,69 +244,71 @@ select 1 as \${dataform.projectConfig.vars.testVar2}
dataformCoreVersion: version,
targets: [
{
database: "dataform-integration-tests",
database: "dataform-open-source",
schema: "dataform",
name: "example"
}
]
});

// Dry run the project.
const runResult = await getProcessResult(
execFile(nodePath, [
cliEntryPointPath,
"run",
projectDir,
"--credentials",
path.resolve(process.env.RUNFILES, "df/test_credentials/bigquery.json"),
"--dry-run",
"--json",
"--vars=testVar1=testValue1,testVar2=testValue2",
"--default-location=europe",
"--tags=someTag,someOtherTag"
])
);
// TODO(ekrekr): re-enable this part of the test once we have working BQ credentials.

expect(runResult.exitCode).equals(0);
// // Dry run the project.
// const runResult = await getProcessResult(
// execFile(nodePath, [
// cliEntryPointPath,
// "run",
// projectDir,
// "--credentials",
// path.resolve(process.env.RUNFILES, "df/test_credentials/bigquery.json"),
// "--dry-run",
// "--json",
// "--vars=testVar1=testValue1,testVar2=testValue2",
// "--default-location=europe",
// "--tags=someTag,someOtherTag"
// ])
// );

expect(JSON.parse(runResult.stdout)).deep.equals({
actions: [
{
fileName: "definitions/example.sqlx",
hermeticity: "HERMETIC",
tableType: "table",
target: {
database: "dataform-integration-tests",
name: "example",
schema: "dataform"
},
tasks: [
{
statement:
"create or replace table `dataform-integration-tests.dataform.example` as \n\nselect 1 as testValue2",
type: "statement"
}
],
type: "table"
}
],
projectConfig: {
assertionSchema: "dataform_assertions",
defaultDatabase: "dataform-integration-tests",
defaultLocation: "europe",
defaultSchema: "dataform",
warehouse: "bigquery",
vars: {
testVar1: "testValue1",
testVar2: "testValue2"
}
},
runConfig: {
fullRefresh: false,
tags: ["someTag", "someOtherTag"]
},
warehouseState: {}
});
// expect(runResult.exitCode).equals(0);

// expect(JSON.parse(runResult.stdout)).deep.equals({
// actions: [
// {
// fileName: "definitions/example.sqlx",
// hermeticity: "HERMETIC",
// tableType: "table",
// target: {
// database: "dataform-open-source",
// name: "example",
// schema: "dataform"
// },
// tasks: [
// {
// statement:
// "create or replace table `dataform-open-source.dataform.example` as \n\nselect 1 as testValue2",
// type: "statement"
// }
// ],
// type: "table"
// }
// ],
// projectConfig: {
// assertionSchema: "dataform_assertions",
// defaultDatabase: "dataform-open-source",
// defaultLocation: "europe",
// defaultSchema: "dataform",
// warehouse: "bigquery",
// vars: {
// testVar1: "testValue1",
// testVar2: "testValue2"
// }
// },
// runConfig: {
// fullRefresh: false,
// tags: ["someTag", "someOtherTag"]
// },
// warehouseState: {}
// });
});
});

Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ steps:
args:
- ./scripts/run_tests
options:
machineType: N1_HIGHCPU_8
machineType: E2_HIGHCPU_8
timeout: 3600s
2 changes: 1 addition & 1 deletion scripts/create_secret
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
gcloud kms encrypt \
--ciphertext-file=$1.enc \
--plaintext-file=$1 \
--project=dataform-public \
--project=dataform-open-source \
--keyring=dataform-builder-keyring \
--key=dataform-builder-key \
--location=global
2 changes: 1 addition & 1 deletion scripts/decrypt_secret
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
gcloud kms decrypt \
--ciphertext-file=$1.enc \
--plaintext-file=$1 \
--project=dataform-public \
--project=dataform-open-source \
--keyring=dataform-builder-keyring \
--key=dataform-builder-key \
--location=global
2 changes: 1 addition & 1 deletion scripts/run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ 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 --config=remote-cache ... --build_tests_only --test_env=USE_CLOUD_BUILD_NETWORK=true
bazel test ... --build_tests_only --test_env=USE_CLOUD_BUILD_NETWORK=true
2 changes: 1 addition & 1 deletion test_credentials/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gcloud_secret(
name = "bigquery.json",
testonly = 1,
ciphertext_file = ":bigquery.json.enc",
project = "dataform-public",
project = "dataform-open-source",
key = "dataform-builder-key",
keyring = "dataform-builder-keyring",
)
51 changes: 26 additions & 25 deletions tests/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ package(default_visibility = ["//visibility:public"])

load("//testing:index.bzl", "ts_test_suite")

ts_test_suite(
name = "tests",
srcs = [
"utils.ts",
"bigquery.spec.ts",
],
data = [
"//test_credentials:bigquery.json",
"//tests/integration/bigquery_project:files",
"//tests/integration/bigquery_project:node_modules",
],
deps = [
"//cli/api",
"//cli/api/utils",
"//common/promises",
"//core",
"//protos:ts",
"//testing",
"//tests/utils",
"@npm//@types/chai",
"@npm//@types/long",
"@npm//@types/node",
"@npm//chai",
],
)
# TODO(ekrekr): re-enable these tests once we have working BQ credentials.
# ts_test_suite(
# name = "tests",
# srcs = [
# "utils.ts",
# "bigquery.spec.ts",
# ],
# data = [
# "//test_credentials:bigquery.json",
# "//tests/integration/bigquery_project:files",
# "//tests/integration/bigquery_project:node_modules",
# ],
# deps = [
# "//cli/api",
# "//cli/api/utils",
# "//common/promises",
# "//core",
# "//protos:ts",
# "//testing",
# "//tests/utils",
# "@npm//@types/chai",
# "@npm//@types/long",
# "@npm//@types/node",
# "@npm//chai",
# ],
# )
Loading

0 comments on commit f9c47fc

Please sign in to comment.