From 026907a9ce6af096af7b6821f24a3728e190ef79 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 19 Feb 2021 12:44:42 +0100 Subject: [PATCH] =?UTF-8?q?#=20Ceci=20est=20la=20combinaison=20de=207=20co?= =?UTF-8?q?mmits.=20#=20Ceci=20est=20le=20premier=20message=20de=20validat?= =?UTF-8?q?ion=C2=A0:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First step of action # Ceci est le message de validation numéro 2 : add ssh stuff # Ceci est le message de validation numéro 3 : Update github action # Ceci est le message de validation numéro 4 : Fix Logic # Ceci est le message de validation numéro 5 : Don't override the PATH !!! # Ceci est le message de validation numéro 6 : Download the known host too, so it is possible to add new IPs in it. # Ceci est le message de validation numéro 7 : Fix GIT path and better management of VERSION_NUMBER --- .github/workflows/filter_testsuite.yml | 99 +++++++++++++++++++ .../run_testsuite_from_branch_name.sh | 69 +++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 .github/workflows/filter_testsuite.yml create mode 100644 Scripts/developer_scripts/run_testsuite_from_branch_name.sh diff --git a/.github/workflows/filter_testsuite.yml b/.github/workflows/filter_testsuite.yml new file mode 100644 index 00000000000..f2eb2dd589e --- /dev/null +++ b/.github/workflows/filter_testsuite.yml @@ -0,0 +1,99 @@ +name: Filter Testsuite + +on: + issue_comment: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3 + id: check + with: + result-encoding: string + script: | + const userName = context.payload.comment.user.login + if(userName == 'maxGimeno') { + const body = context.payload.comment.body + if(body.includes("/testme")) { + return 'OK' + } + } + return 'stop' + - uses: actions/github-script@v3 + if: steps.check.result != 'stop' + id: get_label + with: + result-encoding: string + script: | + //get branch name and username + const pr_url = context.payload.issue.pull_request.url + const pr_content = await github.request(pr_url) + const label = pr_content.data.head.label + console.log(label) + return label + - uses: actions/github-script@v3 + if: steps.check.result != 'stop' + id: get_base + with: + result-encoding: string + script: | + //get branch name and username + const pr_url = context.payload.issue.pull_request.url + const pr_content = await github.request(pr_url) + const base = pr_content.data.base.ref + console.log(base) + return base + - name: Run Testsuite + if: steps.check.outputs.result != 'stop' + run: | + mkdir -p ~/.ssh + #ssh key + ( + cat <> ~/.ssh/id_rsa + chmod 600 /home/runner/.ssh/id_rsa + #ssh public key + ( + cat <> ~/.ssh/id_rsa.pub + chmod 644 /home/runner/.ssh/id_rsa.pub + #known hosts + wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_known_hosts -O ~/.ssh/known_hosts + #config file + wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_config -O ~/.ssh/config + #list of hosts + wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_host_list -O ~/ssh_host_list + #ssh command + LABEL="${{ steps.get_label.outputs.result }}" + USER_NAME=$(echo $LABEL | cut -d':' -f 1) + BRANCH_NAME=$(echo $LABEL | cut -d':' -f 2) + BASE="${{ steps.get_base.outputs.result }}" + mapfile -t HOSTS < ~/ssh_host_list; + LAST_INDEX=$((${#HOSTS[@]}-1)) + for i in ${!HOSTS[@]}; do + HOST=$(echo ${HOSTS[$i]}|cut -d' ' -f 1 ) + PATH_TO_SCRIPT=$(echo ${HOSTS[$i]}|cut -d' ' -f 2 ) + if [ "$i" -ne "$LAST_INDEX" ] ; then + ssh ${HOST} "${PATH_TO_SCRIPT}/run_testsuite_from_branch_name.sh $USER_NAME $BRANCH_NAME $BASE" + else + ssh ${HOST} "${PATH_TO_SCRIPT}/run_testsuite_from_branch_name.sh $USER_NAME $BRANCH_NAME $BASE y" + fi + done + - name: Post address + uses: actions/github-script@v3 + if: steps.check.outputs.result != 'stop' + with: + script: | + const address = "The testsuite is lauched. results will be found, after it is done, here : https://cgal.geometryfactory.com/~mgimeno/test_suite/TESTRESULTS/index.shtml " + github.issues.createComment({ + owner: "maxGimeno", + repo: "cgal", + issue_number: ${{ github.event.issue.number }}, + body: address + }); diff --git a/Scripts/developer_scripts/run_testsuite_from_branch_name.sh b/Scripts/developer_scripts/run_testsuite_from_branch_name.sh new file mode 100644 index 00000000000..99b59fc1fe6 --- /dev/null +++ b/Scripts/developer_scripts/run_testsuite_from_branch_name.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +#To run: $1 = name of the user +# $2 = name of the branch +# $3 = base ref name (master, 5.1.x, 5.2.x, etc...) +# $4 = if given, update the VERSION_NUMBER + + +if uname | grep -q -i cygwin; then + #Is supposed to ignore \r as eol character. + export SHELLOPTS + set -o igncr +fi +source "$(dirname $0)/.autofilterrc" +USER_REPO=$1 +BRANCH_NAME=$2 +BASE_NAME=$3 +cd ${CGAL_ROOT} +scp mgimeno@cgal.geometryfactory.com:public_html/test_suite/VERSION_NUMBER . +cd ${CGAL_GIT_DIR} +if [ ! -d cgal ]; then + git clone --depth 1 --no-single-branch https://github.com/CGAL/cgal.git + cd cgal + git remote rename origin cgal + cd .. +fi +cd cgal +git fetch --depth 1 cgal +git remote add $USER_REPO https://github.com/$USER_REPO/cgal.git +git fetch --depth 1 $USER_REPO +git checkout $BRANCH_NAME +git reset --hard $USER_REPO/$BRANCH_NAME +#setup the list_test_packages +LIST_OF_PKGS=$(git diff --name-only HEAD cgal/$BASE_NAME |cut -s -d/ -f1 |sort -u | xargs -I {} ls -d {}/package_info 2>/dev/null |cut -d/ -f1 |egrep -v Installation||true) +if [ "$LIST_OF_PKGS" != "" ]; then + if [ -f ${CGAL_ROOT}/list_test_packages ]; then rm ${CGAL_ROOT}/list_test_packages; fi + for f in $LIST_OF_PKGS + do + echo "echo \"$f\"" >> ${CGAL_ROOT}/list_test_packages + echo "echo \"${f}_Examples\"" >> ${CGAL_ROOT}/list_test_packages + echo "echo \"${f}_Demo\"" >> ${CGAL_ROOT}/list_test_packages + done +fi +( +#create the release from the branch +echo " Create release..." +cmake -DGIT_REPO=${CGAL_GIT_DIR}/cgal -DDESTINATION=${CGAL_ROOT}/CGAL-TEST -DPUBLIC=OFF -DTESTSUITE=ON -DCGAL_VERSION=0.0-Ic-$(cat ${CGAL_ROOT}/VERSION_NUMBER) -P ${CGAL_GIT_DIR}/cgal/Scripts/developer_scripts/cgal_create_release_with_cmake.cmake | tee log +echo "done." +DEST=$(sed -E 's/.*CGAL-TEST\/(.*)/\1/' log); + +cd ${CGAL_ROOT} + +if [ -L CGAL-I ]; then rm CGAL-I; fi +ln -s $PWD/CGAL-TEST/$DEST CGAL-I +echo "starting testsuite..." + +./autotest_cgal -c +)>${CGAL_ROOT}/autotest.log2 2>&1 & +echo "finished." +if [ -n "$4" ]; then + cd ${CGAL_ROOT} + V=$(cat VERSION_NUMBER) + V=$(($V+1)) + echo $V > VERSION_NUMBER + scp VERSION_NUMBER mgimeno@cgal.geometryfactory.com:public_html/test_suite/VERSION_NUMBER +fi + +echo "exit." +exit 0