#!/bin/bash # Copyright 2017, SUSE LINUX GmbH. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # This script will sync $files_to_sync files across all supported repositories as # returned by the gen-projects-list.sh script. The goal here is to try and sync # all these files at regular intervals so the code in the repositories is # tested in the same way on both the OpenStack CI and the Vagrant platforms. # This script will open reviews in the OpenStack gerrit so make sure your system is # configured properly to submit upstream reviews. Use ./sync-test-repos.sh -h # to get more information on how to use this script. Bugs about this script # should be submitted to the openstack-ansible project on launchpad as usual. # This script has a partner which is executed by the proposal bot here: # https://opendev.org/openstack/project-config/src/playbooks/proposal/sync_openstack_ansible_common_files.sh # Changes made to this file should be mirrored there when applicable. set -eu usage() { cat < Temporary directory for OSA repositories: ${tempdir}" mkdir ${tempdir} pushd ${tempdir} &> /dev/null echo "=> Cloning openstack-ansible-tests repository" eval git clone ${openstack_git_url}/openstack/openstack-ansible-tests echo -e "\n---------------------------------------------\n" for proj in ${osa_projects[@]}; do proj_dir=$(basename ${proj}) # Skip the project if it is in the excluded list check_and_ignore ${proj_dir} && continue echo "=> ##### ${proj} #####" eval git clone ${openstack_git_url}/$proj pushd $proj_dir &> /dev/null git checkout -b openstack/openstack-ansible-tests/sync-tests # if there an open review, re-use it open_review=$(git review --no-color -l | \ grep -v "^Found" | \ grep "Updated from OpenStack Ansible Tests" | \ tail -n1 | awk '{print $1}') [[ -n ${open_review} ]] && \ echo "Using existing review #${open_review} for ${proj_dir}" && \ git review -x ${open_review} popd &> /dev/null # Copy files pushd openstack-ansible-tests &> /dev/null copy_files ${proj_dir} popd &> /dev/null process_changes ${proj_dir} ${open_review:="__no_review__"} # Clean up the directory rm -rf ${proj_dir} echo -e "=> ##################################################\n" done popd &> /dev/null echo "All OpenStack Ansible repositories have been synced successfully!" echo "Happy testing ;-)" exit 0