From 9c4cccc9d340b5d4e515fd46c4f480e7093c6f5e Mon Sep 17 00:00:00 2001 From: Paul Brauner <141240651+paulbrauner-da@users.noreply.github.com> Date: Wed, 31 Jan 2024 14:03:39 +0100 Subject: [PATCH] add copy canton script (#18329) * add copy canton script * cleanup * remove old comments * make sure the script runs from anywhere --- ci/copy-canton.sh | 28 ++++++++++++++++++++++++++++ ci/cron/daily-compat.yml | 19 ++++--------------- 2 files changed, 32 insertions(+), 15 deletions(-) create mode 100755 ci/copy-canton.sh diff --git a/ci/copy-canton.sh b/ci/copy-canton.sh new file mode 100755 index 00000000000..9fd9be43902 --- /dev/null +++ b/ci/copy-canton.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +set -euo pipefail + +DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +else + canton_dir=$1 +fi + +code_drop_dir=$DIR/../canton +for path in community daml-common-staging README.md; do + rm -rf $code_drop_dir/$path + for f in $(git -C "$canton_dir" ls-files $path); do + # we're only interested in copying files, not directories, as git-ls has + # explicitly expanded all directories + if [[ -f $canton_dir/$f ]]; then + # we create the parent directories of f under canton/ if they don't exist + mkdir -p $code_drop_dir/$(dirname $f) + cp $canton_dir/$f $code_drop_dir/$f + fi + done + git add $code_drop_dir/$path +done diff --git a/ci/cron/daily-compat.yml b/ci/cron/daily-compat.yml index 79947787545..00961a9b812 100644 --- a/ci/cron/daily-compat.yml +++ b/ci/cron/daily-compat.yml @@ -238,24 +238,13 @@ jobs: ### code drop ### - copy_canton_code() { - canton_version=$1 - canton_dir=$2 - - commitish=$(canton_version_to_commitish $canton_version) tmp=$(mktemp -d) trap "rm -rf ${tmp}" EXIT - + git clone https://$GITHUB_TOKEN@github.com/DACH-NY/canton $tmp - git -C $tmp checkout $commitish - for path in community daml-common-staging README.md; do - src=$tmp/$path - dst=$canton_dir/$path - rm -rf $dst - mkdir -p $(dirname $dst) - cp -rf $src $dst - git add $dst - done + git -C $tmp checkout $(canton_version_to_commitish $canton3_version) + + ci/copy-canton.sh $tmp } copy_canton_code $canton3_version canton