From 58b53d79c5f5101a7131b4732fbd42be871f911b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 8 Aug 2017 17:04:11 +0200 Subject: [PATCH] CI: fix the 'deploy' rules of alphanet/zeronet --- .gitlab-ci.yml | 81 +++++++++++++---------- scripts/alphanet.sh | 2 +- scripts/create_docker_image.build_deps.sh | 35 ++++++---- scripts/zeronet.patch | 4 +- 4 files changed, 72 insertions(+), 50 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d7ec98bf3..33d537ba6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,15 +31,7 @@ build: ## Building dependencies... - ./scripts/create_docker_image.build_deps.sh "build_deps" "${CI_BUILD_REF}" - "${CI_REGISTRY_IMAGE}/build_deps:${CI_BUILD_REF_NAME}" - "${CI_REGISTRY_IMAGE}/build_deps:master" - ## Saving the docker image... - - if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] && - [ "${CI_BUILD_REF_NAME}" = "master" ] ; then - docker tag "build_deps:${CI_BUILD_REF}" - "${CI_REGISTRY_IMAGE}/build_deps:master" ; - docker push "${CI_REGISTRY_IMAGE}/build_deps:master" ; - fi + "${CI_REGISTRY_IMAGE}/build_deps" ## Preparing sources for the alphanet or the zeronet... - if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] ; then ./scripts/apply_patch.sh "${CI_BUILD_REF_NAME}" ; @@ -142,6 +134,9 @@ publish:docker:minimal: - zeronet@tezos/tezos script: - docker pull "${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}" + - if [ "${CI_PROJECT_PATH}" = "tezos/tezos" ] ; then + ./scripts/apply_patch.sh "${CI_BUILD_REF_NAME}" ; + fi - ./scripts/create_docker_image.minimal.sh "${public_docker_image}" "${CI_BUILD_REF_NAME}" "${CI_REGISTRY_IMAGE}/build:${CI_BUILD_REF}" @@ -185,41 +180,57 @@ publish:github: HEAD - git push git@github.com:tezos/tezos.git -f HEAD:${CI_BUILD_REF_NAME} -deploy:alphanet: + +## Relaunching the bootstrap servers of the alphanet.zeronet + +.bootstrap_template: &bootstrap_definition image: ocaml/opam stage: deploy only: - alphanet@tezos/tezos - script: + - zeronet@tezos/tezos + before_script: - echo "${CI_KH}" > ~/.ssh/known_hosts - - echo "${CI_PK_ALPHANET}" | tr -d "\r" > ~/.ssh/id_ed25519 - - echo "${CI_SSH_CONFIG}" | tr -d "\r" > ~/.ssh/ssh_config + - if [ "${CI_BUILD_REF_NAME}" = "alphanet" ]; then + echo "${CI_PK_ALPHANET}" | tr -d "\r" > ~/.ssh/id_ed25519 ; + else + echo "${CI_PK_ZERONET}" | tr -d "\r" > ~/.ssh/id_ed25519 ; + fi + - echo "${CI_SSH_CONFIG}" | tr -d "\r" > ~/.ssh/config - chmod 600 ~/.ssh/id_ed25519 - - ssh -t bootstrap1 - - ssh -t bootstrap2 - - ssh -t bootstrap3 - - ssh -t bootstrap4 - - ssh -t bootstrap5 - - ssh -t bootstrap6 allow_failure: true -deploy:zeronet: - image: ocaml/opam - stage: deploy - only: - - zeronet@tezos/tezos +deploy:bootstrap1: + <<: *bootstrap_definition script: - - echo "${CI_KH}" > ~/.ssh/known_hosts - - echo "${CI_PK_ZERONET}" | tr -d "\r" > ~/.ssh/id_ed25519 - - echo "${CI_SSH_CONFIG}" | tr -d "\r" > ~/.ssh/ssh_config - - chmod 600 ~/.ssh/id_ed25519 - - ssh -t bootstrap1 - - ssh -t bootstrap2 - - ssh -t bootstrap3 - - ssh -t bootstrap4 - - ssh -t bootstrap5 - - ssh -t bootstrap6 - allow_failure: true + - ssh bootstrap1 + +deploy:bootstrap2: + <<: *bootstrap_definition + script: + - ssh bootstrap2 + +deploy:bootstrap3: + <<: *bootstrap_definition + script: + - ssh bootstrap3 + +deploy:bootstrap4: + <<: *bootstrap_definition + script: + - ssh bootstrap4 + +deploy:bootstrap5: + <<: *bootstrap_definition + script: + - ssh bootstrap5 + +deploy:bootstrap6: + <<: *bootstrap_definition + script: + - ssh bootstrap6 + +## Cleanup... cleanup: <<: *dind_definition diff --git a/scripts/alphanet.sh b/scripts/alphanet.sh index e6fd180a3..b481c0dfe 100755 --- a/scripts/alphanet.sh +++ b/scripts/alphanet.sh @@ -432,7 +432,7 @@ assert_uptodate() { update_script() { pull_image - tmp="$(docker run --rm -dit --entrypoint /bin/true "$docker_image")" + tmp="$(docker run --rm -dit --entrypoint /bin/sleep "$docker_image" 20)" docker cp "$tmp:home/tezos/scripts/alphanet.sh" ".alphanet.sh.new" docker stop "$tmp" > /dev/null if ! diff .alphanet.sh.new "$0" >/dev/null 2>&1 ; then diff --git a/scripts/create_docker_image.build_deps.sh b/scripts/create_docker_image.build_deps.sh index 16a0190b4..c5bd11802 100755 --- a/scripts/create_docker_image.build_deps.sh +++ b/scripts/create_docker_image.build_deps.sh @@ -26,19 +26,21 @@ sed scripts/Dockerfile.build_deps.in \ -e 's|$ocaml_version|'"$ocaml_version"'|g' > Dockerfile ## Lookup for for prebuilt dependencies... -base_layers=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $base_image | tr -d '[]') -same() { - docker run --rm "$1" cat /home/opam/$2 | diff -wq $2 - -} +dependencies="scripts/install_build_deps.sh src/tezos-deps.opam Dockerfile" +dependencies_sha1=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $base_image | sha1sum - $dependencies | sha1sum | tr -d ' -') for cached_image in "$@"; do - if ! docker pull $cached_image; then continue; fi - cached_base_layers=$(docker inspect --format="{{ .RootFS.Layers }}" --type=image $cached_image | tr -d '[]') - if [ "${cached_base_layers##$base_layers}" = "$cached_base_layers" ]; then continue; fi - if ! same "$cached_image" scripts/install_build_deps.sh ; then continue ; fi - if ! same "$cached_image" src/tezos-deps.opam ; then continue ; fi - if ! same "$cached_image" Dockerfile ; then continue ; fi - docker tag "$cached_image" "$image_name:$image_version" - exit 0 + echo + echo "### Looking for prebuilt dependencies ($cached_image)..." + if docker pull "$cached_image:$dependencies_sha1"; then + echo + echo "### Found $cached_image:$dependencies_sha1" + echo + docker tag "$cached_image:$dependencies_sha1" \ + "$image_name:$image_version" + exit 0 + fi + echo "### Missing..." + echo done echo @@ -52,3 +54,12 @@ rm Dockerfile echo echo "### Succesfully build docker image: $image_name:$image_version" echo + +for cached_image in "$@"; do + echo + echo "### Saving socker image ($cached_image)..." + echo + docker tag "$image_name:$image_version" \ + "$cached_image:$dependencies_sha1" + docker push "$cached_image:$dependencies_sha1" +done diff --git a/scripts/zeronet.patch b/scripts/zeronet.patch index 45fba2c19..197a17515 100644 --- a/scripts/zeronet.patch +++ b/scripts/zeronet.patch @@ -20,8 +20,8 @@ diff --git a/scripts/alphanet.sh b/scripts/alphanet.sh +data_dir="$HOME/.tezos-zeronet$suffix" +docker_container="tezos-zeronet$suffix" - - ## Saving state ############################################################ + if [ $ALPHANET_EMACS ]; then + interactive_flags="-t" diff --git a/src/node/main/node_config_file.ml b/src/node/main/node_config_file.ml --- a/src/node/main/node_config_file.ml +++ b/src/node/main/node_config_file.ml