Skip to content

Commit

Permalink
feat: pass additional feature flags to zip-it-and-ship-it (#3925)
Browse files Browse the repository at this point in the history
* feat: pass `parseISC` flag to zip-it-and-ship-it

* refactor: pass all feature flags to ZISI

* chore: disable no-magic-numbers ESLint rule for tests

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
eduardoboucas and kodiakhq[bot] authored Dec 6, 2021
1 parent 6a52ead commit 96ff2a8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,11 @@ module.exports = {
'node/no-extraneous-import': 0,
},
},
{
files: ['packages/*/tests/**/*.js'],
rules: {
'no-magic-numbers': 'off',
},
},
],
}
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 @@ -20,6 +20,7 @@ const DEFAULT_FEATURE_FLAGS = {
buildbot_zisi_trace_nft: false,
buildbot_zisi_esbuild_parser: false,
buildbot_scheduled_functions: false,
zisi_parse_isc: false,
}

module.exports = { normalizeCliFeatureFlags, DEFAULT_FEATURE_FLAGS }
2 changes: 2 additions & 0 deletions packages/build/src/plugins_core/functions/feature_flags.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use strict'

const getZisiFeatureFlags = (featureFlags) => ({
...featureFlags,
buildGoSource: featureFlags.buildbot_build_go_functions,
defaultEsModulesToEsbuild: featureFlags.buildbot_es_modules_esbuild,
nftTranspile: featureFlags.buildbot_nft_transpile_esm || featureFlags.buildbot_zisi_trace_nft,
parseISC: featureFlags.zisi_parse_isc,
parseWithEsbuild: featureFlags.buildbot_zisi_esbuild_parser,
traceWithNft: featureFlags.buildbot_zisi_trace_nft,
})
Expand Down
25 changes: 17 additions & 8 deletions packages/build/tests/core/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ const getNodeBinary = async function (nodeVersion, retries = 1) {
const MAX_RETRIES = 10

// Memoize `get-node`
// eslint-disable-next-line no-magic-numbers
const mGetNode = moize(getNodeBinary, { isPromise: true, maxSize: 1e3 })

test('--node-path is used by build.command', async (t) => {
Expand Down Expand Up @@ -380,27 +379,37 @@ test.serial('Passes the right feature flags to zip-it-and-ship-it', async (t) =>
flags: { featureFlags: { buildbot_nft_transpile_esm: true } },
snapshot: false,
})
await runFixture(t, 'schedule', {
flags: { featureFlags: { zisi_parse_isc: true } },
snapshot: false,
})
await runFixture(t, 'schedule', {
flags: { featureFlags: { this_is_a_mock_flag: true, and_another_one: true } },
snapshot: false,
})

stub.restore()

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

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(mockZipFunctions.getCall(0).args[2].config.test.schedule, undefined)
t.false(mockZipFunctions.getCall(0).args[2].featureFlags.nftTranspile)
t.false(mockZipFunctions.getCall(0).args[2].featureFlags.parseISC)
t.is(mockZipFunctions.getCall(0).args[2].featureFlags.this_is_a_mock_flag, undefined)
t.is(mockZipFunctions.getCall(0).args[2].featureFlags.and_another_one, undefined)

t.true(mockZipFunctions.getCall(1).args[2].featureFlags.traceWithNft)
t.true(mockZipFunctions.getCall(1).args[2].featureFlags.nftTranspile)
t.true(mockZipFunctions.getCall(2).args[2].featureFlags.buildGoSource)
t.true(mockZipFunctions.getCall(3).args[2].featureFlags.parseWithEsbuild)
// eslint-disable-next-line no-magic-numbers
t.true(mockZipFunctions.getCall(5).args[2].featureFlags.nftTranspile)

t.is(mockZipFunctions.getCall(0).args[2].config.test.schedule, undefined)
// eslint-disable-next-line no-magic-numbers
t.is(mockZipFunctions.getCall(4).args[2].config.test.schedule, '@daily')
t.true(mockZipFunctions.getCall(5).args[2].featureFlags.nftTranspile)
t.true(mockZipFunctions.getCall(6).args[2].featureFlags.parseISC)
t.true(mockZipFunctions.getCall(7).args[2].featureFlags.this_is_a_mock_flag)
t.true(mockZipFunctions.getCall(7).args[2].featureFlags.and_another_one)
})

test('Print warning on lingering processes', async (t) => {
Expand Down
1 change: 0 additions & 1 deletion packages/build/tests/telemetry/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ test('Telemetry calls timeout by default', async (t) => {
// We want to rely on the default timeout value
disableTelemetryTimeout: false,
// Introduce an arbitrary large timeout on the server side so that we can validate the client timeout works
// eslint-disable-next-line no-magic-numbers
waitTelemetryServer: 5 * 60 * 1000,
// The error monitor snapshot should contain the timeout error
snapshot: true,
Expand Down

0 comments on commit 96ff2a8

Please sign in to comment.