feat: add v03 user billing service (#1128)
This commit is contained in:
@@ -18,6 +18,11 @@ export const DEFAULT_RUNTIME_DEP_PATHS = Object.freeze([
|
||||
"package-lock.json"
|
||||
]);
|
||||
|
||||
export const GO_RUNTIME_DEP_PATHS = Object.freeze([
|
||||
"go.mod",
|
||||
"go.sum"
|
||||
]);
|
||||
|
||||
export const DEFAULT_RUNTIME_PACKAGE_FIELDS = Object.freeze([
|
||||
"dependencies",
|
||||
"optionalDependencies",
|
||||
@@ -75,9 +80,11 @@ export async function createCiPlan(options = {}) {
|
||||
const componentModels = componentModelsForServices(serviceIdResolution.serviceIds, laneConfig, lane);
|
||||
const envReuseServices = enabledEnvReuseServices(deployJson, lane, serviceIdResolution.serviceIds);
|
||||
const globalChange = classifyGlobalChange(normalizedChangedPaths);
|
||||
const hasGoService = componentModels.some((model) => model.runtimeKind === "go-service");
|
||||
const dockerfileHash = await hashGitPaths(repoRoot, targetRef, [
|
||||
...envReuseRecipe.additionalEnvPaths,
|
||||
...DEFAULT_RUNTIME_DEP_PATHS
|
||||
...DEFAULT_RUNTIME_DEP_PATHS,
|
||||
...(hasGoService ? GO_RUNTIME_DEP_PATHS : [])
|
||||
], { semanticPackageJson: true });
|
||||
const catalogByServiceId = new Map((artifactCatalog?.services ?? []).map((service) => [service.serviceId, service]));
|
||||
|
||||
@@ -297,12 +304,20 @@ export function componentModelsForServices(serviceIds, laneConfig = null, lane =
|
||||
healthPort: declaration.healthPort,
|
||||
componentPaths: uniqueSorted(declaration.componentPaths.map(normalizeRepoPath)),
|
||||
sharedPaths: uniqueSorted(DEFAULT_SHARED_RUNTIME_PATHS.map(normalizeRepoPath)),
|
||||
runtimeDeps: uniqueSorted(DEFAULT_RUNTIME_DEP_PATHS.map(normalizeRepoPath)),
|
||||
runtimeDeps: runtimeDependencyPathsForDeclaration(declaration),
|
||||
buildSystemPaths: uniqueSorted(envReuseRecipeForLaneConfig(laneConfig, lane).additionalEnvPaths)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function runtimeDependencyPathsForDeclaration(declaration) {
|
||||
const paths = [...DEFAULT_RUNTIME_DEP_PATHS];
|
||||
if (declaration.runtimeKind === "go-service" || declaration.artifactKind === "go-service") {
|
||||
paths.push(...GO_RUNTIME_DEP_PATHS);
|
||||
}
|
||||
return uniqueSorted(paths.map(normalizeRepoPath));
|
||||
}
|
||||
|
||||
function serviceDeclarationFor(laneConfig, serviceId, lane) {
|
||||
const configured = laneConfig?.serviceDeclarations?.[serviceId];
|
||||
const runtimeKind = requireDeclarationString(configured?.runtimeKind, lane, `serviceDeclarations.${serviceId}.runtimeKind`);
|
||||
@@ -351,6 +366,9 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") {
|
||||
const bunVersion = requireDeclarationString(configured.bunVersion, lane, "envRecipe.bunVersion");
|
||||
const launcherPath = normalizeRepoPath(requireDeclarationString(configured.launcherPath, lane, "envRecipe.launcherPath"));
|
||||
const runtimeNodeModulesPath = normalizeAbsolutePath(configured.runtimeNodeModulesPath);
|
||||
const runtimeGoModCachePath = normalizeAbsolutePath(configured.runtimeGoModCachePath);
|
||||
const runtimeGoBuildCachePath = normalizeAbsolutePath(configured.runtimeGoBuildCachePath);
|
||||
const goToolchain = normalizeDeclarationString(configured.goToolchain);
|
||||
if (!runtimeNodeModulesPath) throw new Error(`deploy.lanes.${lane}.envRecipe.runtimeNodeModulesPath must be absolute`);
|
||||
const additionalEnvPaths = uniqueSorted(normalizeStringList(configured.additionalEnvPaths, []).map(normalizeRepoPath));
|
||||
const launcherInputPaths = uniqueSorted([
|
||||
@@ -367,6 +385,9 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") {
|
||||
bunVersion,
|
||||
launcherPath,
|
||||
runtimeNodeModulesPath,
|
||||
runtimeGoModCachePath,
|
||||
runtimeGoBuildCachePath,
|
||||
goToolchain,
|
||||
additionalEnvPaths,
|
||||
launcherInputPaths,
|
||||
downloadStack,
|
||||
@@ -376,6 +397,9 @@ function envReuseRecipeForLaneConfig(laneConfig, lane = "v02") {
|
||||
bunVersion,
|
||||
launcherPath,
|
||||
runtimeNodeModulesPath,
|
||||
runtimeGoModCachePath,
|
||||
runtimeGoBuildCachePath,
|
||||
goToolchain,
|
||||
additionalEnvPaths,
|
||||
downloadStack,
|
||||
hwpodAliases
|
||||
@@ -389,6 +413,7 @@ function normalizeDownloadStack(value, lane) {
|
||||
const httpProxy = normalizeOptionalHttpUrl(configured.httpProxy, `deploy.lanes.${lane}.envRecipe.downloadStack.httpProxy`);
|
||||
const httpsProxy = normalizeOptionalHttpUrl(configured.httpsProxy, `deploy.lanes.${lane}.envRecipe.downloadStack.httpsProxy`);
|
||||
const npmRegistry = normalizeOptionalHttpUrl(configured.npmRegistry, `deploy.lanes.${lane}.envRecipe.downloadStack.npmRegistry`);
|
||||
const goProxy = normalizeDeclarationString(configured.goProxy);
|
||||
const npmFetchTimeoutMs = Number(configured.npmFetchTimeoutMs);
|
||||
const bunPackages = configured.bunPackages && typeof configured.bunPackages === "object" ? configured.bunPackages : null;
|
||||
const x64 = normalizePackageName(bunPackages?.x64);
|
||||
@@ -404,6 +429,7 @@ function normalizeDownloadStack(value, lane) {
|
||||
noProxy: normalizeStringList(configured.noProxy, []),
|
||||
npmRegistry,
|
||||
npmFetchTimeoutMs,
|
||||
goProxy,
|
||||
bunPackages: { x64, arm64 }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -85,6 +85,17 @@ export async function resolveDevArtifactService(repoRoot, serviceId, catalog = n
|
||||
});
|
||||
}
|
||||
|
||||
const goCmdPath = `cmd/${serviceId}/main.go`;
|
||||
if (await pathExists(repoRoot, goCmdPath)) {
|
||||
return withServicePublishPolicy({
|
||||
serviceId,
|
||||
runtimeKind: "go-service",
|
||||
entrypoint: goCmdPath,
|
||||
implementationState: "repo-entrypoint",
|
||||
sourceState
|
||||
});
|
||||
}
|
||||
|
||||
if (serviceId === "hwlab-cloud-web") {
|
||||
return withServicePublishPolicy({
|
||||
serviceId,
|
||||
|
||||
Reference in New Issue
Block a user