Skip to content

Commit

Permalink
fix: drop runtimeVersion override for go functions (#1676)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Dec 1, 2023
1 parent be424b2 commit f146798
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/feature_flags.ts
Expand Up @@ -26,6 +26,9 @@ export const defaultFlags = {

// If multiple glob stars are in includedFiles, fail the build instead of warning.
zisi_esbuild_fail_double_glob: false,

// drops the "runtimeVersion" override field
zisi_go_drop_runtime_override: false,
} as const

export type FeatureFlags = Partial<Record<keyof typeof defaultFlags, boolean>>
Expand Down
3 changes: 2 additions & 1 deletion src/runtimes/go/index.ts
Expand Up @@ -113,6 +113,7 @@ const zipFunction: ZipFunction = async function ({
srcPath,
stat,
isInternal,
featureFlags,
}) {
const destPath = join(destFolder, filename)
const isSource = extname(mainFile) === '.go'
Expand All @@ -137,7 +138,7 @@ const zipFunction: ZipFunction = async function ({
config,
displayName: config?.name,
generator: config?.generator || getInternalValue(isInternal),
runtimeVersion: 'provided.al2',
runtimeVersion: featureFlags.zisi_go_drop_runtime_override ? undefined : 'provided.al2',
}

// If `zipGo` is enabled, we create a zip archive with the Go binary and the
Expand Down
5 changes: 4 additions & 1 deletion tests/main.test.ts
Expand Up @@ -1791,6 +1791,9 @@ describe('zip-it-and-ship-it', () => {
zipGo: true,
},
},
featureFlags: {
zisi_go_drop_runtime_override: true,
},
},
})
const binaryPath = join(FIXTURES_DIR, fixtureName, 'test')
Expand All @@ -1803,7 +1806,7 @@ describe('zip-it-and-ship-it', () => {

const manifest = JSON.parse(await readFile(manifestPath, 'utf-8'))

expect(manifest.functions[0].runtimeVersion).toEqual('provided.al2')
expect(manifest.functions[0].runtimeVersion).toBeUndefined()

const unzippedFunctions = await unzipFiles([func])
const unzippedBinaryPath = join(unzippedFunctions[0].unzipPath, 'bootstrap')
Expand Down

1 comment on commit f146798

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱ Benchmark results

  • largeDepsEsbuild: 1.4s
  • largeDepsNft: 5.5s
  • largeDepsZisi: 10.4s

Please sign in to comment.