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: bundle sqlc binaries in ftl release binary #3933

Closed
wants to merge 3 commits into from
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
run: just test-frontend
test-wasm:
name: Test sqlc-gen-ftl
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -110,7 +110,7 @@ jobs:
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Test WASM
run: cd sqlc-gen-ftl && cargo test --features ci --test sqlc_gen_ftl_test -- --nocapture
run: just test-sqlc-gen-ftl
- name: Check for uncommitted changes
run: |
if [[ -n $(git status -s) ]]; then
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,25 @@ jobs:
docker tag "ftl0/ftl-${image}:latest" "ftl0/ftl-${image}:${version}"
docker push -a "ftl0/ftl-${image}"
done
build-wasm-plugin:
name: Build WASM Plugin and Download SQLC Binaries
runs-on: macos-latest # Must be macos to sign the Darwin SQLC binaries
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Init Hermit
uses: cashapp/[email protected]
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Build WASM Plugin
run: |
just build-sqlc-gen-ftl
create-go-release:
name: Release Go Binaries
runs-on: ubuntu-latest
needs: [build-wasm-plugin]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
15 changes: 11 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ZIP_DIRS := "go-runtime/compile/build-template " + \
CONSOLE_ROOT := "frontend/console"
FRONTEND_OUT := CONSOLE_ROOT + "/dist/index.html"
EXTENSION_OUT := "frontend/vscode/dist/extension.js"
SQLC_GEN_FTL_OUT := "sqlc-gen-ftl/target/wasm32-wasip1/release/sqlc-gen-ftl.wasm"
SQLC_GEN_FTL_OUT := "internal/sqlc/resources/sqlc-gen-ftl.wasm"
PROTOS_IN := "common/protos backend/protos"
PROTOS_OUT := "backend/protos/xyz/block/ftl/console/v1/console.pb.go " + \
"backend/protos/xyz/block/ftl//v1/ftl.pb.go " + \
Expand Down Expand Up @@ -194,10 +194,17 @@ build-extension: pnpm-install
@mk {{EXTENSION_OUT}} : frontend/vscode/src frontend/vscode/package.json -- "cd frontend/vscode && rm -f ftl-*.vsix && pnpm run compile"

# Build the sqlc-ftl-gen plugin, used to generate FTL schema from SQL
build-sqlc-gen-ftl: build-rust-protos
build-sqlc-gen-ftl: build-rust-protos download-sqlc
@mk {{SQLC_GEN_FTL_OUT}} : sqlc-gen-ftl/src -- \
"cd sqlc-gen-ftl && \
cargo build --target wasm32-wasip1 --release"
"cargo build --manifest-path sqlc-gen-ftl/Cargo.toml --target wasm32-wasip1 --release && \
cp sqlc-gen-ftl/target/wasm32-wasip1/release/sqlc-gen-ftl.wasm internal/sqlc/resources"

test-sqlc-gen-ftl:
@cargo test --manifest-path sqlc-gen-ftl/Cargo.toml --features ci --test sqlc_gen_ftl_test -- --nocapture

# Download SQLC binaries, embedded in the FTL binary as resources
download-sqlc:
@bash scripts/provide-sqlc-resources

