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

feat: add buildbot_zisi_trace_nft feature flag #3765

Merged
merged 1 commit into from
Oct 26, 2021
Merged
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
1 change: 1 addition & 0 deletions packages/build/src/core/feature_flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const getFeatureFlag = function (name) {
const DEFAULT_FEATURE_FLAGS = {
buildbot_build_go_functions: false,
buildbot_es_modules_esbuild: false,
buildbot_zisi_trace_nft: false,
buildbot_zisi_esbuild_parser: false,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const getZisiFeatureFlags = (featureFlags) => ({
buildGoSource: featureFlags.buildbot_build_go_functions,
defaultEsModulesToEsbuild: featureFlags.buildbot_es_modules_esbuild,
parseWithEsbuild: featureFlags.buildbot_zisi_esbuild_parser,
traceWithNft: featureFlags.buildbot_zisi_trace_nft,
})

module.exports = { getZisiFeatureFlags }
60 changes: 29 additions & 31 deletions packages/build/tests/core/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,58 +334,56 @@ test.serial(`Doesn't fail build for ES module function if feature flag is off`,
t.false(callArgs[2].featureFlags.defaultEsModulesToEsbuild)
})

test.serial('Passes `parseWithEsbuild` feature flag to zip-it-and-ship-it', async (t) => {
test.serial('Passes the right base path properties to zip-it-and-ship-it', async (t) => {
const mockZipFunctions = sinon.stub().resolves()
const stub = sinon.stub(zipItAndShipIt, 'zipFunctions').get(() => mockZipFunctions)
const fixtureName = 'core'
const fixtureDir = join(FIXTURES_DIR, fixtureName)

await runFixture(t, 'core', { snapshot: false })
await runFixture(t, 'core', {
flags: { featureFlags: { buildbot_zisi_esbuild_parser: true } },
snapshot: false,
})
await runFixture(t, fixtureName, { snapshot: false })

stub.restore()

t.is(mockZipFunctions.callCount, 2)
t.false(mockZipFunctions.firstCall.args[2].featureFlags.parseWithEsbuild)
t.true(mockZipFunctions.secondCall.args[2].featureFlags.parseWithEsbuild)
t.is(mockZipFunctions.callCount, 1)

// eslint-disable-next-line prefer-destructuring
const { basePath, config, repositoryRoot } = mockZipFunctions.firstCall.args[2]

t.is(basePath, fixtureDir)
t.is(config['*'].includedFilesBasePath, fixtureDir)
t.is(repositoryRoot, fixtureDir)
})

test.serial('Passes `buildGoSource` feature flag to zip-it-and-ship-it', async (t) => {
test.serial('Passes the right feature flags to zip-it-and-ship-it', async (t) => {
const mockZipFunctions = sinon.stub().resolves()
const stub = sinon.stub(zipItAndShipIt, 'zipFunctions').get(() => mockZipFunctions)

await runFixture(t, 'core', { snapshot: false })
await runFixture(t, 'core', {
flags: { featureFlags: { buildbot_zisi_trace_nft: true } },
snapshot: false,
})
await runFixture(t, 'core', {
flags: { featureFlags: { buildbot_build_go_functions: true } },
snapshot: false,
})
await runFixture(t, 'core', {
flags: { featureFlags: { buildbot_zisi_esbuild_parser: true } },
snapshot: false,
})

stub.restore()

t.is(mockZipFunctions.callCount, 2)
t.false(mockZipFunctions.firstCall.args[2].featureFlags.buildGoSource)
t.true(mockZipFunctions.secondCall.args[2].featureFlags.buildGoSource)
})

test.serial('Passes the right base path properties to zip-it-and-ship-it', async (t) => {
const mockZipFunctions = sinon.stub().resolves()
const stub = sinon.stub(zipItAndShipIt, 'zipFunctions').get(() => mockZipFunctions)
const fixtureName = 'core'
const fixtureDir = join(FIXTURES_DIR, fixtureName)

await runFixture(t, fixtureName, { snapshot: false })

stub.restore()

t.is(mockZipFunctions.callCount, 1)
// eslint-disable-next-line no-magic-numbers
t.is(mockZipFunctions.callCount, 4)

// eslint-disable-next-line prefer-destructuring
const { basePath, config, repositoryRoot } = mockZipFunctions.firstCall.args[2]
t.false(mockZipFunctions.getCall(0).args[2].featureFlags.traceWithNft)
t.false(mockZipFunctions.getCall(0).args[2].featureFlags.buildGoSource)
t.false(mockZipFunctions.getCall(0).args[2].featureFlags.parseWithEsbuild)

t.is(basePath, fixtureDir)
t.is(config['*'].includedFilesBasePath, fixtureDir)
t.is(repositoryRoot, fixtureDir)
t.true(mockZipFunctions.getCall(1).args[2].featureFlags.traceWithNft)
t.true(mockZipFunctions.getCall(2).args[2].featureFlags.buildGoSource)
t.true(mockZipFunctions.getCall(3).args[2].featureFlags.parseWithEsbuild)
})

test('Print warning on lingering processes', async (t) => {
Expand Down