Skip to content

Commit

Permalink
Lint & Format
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Jun 26, 2024
1 parent c78605c commit 564fd64
Show file tree
Hide file tree
Showing 94 changed files with 4,665 additions and 4,018 deletions.
481 changes: 268 additions & 213 deletions buildkite/src/Command/Base.dhall

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions buildkite/src/Command/CheckGraphQLSchema.dhall
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
let Prelude = ../External/Prelude.dhall

let Command = ./Base.dhall

let Size = ./Size.dhall
let RunInToolchain = ./RunInToolchain.dhall in

{ step = \(dependsOn : List Command.TaggedKey.Type) ->
Command.build
Command.Config::{
commands =
RunInToolchain.runInToolchainBullseye ([] : List Text)
"./buildkite/scripts/check-graphql-schema.sh",
label = "Check GraphQL Schema",
key = "check-graphql-schema",
target = Size.Large,
depends_on = dependsOn
}
}
let RunInToolchain = ./RunInToolchain.dhall

in { step =
\(dependsOn : List Command.TaggedKey.Type)
-> Command.build
Command.Config::{
, commands =
RunInToolchain.runInToolchainBullseye
([] : List Text)
"./buildkite/scripts/check-graphql-schema.sh"
, label = "Check GraphQL Schema"
, key = "check-graphql-schema"
, target = Size.Large
, depends_on = dependsOn
}
}
46 changes: 23 additions & 23 deletions buildkite/src/Command/ConnectToTestnet.dhall
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
let Prelude = ../External/Prelude.dhall
let B = ../External/Buildkite.dhall

let Command = ./Base.dhall
let Docker = ./Docker/Type.dhall

let Size = ./Size.dhall

let B/SoftFail = B.definitions/commandStep/properties/soft_fail/Type

let Cmd = ../Lib/Cmds.dhall in
let Cmd = ../Lib/Cmds.dhall