# Generate Rust protos
build-rust-protos:
Expand Down
174 changes: 174 additions & 0 deletions backend/protos/src/protos/xyz.block.ftl.console.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
// @generated
// This file is @generated by prost-build.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Config {
#[prost(message, optional, tag="1")]
pub config: ::core::option::Option<super::super::schema::v1::Config>,
#[prost(message, repeated, tag="2")]
pub references: ::prost::alloc::vec::Vec<super::super::schema::v1::Ref>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Data {
#[prost(message, optional, tag="1")]
pub data: ::core::option::Option<super::super::schema::v1::Data>,
#[prost(string, tag="2")]
pub schema: ::prost::alloc::string::String,
#[prost(message, repeated, tag="3")]
pub references: ::prost::alloc::vec::Vec<super::super::schema::v1::Ref>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Database {
#[prost(message, optional, tag="1")]
pub database: ::core::option::Option<super::super::schema::v1::Database>,
#[prost(message, repeated, tag="2")]
pub references: ::prost::alloc::vec::Vec<super::super::schema::v1::Ref>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Enum {
#[prost(message, optional, tag="1")]
pub r#enum: ::core::option::Option<super::super::schema::v1::Enum>,
#[prost(message, repeated, tag="2")]
pub references: ::prost::alloc::vec::Vec<super::super::schema::v1::Ref>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Topic {
#[prost(message, optional, tag="1")]
pub topic: ::core::option::Option<super::super::schema::v1::Topic>,
#[prost(message, repeated, tag="2")]
pub references: ::prost::alloc::vec::Vec<super::super::schema::v1::Ref>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TypeAlias {
#[prost(message, optional, tag="1")]
pub typealias: ::core::option::Option<super::super::schema::v1::TypeAlias>,
#[prost(message, repeated, tag="2")]
pub references: ::prost::alloc::vec::Vec<super::super::schema::v1::Ref>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Secret {
#[prost(message, optional, tag="1")]
pub secret: ::core::option::Option<super::super::schema::v1::Secret>,
#[prost(message, repeated, tag="2")]
pub references: ::prost::alloc::vec::Vec<super::super::schema::v1::Ref>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Verb {
#[prost(message, optional, tag="1")]
pub verb: ::core::option::Option<super::super::schema::v1::Verb>,
#[prost(string, tag="2")]
pub schema: ::prost::alloc::string::String,
#[prost(string, tag="3")]
pub json_request_schema: ::prost::alloc::string::String,
#[prost(message, repeated, tag="4")]
pub references: ::prost::alloc::vec::Vec<super::super::schema::v1::Ref>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Module {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub deployment_key: ::prost::alloc::string::String,
#[prost(string, tag="3")]
pub language: ::prost::alloc::string::String,
#[prost(string, tag="4")]
pub schema: ::prost::alloc::string::String,
#[prost(message, repeated, tag="5")]
pub verbs: ::prost::alloc::vec::Vec<Verb>,
#[prost(message, repeated, tag="6")]
pub data: ::prost::alloc::vec::Vec<Data>,
#[prost(message, repeated, tag="7")]
pub secrets: ::prost::alloc::vec::Vec<Secret>,
#[prost(message, repeated, tag="8")]
pub configs: ::prost::alloc::vec::Vec<Config>,
#[prost(message, repeated, tag="9")]
pub databases: ::prost::alloc::vec::Vec<Database>,
#[prost(message, repeated, tag="10")]
pub enums: ::prost::alloc::vec::Vec<Enum>,
#[prost(message, repeated, tag="11")]
pub topics: ::prost::alloc::vec::Vec<Topic>,
#[prost(message, repeated, tag="12")]
pub typealiases: ::prost::alloc::vec::Vec<TypeAlias>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TopologyGroup {
#[prost(string, repeated, tag="1")]
pub modules: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Topology {
#[prost(message, repeated, tag="1")]
pub levels: ::prost::alloc::vec::Vec<TopologyGroup>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct GetModulesRequest {
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetModulesResponse {
#[prost(message, repeated, tag="1")]
pub modules: ::prost::alloc::vec::Vec<Module>,
#[prost(message, optional, tag="2")]
pub topology: ::core::option::Option<Topology>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct StreamModulesRequest {
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamModulesResponse {
#[prost(message, repeated, tag="1")]
pub modules: ::prost::alloc::vec::Vec<Module>,
#[prost(message, optional, tag="2")]
pub topology: ::core::option::Option<Topology>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetConfigRequest {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, optional, tag="2")]
pub module: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetConfigResponse {
#[prost(bytes="bytes", tag="1")]
pub value: ::prost::bytes::Bytes,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetConfigRequest {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, optional, tag="2")]
pub module: ::core::option::Option<::prost::alloc::string::String>,
#[prost(bytes="bytes", tag="3")]
pub value: ::prost::bytes::Bytes,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetConfigResponse {
#[prost(bytes="bytes", tag="1")]
pub value: ::prost::bytes::Bytes,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetSecretRequest {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, optional, tag="2")]
pub module: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetSecretResponse {
#[prost(bytes="bytes", tag="1")]
pub value: ::prost::bytes::Bytes,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetSecretRequest {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, optional, tag="2")]
pub module: ::core::option::Option<::prost::alloc::string::String>,
#[prost(bytes="bytes", tag="3")]
pub value: ::prost::bytes::Bytes,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetSecretResponse {
#[prost(bytes="bytes", tag="1")]
pub value: ::prost::bytes::Bytes,
}
// @@protoc_insertion_point(module)
71 changes: 71 additions & 0 deletions backend/protos/src/protos/xyz.block.ftl.deployment.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// @generated
// This file is @generated by prost-build.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetDeploymentContextRequest {
#[prost(string, tag="1")]
pub deployment: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetDeploymentContextResponse {
#[prost(string, tag="1")]
pub module: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub deployment: ::prost::alloc::string::String,
#[prost(map="string, bytes", tag="3")]
pub configs: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::bytes::Bytes>,
#[prost(map="string, bytes", tag="4")]
pub secrets: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::bytes::Bytes>,
#[prost(message, repeated, tag="5")]
pub databases: ::prost::alloc::vec::Vec<get_deployment_context_response::Dsn>,
#[prost(message, repeated, tag="6")]
pub routes: ::prost::alloc::vec::Vec<get_deployment_context_response::Route>,
}
/// Nested message and enum types in `GetDeploymentContextResponse`.
pub mod get_deployment_context_response {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Dsn {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(enumeration="DbType", tag="2")]
pub r#type: i32,
#[prost(string, tag="3")]
pub dsn: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Route {
#[prost(string, tag="1")]
pub deployment: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub uri: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DbType {
Unspecified = 0,
Postgres = 1,
Mysql = 2,
}
impl DbType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "DB_TYPE_UNSPECIFIED",
Self::Postgres => "DB_TYPE_POSTGRES",
Self::Mysql => "DB_TYPE_MYSQL",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"DB_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"DB_TYPE_POSTGRES" => Some(Self::Postgres),
"DB_TYPE_MYSQL" => Some(Self::Mysql),
_ => None,
}
}
}
}
// @@protoc_insertion_point(module)
Loading
Loading