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

[Functions] Bump javy #4437

Closed
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 packages/app/src/cli/services/function/binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import fs from 'node:fs'
import * as gzip from 'node:zlib'
import {fileURLToPath} from 'node:url'

const JAVY_VERSION = 'v3.0.1'
const FUNCTION_RUNNER_VERSION = 'v6.2.0'
const JAVY_VERSION = 'v3.1.0'
Copy link
Contributor

@DuncanUszkay1 DuncanUszkay1 Sep 12, 2024

Choose a reason for hiding this comment

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

🤔 it's not clear to me from scanning this file what the upgrade process is here- it seems that as long as there's a javy executable in the bin, this version won't get downloaded when installBinary is called. Is that the intention?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it is: in our previous model, javy would be automatically downloaded making the relationship between javy and cli versions 1:N; in our new model however, such relationship is switched to 1:1. A new CLI version doesn't pre-populate the bin directory, which means that when running the build or run commands for the first time the given javy version will be downloaded.

Copy link
Member Author

Choose a reason for hiding this comment

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

So to answer your question more concretely, there's no automatic upgrade process, a javy version bump is tied to a cli version bump.


// The logic for determining the download URL and what to do with the response stream is _coincidentally_ the same for
// Javy and function-runner for now. Those methods may not continue to have the same logic in the future. If they
Expand Down
16 changes: 9 additions & 7 deletions packages/app/src/cli/services/function/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('runJavy', () => {
await expect(got).resolves.toBeUndefined()
expect(exec).toHaveBeenCalledWith(
javyBinary().path,
['compile', '-d', '-o', joinPath(ourFunction.directory, 'dist/index.wasm'), 'dist/function.js'],
['build', '-C', 'dynamic', '-o', joinPath(ourFunction.directory, 'dist/index.wasm'), 'dist/function.js'],
{
cwd: ourFunction.directory,
stderr: 'inherit',
Expand Down Expand Up @@ -222,18 +222,20 @@ describe('ExportJavyBuilder', () => {

// Then
await expect(got).resolves.toBeUndefined()

expect(exec).toHaveBeenCalledWith(
javyBinary().path,
[
'compile',
'-d',
'build',
'-C',
'dynamic',
'-C',
expect.stringContaining('wit='),
'-C',
'wit-world=shopify-function',
'-o',
joinPath(ourFunction.directory, 'dist/index.wasm'),
'dist/function.js',
'--wit',
expect.stringContaining('javy-world.wit'),
'-n',
'shopify-function',
],
{
cwd: ourFunction.directory,
Expand Down
7 changes: 5 additions & 2 deletions packages/app/src/cli/services/function/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ export async function runJavy(
const javy = javyBinary()
await installBinary(javy)

const args = ['compile', '-d', '-o', fun.outputPath, 'dist/function.js', ...extra]
// Using the `build` command we want to emit:
//
// `javy build -C dynamic -C wit=<path> -C wit-world=val -o <path> <function.js>`
const args = ['build', '-C', 'dynamic', ...extra, '-o', fun.outputPath, 'dist/function.js']

return exec(javy.path, args, {
cwd: fun.directory,
Expand Down Expand Up @@ -242,7 +245,7 @@ export class ExportJavyBuilder implements JavyBuilder {
const witPath = joinPath(dir, 'javy-world.wit')
await writeFile(witPath, witContent)

return runJavy(fun, options, ['--wit', witPath, '-n', JAVY_WORLD])
return runJavy(fun, options, ['-C', `wit=${witPath}`, '-C', `wit-world=${JAVY_WORLD}`])
})
}

Expand Down