From f33f291580d7e1ff87e459be3d03f104049606db Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 20 Nov 2024 16:25:41 -0800 Subject: [PATCH] Consolidate test configs Differential Revision: D66271546 --- .github/workflows/ci.yml | 2 +- .vscode/settings.json | 4 +- scripts/config.tests.js | 104 ++++++++++++++++++++++++++++++++++++++ scripts/config.tests.json | 74 --------------------------- scripts/dev-compiler.sh | 2 +- 5 files changed, 108 insertions(+), 78 deletions(-) create mode 100644 scripts/config.tests.js delete mode 100644 scripts/config.tests.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a162706e4373..d242d9e95ef02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,7 @@ jobs: - name: "Build test project" run: cargo run --manifest-path=compiler/Cargo.toml --bin relay --release ${{ matrix.target.features && '--features' }} ${{ matrix.target.features }} ./compiler/test-project/relay.config.json - name: "Build Relay unit-test artifacts" - run: cargo run --manifest-path=compiler/Cargo.toml --bin relay --release ${{ matrix.target.features && '--features' }} ${{ matrix.target.features }} ./scripts/config.tests.json + run: cargo run --manifest-path=compiler/Cargo.toml --bin relay --release ${{ matrix.target.features && '--features' }} ${{ matrix.target.features }} ./scripts/config.tests.js - name: "Check working directory status" run: './scripts/check-git-status.sh' diff --git a/.vscode/settings.json b/.vscode/settings.json index b35f976fbde47..e1bf2c8623ff7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -20,7 +20,7 @@ // Note that startup will be very slow since it will need to build the // compiler first. - // "relay.pathToConfig": "./scripts/config.tests.json", + // "relay.pathToConfig": "./scripts/config.tests.js", // "relay.pathToRelay": "./scripts/dev-compiler.sh", // "relay.autoStartCompiler": true, -} \ No newline at end of file +} diff --git a/scripts/config.tests.js b/scripts/config.tests.js new file mode 100644 index 0000000000000..8f5109ff1e23d --- /dev/null +++ b/scripts/config.tests.js @@ -0,0 +1,104 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @oncall relay + */ + +'use strict'; + +// Note: This is purposefully not using Flow because the Rust Relay Compiler +// will execute it directly with Node. + +const {join} = require('path'); + +/** + * Due to difference in how files are organized on GitHub and how they are + * organized in Meta's internal repo, this config needs to emit different + * paths depending on the environment. + */ +function makeConfig() { + const IS_OSS = !__dirname.includes('__github__'); + const basePath = IS_OSS ? 'packages' : '../..'; + return { + root: IS_OSS ? '..' : '.', + name: 'tests', + sources: { + '': 'tests', + }, + excludes: ['**/node_modules/**'], + header: [ + 'Copyright (c) Meta Platforms, Inc. and affiliates.', + '', + 'This source code is licensed under the MIT license found in the', + 'LICENSE file in the root directory of this source tree.', + '', + '@oncall relay', + ], + projects: { + tests: { + enumModuleSuffix: null, + schema: join(basePath, 'relay-test-utils-internal/testschema.graphql'), + schemaConfig: { + nonNodeIdFields: { + allowedIdTypes: { + IDFieldTests: 'IDFieldIsID', + NonNode: 'NonNodeID', + }, + }, + deferStreamInterface: { + deferName: 'defer', + streamName: 'stream', + ifArg: 'if', + labelArg: 'label', + initialCountArg: 'initial_count', + useCustomizedBatchArg: 'use_customized_batch', + }, + }, + schemaExtensions: [ + join(basePath, 'relay-test-utils-internal/schema-extensions'), + ], + customScalarTypes: { + OpaqueScalarType: { + name: 'OpaqueScalarType', + path: '../OpaqueScalarType', + }, + }, + jsModuleFormat: 'commonjs', + moduleImportConfig: { + dynamicModuleProvider: { + mode: 'Custom', + statement: "() => require('./.<$module>')", + }, + surface: 'resolvers', + }, + featureFlags: { + no_inline: { + kind: 'enabled', + }, + actor_change_support: { + kind: 'enabled', + }, + relay_resolver_enable_interface_output_type: { + kind: 'enabled', + }, + enable_exec_time_resolvers_directive: true, + }, + language: 'flow', + resolverContextType: { + name: 'TestResolverContextType', + path: join( + basePath, + 'relay-runtime/mutations/__tests__/TestResolverContextType', + ), + }, + }, + }, + isDevVariableName: '__DEV__', + }; +} + +module.exports = makeConfig(); diff --git a/scripts/config.tests.json b/scripts/config.tests.json deleted file mode 100644 index 74a907d034f36..0000000000000 --- a/scripts/config.tests.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "root": "..", - "name": "tests", - "sources": { - "packages": "tests" - }, - "excludes": [ - "**/node_modules/**" - ], - "header": [ - "Copyright (c) Meta Platforms, Inc. and affiliates.", - "", - "This source code is licensed under the MIT license found in the", - "LICENSE file in the root directory of this source tree.", - "", - "@oncall relay" - ], - "projects": { - "tests": { - "enumModuleSuffix": null, - "schema": "packages/relay-test-utils-internal/testschema.graphql", - "schemaExtensions": [ - "packages/relay-test-utils-internal/schema-extensions" - ], - "customScalarTypes": { - "OpaqueScalarType": { - "name": "OpaqueScalarType", - "path": "../OpaqueScalarType" - } - }, - "jsModuleFormat": "commonjs", - "moduleImportConfig": { - "dynamicModuleProvider": { - "mode": "Custom", - "statement": "() => require('./.<$module>')" - }, - "surface": "resolvers" - }, - "schemaConfig": { - "nonNodeIdFields": { - "allowedIdTypes": { - "IDFieldTests": "IDFieldIsID", - "NonNode": "NonNodeID" - } - }, - "deferStreamInterface": { - "deferName": "defer", - "streamName": "stream", - "ifArg": "if", - "labelArg": "label", - "initialCountArg": "initial_count", - "useCustomizedBatchArg": "use_customized_batch" - } - }, - "featureFlags": { - "no_inline": { - "kind": "enabled" - }, - "actor_change_support": { - "kind": "enabled" - }, - "relay_resolver_enable_interface_output_type": { - "kind": "enabled" - } - }, - "language": "flow", - "resolverContextType": { - "name": "TestResolverContextType", - "path": "packages/relay-runtime/mutations/__tests__/TestResolverContextType" - } - } - }, - "isDevVariableName": "__DEV__" -} diff --git a/scripts/dev-compiler.sh b/scripts/dev-compiler.sh index 78f581a3bc16c..57e20c5ddf8b6 100755 --- a/scripts/dev-compiler.sh +++ b/scripts/dev-compiler.sh @@ -8,7 +8,7 @@ # VSCode extension on our test files. An example VSCode project settings.json file: # # { -# "relay.pathToConfig": "./scripts/config.tests.json", +# "relay.pathToConfig": "./scripts/config.tests.js", # "relay.pathToRelay": "./scripts/dev-compiler.sh", # "relay.autoStartCompiler": true # }