Skip to content
Permalink
Browse files

Docker: Automatically lookup merge sha in run_test_pr.sh

  • Loading branch information
oschuett committed Jan 3, 2020
1 parent 27260ac commit 99fd567af7e3dbe1b318b30ce765d775b6cdbba1
Showing with 10 additions and 7 deletions.
  1. +10 −7 tools/docker/run_test_pr.sh
@@ -1,22 +1,23 @@
#!/bin/bash -l
# -*- coding: utf-8 -*-
# author: Tiziano Müller
# author: Tiziano Müller, Ole Schütt

set -o errexit
set -o nounset
set -o pipefail

if [[ $# -lt 3 ]]; then
echo "usage: $0 <test_name> <PR ID or branch name> <Pull-Request ref/SHA> [optional-docker-run-arguments]"
echo "example: $0 python 506 d3b9e46d0f2a0588c23fcb00f20e134f3fc302e8"
if [[ $# -lt 2 ]]; then
echo "usage: $0 <test_name> <pr_number> [optional-docker-run-arguments]"
echo "example: $0 python 506"
exit 1
fi

TESTNAME=$1
[[ $2 =~ ^[0-9]+$ ]] && GIT_BRANCH="pull/$2/head" || GIT_BRANCH="$2"
GIT_REF=$3
PR_NUMBER=$2
shift 2

shift 3
GIT_BRANCH="pull/${PR_NUMBER}/merge"
GIT_REF=$(curl -s "https://api.github.com/repos/cp2k/cp2k/pulls/${PR_NUMBER}" | jq -r '.merge_commit_sha')

echo "Running ${TESTNAME} on Branch ${GIT_BRANCH} (ref: ${GIT_REF})..."

@@ -26,3 +27,5 @@ set -o xtrace
${DOCKER:-docker} run -i --init --rm --cap-add=SYS_PTRACE \
-e "GIT_BRANCH=${GIT_BRANCH}" -e "GIT_REF=${GIT_REF}" \
"$@" "img_cp2k_test_${TESTNAME}"

#EOF

0 comments on commit 99fd567

Please sign in to comment.
You can’t perform that action at this time.