forked from hail-is/hail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate temporary repos to test against (hail-is#97)
* wip * a little closer * bugs & posix * fixes * setup endpoints * give notice of setup-endpoints.sh` * wait more than one minute when there are no k8s nodes available it takes about 60 seconds to start one * bad rebase, should have deleted this line * pretty sure ssl is not supported in ci2 * stop using ci-test repo and use better temp dir * hide token in test-locally * be professional * address a few comments * hide TOKEN
- Loading branch information
Showing
13 changed files
with
174 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set +x | ||
|
||
FULLY_QUALIFIED_REPO_NAME=$1 | ||
TOKEN=$2 | ||
CALLBACK_URL=$3 | ||
|
||
if [[ -z "${FULLY_QUALIFIED_REPO_NAME}" ]] || [[ -z "${TOKEN}" ]] || [[ -z "${CALLBACK_URL}" ]] | ||
then | ||
echo "USAGE: ./setup-endpoints.sh FULLY_QUALIFIED_REPO_NAME GITHUB_OAUTH_TOKEN CALLBACK_URL" | ||
echo " e.g.: ./setup-endpoints.sh hail-ci-test/foo abcdef http://ci2.hail.is" | ||
exit 1 | ||
fi | ||
|
||
for ENDPOINT in push pull_request pull_request_review | ||
do | ||
echo "creating endpoint ${ENDPOINT}" | ||
curl -XPOST \ | ||
https://api.github.com/repos/${FULLY_QUALIFIED_REPO_NAME}/hooks \ | ||
-H "Authorization: token ${TOKEN}" \ | ||
-d '{ "name": "web" | ||
, "config": { | ||
"url": "'${CALLBACK_URL}/${ENDPOINT}'" | ||
, "content_type": "json" | ||
} | ||
, "events": ["'${ENDPOINT}'"] | ||
}' | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,62 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
function cleanup { | ||
export REPO_NAME=ci-test-$(LC_CTYPE=C LC_ALL=C tr -dc 'a-z0-9' < /dev/urandom | head -c 8) | ||
export WATCHED_TARGETS='[["hail-ci-test/'${REPO_NAME}':master", true]]' | ||
|
||
set +x | ||
TOKEN=$(cat github-tokens/user1) | ||
set -x | ||
|
||
cleanup() { | ||
set - INT TERM | ||
set +e | ||
kill $(cat ci.pid) | ||
rm -rf ci.pid | ||
set +x | ||
curl -XDELETE \ | ||
https://api.github.com/repos/hail-ci-test/${REPO_NAME} \ | ||
-H "Authorization: token ${TOKEN}" | ||
set -x | ||
} | ||
trap cleanup EXIT | ||
|
||
export WATCHED_TARGETS='[["hail-is/ci-test:master", true]]' | ||
trap "exit 24" INT TERM | ||
|
||
# create the temp repo | ||
set +x | ||
curl -XPOST \ | ||
https://api.github.com/orgs/hail-ci-test/repos \ | ||
-H "Authorization: token ${TOKEN}" \ | ||
-d "{ \"name\" : \"${REPO_NAME}\" }" | ||
set -x | ||
|
||
# start CI system | ||
source activate hail-ci | ||
python ci/ci.py & echo $! > ci.pid | ||
sleep 5 | ||
PYTHONPATH=$PYTHONPATH:${PWD}/ci pytest -vv test/test-ci.py | ||
sleep 10 | ||
|
||
# upload files to temp repo | ||
# https://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x | ||
REPO_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') | ||
cp test-repo/* ${REPO_DIR} | ||
pushd ${REPO_DIR} | ||
git init | ||
git config user.email 'ci-automated-tests@broadinstitute.org' | ||
git config user.name 'ci-automated-tests' | ||
set +x | ||
git remote add origin \ | ||
https://${TOKEN}@github.com/hail-ci-test/${REPO_NAME}.git | ||
set -x | ||
git add * | ||
git commit -m 'inital commit' | ||
git push origin master:master | ||
popd | ||
|
||
# setup webhooks for temp repo | ||
set +x | ||
./setup-endpoints.sh hail-ci-test/${REPO_NAME} ${TOKEN} ${SELF_HOSTNAME} | ||
set -x | ||
|
||
export PYTHONPATH=$PYTHONPATH:${PWD}/ci | ||
pytest -vv test/test-ci.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
google/cloud-sdk:alpine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
uname -a | ||
mkdir -p artifacts/foo/bar | ||
cat <<EOF > artifacts/index.html | ||
<html> | ||
<body> | ||
<h1>Hello World!</h1> | ||
<a href='foo/bar/thing'>foo/bar/thing!</a> | ||
</body> | ||
</html> | ||
EOF | ||
cat <<EOF > artifacts/foo/bar/thing | ||
this is a thing | ||
thing thing thing | ||
thing a ding | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
set +ex | ||
|
||
gcloud auth activate-service-account \ | ||
--key-file=/secrets/ci-deploy-0-1--hail-is-ci-test.json | ||
|
||
DEPLOY_SHA=$(git rev-parse HEAD) | ||
gsutil ls gs://hail-ci-test/${DEPLOY_SHA} || ( | ||
git show HEAD > foo | ||
gsutil cp foo gs://hail-ci-test/$(git rev-parse HEAD) | ||
) |
Oops, something went wrong.