diff --git a/.github/workflows/build_matrix.yml b/.github/workflows/build_matrix.yml index 3e09d85b9a..55250bc158 100644 --- a/.github/workflows/build_matrix.yml +++ b/.github/workflows/build_matrix.yml @@ -10,7 +10,7 @@ jobs: # IMPORTANT: in case of changing the structure of this file make sure to test # the changes against `npm/gen-root.ts` file setup-matrix: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 outputs: matrix: ${{ steps.setup-matrix.outputs.matrix }} steps: @@ -33,34 +33,34 @@ jobs: ] include: - build: linux-x64-gnu - os: ubuntu-latest + os: ubuntu-22.04 rust: stable target: x86_64-unknown-linux-gnu libc: glibc - build: linux-x64-musl - os: ubuntu-latest + os: ubuntu-22.04 rust: stable target: x86_64-unknown-linux-musl libc: musl cross: true - build: linux-arm64-gnu - os: ubuntu-latest + os: ubuntu-22.04 rust: stable target: aarch64-unknown-linux-gnu libc: glibc cross: true - build: linux-arm64-musl - os: ubuntu-latest + os: ubuntu-22.04 rust: stable target: aarch64-unknown-linux-musl libc: musl cross: true - build: linux-ia32-gnu - os: ubuntu-latest + os: ubuntu-22.04 rust: stable target: i686-unknown-linux-gnu libc: glibc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffadd30c5c..df3740c7b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -262,7 +262,7 @@ jobs: needs: [setup_build_matrix, test, draft_release, check_if_build, test_cf, test_wasm] # TODO: put a condition to separate job that other will depend on to remove duplication? if: github.event_name == 'push' && github.ref == 'refs/heads/main' && (needs.check_if_build.outputs.check_if_build == 'true') - runs-on: ${{ matrix.os || 'ubuntu-latest' }} + runs-on: ${{ matrix.os || 'ubuntu-22.04' }} strategy: fail-fast: false matrix: ${{ fromJson(needs.setup_build_matrix.outputs.matrix) }} diff --git a/Cargo.lock b/Cargo.lock index 028934b915..572b3f7d95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,8 +286,7 @@ dependencies = [ [[package]] name = "async-graphql-extension-apollo-tracing" version = "3.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c4d3cc0bb90e426ddedb5a0b30bd9c0a9aaec1351d0e96556d5919a18ff954" +source = "git+https://github.com/Anshgrover23/async_graphql_apollo_studio_extension?rev=d89ea0588552c8eb10b7169c012ff3613970126c#d89ea0588552c8eb10b7169c012ff3613970126c" dependencies = [ "anyhow", "async-graphql", diff --git a/Cargo.toml b/Cargo.toml index 5a344242c0..6b584e81d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -141,7 +141,7 @@ opentelemetry-appender-tracing = { version = "0.4.0" } opentelemetry-prometheus = "0.16.0" phonenumber = "0.3.4" chrono = "0.4.38" -async-graphql-extension-apollo-tracing = { version = "3.2.15"} +async-graphql-extension-apollo-tracing = { git = "https://github.com/Anshgrover23/async_graphql_apollo_studio_extension", rev = "d89ea0588552c8eb10b7169c012ff3613970126c" } headers = { workspace = true } http = { workspace = true } mime = "0.3.17" diff --git a/npm/cli.js b/npm/cli.js new file mode 100644 index 0000000000..4e0a5ac366 --- /dev/null +++ b/npm/cli.js @@ -0,0 +1,43 @@ +#!/usr/bin/env node + +import {familySync, GLIBC, MUSL} from "detect-libc" +import {spawn} from "child_process" +import path from "path" +import {fileURLToPath} from "url" + +const filename = fileURLToPath(import.meta.url) +const dirname = path.dirname(filename) +const rootDir = path.resolve(dirname, "..") + +const platform = process.platform +const arch = process.arch + +const libcFamily = familySync() +let libc +if (platform === "win32") { + libc = "-msvc" +} else { + libc = libcFamily === GLIBC ? "-gnu" : libcFamily === MUSL ? "-musl" : "" +} + +const pkg = `@tailcallhq/core-${platform}-${arch}${libc}` +const binaryPath = path.join(rootDir, "node_modules", pkg, "bin", platform === "win32" ? "tailcall.exe" : "tailcall") + +try { + const child = spawn(binaryPath, process.argv.slice(2), { + stdio: "inherit", + shell: true, + }) + + child.on("error", (err) => { + console.error(`Failed to execute tailcall: ${err.message}`) + process.exit(1) + }) + + child.on("exit", (code) => { + process.exit(code ?? 1) + }) +} catch (error) { + console.error(`Failed to execute tailcall: ${error.message}`) + process.exit(1) +} diff --git a/npm/gen-root.ts b/npm/gen-root.ts index c5cfbd5ae2..43d2b67254 100644 --- a/npm/gen-root.ts +++ b/npm/gen-root.ts @@ -60,6 +60,9 @@ async function genServerPackage(buildDefinitions: string[]) { name: name, type: "module", version: packageVersion, + bin: { + tailcall: "./cli.js", + }, optionalDependencies, scarfSettings: { defaultOptIn: true, @@ -90,10 +93,19 @@ async function genServerPackage(buildDefinitions: string[]) { optionalDependencies, )};\n${preInstallScript}` + // Write script files await fs.writeFile(resolve(scriptsPath, "post-install.js"), postInstallScriptContent, "utf8") await fs.writeFile(resolve(scriptsPath, "pre-install.js"), preInstallScriptContent, "utf8") + + // Write package.json await fs.writeFile(resolve(directoryPath, "./package.json"), JSON.stringify(tailcallPackage, null, 2), "utf8") + // Copy cli.js and set executable permissions + const cliPath = resolve(directoryPath, "cli.js") + await fs.copyFile(resolve(__dirname, "cli.js"), cliPath) + await fs.chmod(cliPath, 0o755) // Make cli.js executable + + // Copy README await fs.copyFile(resolve(__dirname, "../README.md"), resolve(directoryPath, "./README.md")) } diff --git a/npm/gen.ts b/npm/gen.ts index 551371ff2f..3e76671559 100644 --- a/npm/gen.ts +++ b/npm/gen.ts @@ -44,7 +44,8 @@ async function genPlatformPackage() { cpu: [cpu], } - if (libc) platformPackage.libc = [libc] + // Only set libc for non-Windows platforms + if (libc && os !== "win32") platformPackage.libc = [libc] const packagePath = `@tailcallhq/core-${build}` const binPath = `${packagePath}/bin`