Skip to content

Commit

Permalink
refactor: non-nullable timeout in BaseBuildSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
vvagaytsev committed Apr 11, 2023
1 parent 04c6206 commit 0760794
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 154 deletions.
3 changes: 2 additions & 1 deletion core/src/config/base.ts
Expand Up @@ -14,7 +14,7 @@ import { pathExists, readFile } from "fs-extra"
import { omit, isPlainObject, isArray } from "lodash"
import { coreModuleSpecSchema, baseModuleSchemaKeys, BuildDependencyConfig, ModuleConfig } from "./module"
import { ConfigurationError, FilesystemError, ParameterError } from "../exceptions"
import { DEFAULT_API_VERSION } from "../constants"
import { DEFAULT_API_VERSION, DEFAULT_BUILD_TIMEOUT_SEC } from "../constants"
import { ProjectConfig, ProjectResource } from "../config/project"
import { validateWithPath } from "./validation"
import { defaultDotIgnoreFile, listDirectory } from "../util/fs"
Expand Down Expand Up @@ -350,6 +350,7 @@ export function prepareModuleResource(spec: any, configPath: string, projectRoot
allowPublish: spec.allowPublish,
build: {
dependencies,
timeout: spec.build?.timeout || DEFAULT_BUILD_TIMEOUT_SEC,
},
configPath,
description: spec.description,
Expand Down
2 changes: 1 addition & 1 deletion core/src/config/module.ts
Expand Up @@ -70,7 +70,7 @@ export const buildDependencySchema = createSchema({

export interface BaseBuildSpec {
dependencies: BuildDependencyConfig[]
timeout?: number
timeout: number
}

export interface GenerateFileSpec {
Expand Down
3 changes: 2 additions & 1 deletion core/src/util/testing.ts
Expand Up @@ -20,7 +20,7 @@ import { EventBus, Events } from "../events"
import { dedent } from "./string"
import pathIsInside from "path-is-inside"
import { join, resolve } from "path"
import { DEFAULT_API_VERSION, GARDEN_CORE_ROOT } from "../constants"
import { DEFAULT_API_VERSION, DEFAULT_BUILD_TIMEOUT_SEC, GARDEN_CORE_ROOT } from "../constants"
import { getRootLogger } from "../logger/logger"
import stripAnsi from "strip-ansi"
import { VcsHandler } from "../vcs/vcs"
Expand Down Expand Up @@ -64,6 +64,7 @@ const moduleConfigDefaults: ModuleConfig = {
apiVersion: DEFAULT_API_VERSION,
build: {
dependencies: [],
timeout: DEFAULT_BUILD_TIMEOUT_SEC,
},
disabled: false,
name: "foo",
Expand Down
4 changes: 2 additions & 2 deletions core/test/helpers.ts
Expand Up @@ -35,7 +35,7 @@ import { createGardenPlugin, GardenPluginSpec, ProviderHandlers, RegisterPluginP
import { Garden, GardenOpts } from "../src/garden"
import { ModuleConfig } from "../src/config/module"
import { ModuleVersion } from "../src/vcs/vcs"
import { DEFAULT_API_VERSION, GARDEN_CORE_ROOT, gardenEnv } from "../src/constants"
import { DEFAULT_API_VERSION, DEFAULT_BUILD_TIMEOUT_SEC, GARDEN_CORE_ROOT, gardenEnv } from "../src/constants"
import { globalOptions, GlobalOptions, Parameters, ParameterValues } from "../src/cli/params"
import { ConfigureModuleParams } from "../src/plugin/handlers/Module/configure"
import { ExternalSourceType, getRemoteSourceRelPath, hashRepoUrl } from "../src/util/ext-source-util"
Expand Down Expand Up @@ -407,7 +407,7 @@ export const defaultModuleConfig: ModuleConfig = {
name: "test",
path: "bla",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
spec: {
services: [
Expand Down
20 changes: 10 additions & 10 deletions core/test/integ/src/plugins/hadolint/hadolint.ts
Expand Up @@ -9,7 +9,7 @@
import tmp from "tmp-promise"
import { ProjectConfig } from "../../../../../src/config/project"
import execa = require("execa")
import { DEFAULT_API_VERSION } from "../../../../../src/constants"
import { DEFAULT_API_VERSION, DEFAULT_BUILD_TIMEOUT_SEC } from "../../../../../src/constants"
import { createProjectConfig, getDataDir, TestGarden } from "../../../../helpers"
import { expect } from "chai"
import stripAnsi from "strip-ansi"
Expand Down Expand Up @@ -66,7 +66,7 @@ describe("hadolint provider", () => {
name: "foo",
type: "container",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path: tmpPath,
serviceConfigs: [],
Expand All @@ -80,7 +80,7 @@ describe("hadolint provider", () => {
name: "bar",
type: "container",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path: tmpPath,
serviceConfigs: [],
Expand Down Expand Up @@ -130,7 +130,7 @@ describe("hadolint provider", () => {
name: "foo",
type: "foo",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path: tmpPath,
serviceConfigs: [],
Expand Down Expand Up @@ -163,7 +163,7 @@ describe("hadolint provider", () => {
name: "foo",
type: "hadolint",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path,
serviceConfigs: [],
Expand Down Expand Up @@ -235,7 +235,7 @@ describe("hadolint provider", () => {
name: "foo",
type: "hadolint",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path: modulePath,
serviceConfigs: [],
Expand Down Expand Up @@ -301,7 +301,7 @@ describe("hadolint provider", () => {
name: "foo",
type: "hadolint",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path,
serviceConfigs: [],
Expand Down Expand Up @@ -361,7 +361,7 @@ describe("hadolint provider", () => {
name: "foo",
type: "hadolint",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path,
serviceConfigs: [],
Expand Down Expand Up @@ -411,7 +411,7 @@ describe("hadolint provider", () => {
name: "foo",
type: "hadolint",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path,
serviceConfigs: [],
Expand Down Expand Up @@ -464,7 +464,7 @@ describe("hadolint provider", () => {
name: "foo",
type: "hadolint",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path,
serviceConfigs: [],
Expand Down
Expand Up @@ -33,7 +33,7 @@ import { gardenAnnotationKey } from "../../../../../../src/util/string"
import { getDeployStatuses } from "../../../../../../src/tasks/helpers"
import { LocalModeProcessRegistry, ProxySshKeystore } from "../../../../../../src/plugins/kubernetes/local-mode"
import { KubernetesDeployAction } from "../../../../../../src/plugins/kubernetes/kubernetes-type/config"
import { DEFAULT_API_VERSION } from "../../../../../../src/constants"
import { DEFAULT_API_VERSION, DEFAULT_BUILD_TIMEOUT_SEC } from "../../../../../../src/constants"
import { ActionModeMap } from "../../../../../../src/actions/types"

describe("kubernetes-module handlers", () => {
Expand Down Expand Up @@ -86,7 +86,7 @@ describe("kubernetes-module handlers", () => {
kind: "Module",
disabled: false,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
description: "Kubernetes module that includes a Namespace resource",
name: "namespace-resource",
path: tmpDir.path,
Expand Down Expand Up @@ -185,6 +185,7 @@ describe("kubernetes-module handlers", () => {
})
return { deployParams, manifests }
}

it("should successfully deploy when serviceResource doesn't have a containerModule", async () => {
const graph = await garden.getConfigGraph({ log: garden.log, emit: false })
const action = graph.getDeploy("module-simple")
Expand Down
4 changes: 2 additions & 2 deletions core/test/integ/src/plugins/kubernetes/volume/configmap.ts
Expand Up @@ -9,7 +9,7 @@
import tmp from "tmp-promise"
import { ProjectConfig } from "../../../../../../src/config/project"
import execa = require("execa")
import { DEFAULT_API_VERSION } from "../../../../../../src/constants"
import { DEFAULT_API_VERSION, DEFAULT_BUILD_TIMEOUT_SEC } from "../../../../../../src/constants"
import { expect } from "chai"
import { TestGarden, makeTempDir, createProjectConfig } from "../../../../../helpers"
import { DeployTask } from "../../../../../../src/tasks/deploy"
Expand Down Expand Up @@ -50,7 +50,7 @@ describe("configmap module", () => {
name: "test",
type: "configmap",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path: tmpDir.path,
serviceConfigs: [],
Expand Down
Expand Up @@ -9,7 +9,7 @@
import tmp from "tmp-promise"
import { ProjectConfig } from "../../../../../../src/config/project"
import execa = require("execa")
import { DEFAULT_API_VERSION } from "../../../../../../src/constants"
import { DEFAULT_API_VERSION, DEFAULT_BUILD_TIMEOUT_SEC } from "../../../../../../src/constants"
import { expect } from "chai"
import { TestGarden, makeTempDir, createProjectConfig } from "../../../../../helpers"
import { DeployTask } from "../../../../../../src/tasks/deploy"
Expand Down Expand Up @@ -55,7 +55,7 @@ describe("persistentvolumeclaim", () => {
name: "test",
type: "persistentvolumeclaim",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path: tmpDir.path,
serviceConfigs: [],
Expand Down
10 changes: 8 additions & 2 deletions core/test/unit/src/analytics/analytics.ts
Expand Up @@ -13,7 +13,12 @@ import { validate as validateUuid } from "uuid"

import { makeTestGardenA, TestGarden, enableAnalytics, getDataDir, makeTestGarden, freezeTime } from "../../../helpers"
import { AnalyticsHandler, getAnonymousUserId } from "../../../../src/analytics/analytics"
import { DEFAULT_API_VERSION, DEFAULT_GARDEN_CLOUD_DOMAIN, gardenEnv } from "../../../../src/constants"
import {
DEFAULT_API_VERSION,
DEFAULT_BUILD_TIMEOUT_SEC,
DEFAULT_GARDEN_CLOUD_DOMAIN,
gardenEnv,
} from "../../../../src/constants"
import { CloudApi } from "../../../../src/cloud/api"
import { Log } from "../../../../src/logger/log-entry"
import { LogLevel, RootLogger } from "../../../../src/logger/logger"
Expand All @@ -25,6 +30,7 @@ class FakeCloudApi extends CloudApi {
static async factory(params: { log: Log; projectConfig?: ProjectResource; skipLogging?: boolean }) {
return new FakeCloudApi(params.log, "https://garden.io", new GlobalConfigStore())
}

async getProfile() {
return {
id: "1",
Expand Down Expand Up @@ -475,7 +481,7 @@ describe("AnalyticsHandler", () => {
name: "module-a",
type: "test",
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
path: "",
serviceConfigs: [],
Expand Down
29 changes: 17 additions & 12 deletions core/test/unit/src/commands/get/get-config.ts
Expand Up @@ -11,7 +11,12 @@ import { pick } from "lodash"
import { getDataDir, makeTestGarden, makeTestGardenA, withDefaultGlobalOpts } from "../../../../helpers"
import { GetConfigCommand } from "../../../../../src/commands/get/get-config"
import { sortBy } from "lodash"
import { DEFAULT_API_VERSION, DEFAULT_RUN_TIMEOUT_SEC, DEFAULT_TEST_TIMEOUT_SEC } from "../../../../../src/constants"
import {
DEFAULT_API_VERSION,
DEFAULT_BUILD_TIMEOUT_SEC,
DEFAULT_RUN_TIMEOUT_SEC,
DEFAULT_TEST_TIMEOUT_SEC,
} from "../../../../../src/constants"
import { defaultWorkflowResources, WorkflowConfig } from "../../../../../src/config/workflow"
import { defaultContainerLimits } from "../../../../../src/plugins/container/moduleConfig"

Expand Down Expand Up @@ -123,7 +128,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: true,
name: "a-disabled",
include: [],
Expand All @@ -146,7 +151,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
include: [],
name: "b-enabled",
Expand Down Expand Up @@ -192,7 +197,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
name: "enabled",
include: [],
Expand Down Expand Up @@ -252,7 +257,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
name: "enabled",
include: [],
Expand Down Expand Up @@ -310,7 +315,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
name: "enabled",
include: [],
Expand Down Expand Up @@ -377,7 +382,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: true,
name: "a-disabled",
include: [],
Expand All @@ -400,7 +405,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
include: [],
name: "b-enabled",
Expand Down Expand Up @@ -444,7 +449,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
name: "enabled",
include: [],
Expand Down Expand Up @@ -519,7 +524,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
name: "enabled",
include: [],
Expand Down Expand Up @@ -596,7 +601,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
name: "enabled",
include: [],
Expand Down Expand Up @@ -682,7 +687,7 @@ describe("GetConfigCommand", () => {
{
apiVersion: DEFAULT_API_VERSION,
allowPublish: false,
build: { dependencies: [] },
build: { dependencies: [], timeout: DEFAULT_BUILD_TIMEOUT_SEC },
disabled: false,
name: "enabled",
include: [],
Expand Down

0 comments on commit 0760794

Please sign in to comment.