Skip to content

Commit

Permalink
feat: add buildbot_zisi_trace_nft feature flag (#3765)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas authored Oct 26, 2021
1 parent 88c2e87 commit f2ea534
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
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
1 change: 1 addition & 0 deletions packages/build/src/plugins_core/functions/feature_flags.js
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

0 comments on commit f2ea534

Please sign in to comment.