Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate test configs #4853

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
104 changes: 104 additions & 0 deletions scripts/config.tests.js
Original file line number Diff line number Diff line change
@@ -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();
74 changes: 0 additions & 74 deletions scripts/config.tests.json

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/dev-compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# }
Expand Down
Loading