{ step = \(dependsOn : List Command.TaggedKey.Type)
-> \(testnet : Text)
-> \(wait_between_graphql_poll : Text)
-> \(wait_before_final_check: Text )
-> \(soft_fail: B/SoftFail)
-> Command.build
Command.Config::{
commands = [
Cmd.runInDocker
Cmd.Docker::{
image = (../Constants/ContainerImages.dhall).ubuntu2004
in { step =
\(dependsOn : List Command.TaggedKey.Type)
-> \(testnet : Text)
-> \(wait_between_graphql_poll : Text)
-> \(wait_before_final_check : Text)
-> \(soft_fail : B/SoftFail)
-> Command.build
Command.Config::{
, commands =
[ Cmd.runInDocker
Cmd.Docker::{
, image = (../Constants/ContainerImages.dhall).ubuntu2004
}
"./buildkite/scripts/connect-to-testnet.sh ${testnet} ${wait_between_graphql_poll} ${wait_before_final_check}"
]
, label = "Connect to ${testnet}"
, soft_fail = Some soft_fail
, key = "connect-to-${testnet}"
, target = Size.Large
, depends_on = dependsOn
}
"./buildkite/scripts/connect-to-testnet.sh ${testnet} ${wait_between_graphql_poll} ${wait_before_final_check}"
],
label = "Connect to ${testnet}",
soft_fail = Some soft_fail,
key = "connect-to-${testnet}",
target = Size.Large,
depends_on = dependsOn
}
}
}
107 changes: 50 additions & 57 deletions buildkite/src/Command/DeployTestnet.dhall
Original file line number Diff line number Diff line change
@@ -1,63 +1,56 @@
let Prelude = ../External/Prelude.dhall

let Command = ./Base.dhall

let Size = ./Size.dhall

let Cmd = ../Lib/Cmds.dhall

let DeploySpec =
{ Type =
{ testnetLabel : Text
, deployEnvFile : Text
, workspace : Text
, artifactPath : Text
, postDeploy : Text
, testnetDir : Text
, deps : List Command.TaggedKey.Type
}
, default =
{ testnetLabel = "ci-net"
, deployEnvFile = "export-git-env-vars.sh"
, workspace = "\\\${BUILDKITE_BRANCH//[_\\/]/-}"
, artifactPath = "/tmp/artifacts"
, postDeploy = "echo 'Deployment successfull!'"
, testnetDir = "automation/terraform/testnets/ci-net"
, deps = [] : List Command.TaggedKey.Type
}
}

let DeploySpec = {
Type = {
testnetLabel: Text,
deployEnvFile : Text,
workspace: Text,
artifactPath: Text,
postDeploy: Text,
testnetDir: Text,
deps : List Command.TaggedKey.Type
},
default = {
testnetLabel = "ci-net",
deployEnvFile = "export-git-env-vars.sh",
workspace = "\\\${BUILDKITE_BRANCH//[_\\/]/-}",
artifactPath = "/tmp/artifacts",
postDeploy = "echo 'Deployment successfull!'",
testnetDir = "automation/terraform/testnets/ci-net",
deps = [] : List Command.TaggedKey.Type
}
}

in

{
step = \(spec : DeploySpec.Type) ->
Command.build
Command.Config::{
commands = [
Cmd.run "cd ${spec.testnetDir}",
Cmd.run "terraform init",
-- create separate workspace based on build branch to isolate infrastructure states
Cmd.run "terraform workspace select ${spec.workspace} || terraform workspace new ${spec.workspace}",
-- download deployment dependencies and ensure artifact DIR exists
Cmd.run "mkdir -p ${spec.artifactPath}",
Cmd.run "artifact-cache-helper.sh ${spec.deployEnvFile}",
-- launch testnet based on deploy ENV and ensure auto-cleanup on `apply` failures
Cmd.run "source ${spec.deployEnvFile}",
Cmd.run (
"terraform apply -auto-approve" ++
" -var mina_image=gcr.io/o1labs-192920/mina-daemon:\\\$MINA_DOCKER_TAG" ++
" -var ci_artifact_path=${spec.artifactPath}" ++
" || (terraform destroy -auto-approve && exit 1)"
),
-- upload/cache testnet genesis_ledger
Cmd.run "artifact-cache-helper.sh ${spec.artifactPath}/genesis_ledger.json --upload",
-- execute post-deploy operation
Cmd.run "${spec.postDeploy}"
],
label = "Deploy ${spec.testnetLabel}",
key = "deploy-${spec.testnetLabel}",
target = Size.Large,
depends_on = spec.deps
},
DeploySpec = DeploySpec
}
in { step =
\(spec : DeploySpec.Type)
-> Command.build
Command.Config::{
, commands =
[ Cmd.run "cd ${spec.testnetDir}"
, Cmd.run "terraform init"
, Cmd.run
"terraform workspace select ${spec.workspace} || terraform workspace new ${spec.workspace}"
, Cmd.run "mkdir -p ${spec.artifactPath}"
, Cmd.run "artifact-cache-helper.sh ${spec.deployEnvFile}"
, Cmd.run "source ${spec.deployEnvFile}"
, Cmd.run
( "terraform apply -auto-approve"
++ " -var mina_image=gcr.io/o1labs-192920/mina-daemon:\\\$MINA_DOCKER_TAG"
++ " -var ci_artifact_path=${spec.artifactPath}"
++ " || (terraform destroy -auto-approve && exit 1)"
)
, Cmd.run
"artifact-cache-helper.sh ${spec.artifactPath}/genesis_ledger.json --upload"
, Cmd.run "${spec.postDeploy}"
]
, label = "Deploy ${spec.testnetLabel}"
, key = "deploy-${spec.testnetLabel}"
, target = Size.Large
, depends_on = spec.deps
}
, DeploySpec = DeploySpec
}
39 changes: 19 additions & 20 deletions buildkite/src/Command/Docker/Type.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
--
-- TODO: Move volume to something in the cloud or artifacts from gcloud storage

{
Type = {
image: Text,
shell: Optional (List Text),
`propagate-environment`: Bool,
`mount-buildkite-agent`: Bool,
`mount-workdir`: Bool,
privileged: Bool,
environment: List Text,
user: Optional Text
},
default = {
shell = Some ["/bin/sh", "-e", "-c"],
`propagate-environment` = True,
`mount-buildkite-agent` = False,
`mount-workdir` = False,
privileged = False,
environment = [ "BUILDKITE_AGENT_ACCESS_TOKEN" ],
user = None Text
}
{ Type =
{ image : Text
, shell : Optional (List Text)
, propagate-environment : Bool
, mount-buildkite-agent : Bool
, mount-workdir : Bool
, privileged : Bool
, environment : List Text
, user : Optional Text
}
, default =
{ shell = Some [ "/bin/sh", "-e", "-c" ]
, propagate-environment = True
, mount-buildkite-agent = False
, mount-workdir = False
, privileged = False
, environment = [ "BUILDKITE_AGENT_ACCESS_TOKEN" ]
, user = None Text
}
}
Loading

0 comments on commit 564fd64

Please sign in to comment.