Skip to content

Commit

Permalink
Merge pull request #16027 from MinaProtocol/dkijania/version_lint_for…
Browse files Browse the repository at this point in the history
…_mainline_branches

Version linter for each mainline branch
  • Loading branch information
dkijania authored Sep 10, 2024
2 parents 3288f13 + d68450b commit fafc2ea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions buildkite/scripts/dump-mina-type-shapes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ source buildkite/scripts/export-git-env-vars.sh

source buildkite/scripts/debian/install.sh "mina-${TESTNET_NAME}" 1

MINA_COMMIT_SHA1=$(git log -n 1 --format=%h --abbrev=7 --no-merges)
MINA_COMMIT_SHA1=$(git log -n 1 --format=%h --abbrev=7)
export TYPE_SHAPE_FILE=${MINA_COMMIT_SHA1}-type_shape.txt

echo "--- Create type shapes git note for commit: ${MINA_COMMIT_SHA1}"
mina internal dump-type-shapes > ${TYPE_SHAPE_FILE}
mina internal dump-type-shapes > ${TYPE_SHAPE_FILE}
2 changes: 1 addition & 1 deletion buildkite/scripts/version-linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pip3 install sexpdata==1.0.0

base_branch=${REMOTE}/${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-compatible}
pr_branch=origin/${BUILDKITE_BRANCH}
release_branch=${REMOTE}/$1
release_branch=origin/$1

echo "--- Run Python version linter with branches: ${pr_branch} ${base_branch} ${release_branch}"
./scripts/version-linter.py ${pr_branch} ${base_branch} ${release_branch}
Expand Down
24 changes: 19 additions & 5 deletions buildkite/src/Jobs/Test/VersionLint.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ let Cmd = ../../Lib/Cmds.dhall

let S = ../../Lib/SelectFiles.dhall

let B = ../../External/Buildkite.dhall

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

let Pipeline = ../../Pipeline/Dsl.dhall

let PipelineTag = ../../Pipeline/Tag.dhall
Expand All @@ -19,24 +23,26 @@ let Size = ../../Command/Size.dhall
let dependsOn = [ { name = "MinaArtifactBullseye", key = "build-deb-pkg" } ]

let buildTestCmd
: Text -> Size -> List Command.TaggedKey.Type -> Command.Type
: Text -> Size -> List Command.TaggedKey.Type -> B/SoftFail -> Command.Type
= \(release_branch : Text)
-> \(cmd_target : Size)
-> \(dependsOn : List Command.TaggedKey.Type)
-> \(soft_fail : B/SoftFail)
-> Command.build
Command.Config::{
, commands =
RunInToolchain.runInToolchain
([] : List Text)
"buildkite/scripts/dump-mina-type-shapes.sh"
# [ Cmd.run
"gsutil cp \$(git log -n 1 --format=%h --abbrev=7 --no-merges)-type_shape.txt \$MINA_TYPE_SHAPE gs://mina-type-shapes"
"gsutil cp \$(git log -n 1 --format=%h --abbrev=7)-type_shape.txt \$MINA_TYPE_SHAPE gs://mina-type-shapes"
]
# RunInToolchain.runInToolchain
([] : List Text)
"buildkite/scripts/version-linter.sh ${release_branch}"
, label = "Versioned type linter"
, key = "version-linter"
, label = "Versioned type linter for ${release_branch}"
, key = "version-linter-${release_branch}"
, soft_fail = Some soft_fail
, target = cmd_target
, docker = None Docker.Type
, depends_on = dependsOn
Expand All @@ -62,5 +68,13 @@ in Pipeline.build
, PipelineTag.Type.Stable
]
}
, steps = [ buildTestCmd "compatible" Size.Small dependsOn ]
, steps =
[ buildTestCmd
"compatible"
Size.Small
dependsOn
(B/SoftFail.Boolean True)
, buildTestCmd "develop" Size.Small dependsOn (B/SoftFail.Boolean True)
, buildTestCmd "master" Size.Small dependsOn (B/SoftFail.Boolean True)
]
}
6 changes: 3 additions & 3 deletions scripts/version-linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def set_error():

def branch_commit(branch):
print ('Retrieving', branch, 'head commit...')
result=subprocess.run(['git','log','-n','1','--format="%h"','--abbrev=7','--no-merges',f'{branch}'],
result=subprocess.run(['git','log','-n','1','--format="%h"','--abbrev=7',f'{branch}'],
capture_output=True)
output=result.stdout.decode('ascii')
print ('command stdout:', output)
Expand All @@ -55,7 +55,7 @@ def download_type_shapes(role,branch,sha1) :
print ("gsutil cp gs://mina-type-shapes ${sha1}-type_shape.txt ")

sys.exit(1)

result=subprocess.run(['wget','--no-clobber',url])

def type_shape_file(sha1) :
Expand Down Expand Up @@ -236,7 +236,7 @@ def check_type_shapes(pr_branch_dict,base_branch,base_type_dict,release_branch,r
# not an error if the type was introduced in the base branch, and the type changed in PR branch

def assert_commit(commit, desc):
if not commit:
if not commit:
f"Empty commit detected when evaluating commit of {desc}"

if __name__ == "__main__":
Expand Down

0 comments on commit fafc2ea

Please sign in to comment.