Skip to content

Commit

Permalink
closes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbradley committed Feb 23, 2017
1 parent e27db73 commit d1f8878
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
5 changes: 0 additions & 5 deletions docker/tester/pull-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ then
rm -rf "${cloneDir}"
fi

printf "Cloning $( echo "${repoUrl}" | sed 's/\(.*:\/\/\).*@\(.*\)/\1\2/' ).\n"
git clone "${repoUrl}" "${cloneDir}"
cd "${cloneDir}"

printf "Tracking branch:\n"
git branch -vv


# If a commit SHA is specified then detach the HEAD and point at the commit
if [[ -n "${commit}" ]]
then
Expand Down
6 changes: 4 additions & 2 deletions docker/tester/run-test-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ set -o nounset # exit if undeclared variable is used
githubApiKey=${1}
team=${2}
projectCommit=${3}
testImage=${4}
tempDir=${5}
projectBranch=${4}
testImage=${5}
tempDir=${6}

docker run --cap-add=NET_ADMIN \
--env PROJECT_URL=https://${githubApiKey}@github.com/CS310-2017Jan/cpsc310project_${team}.git \
--env PROJECT_COMMIT=$projectCommit \
--env PROJECT_BRANCH=$projectBranch \
--volume "${tempDir}":/output/ \
--rm \
${testImage}
12 changes: 9 additions & 3 deletions docker/tester/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# 1) Expects the deliverable repo exist in deliverableDir with up to date packages (node_modules)
# ##############################################################################

version=1.0.1
version=1.0.2


projectDir="/cpsc310project"
Expand All @@ -38,15 +38,21 @@ testsCmd="yarn run autotest"

date=$(date --utc +%FT%T.%3NZ)

printf "<INFO>\n%s\n%s\n</INFO exitcode=0, completed=%s, duration=0s>\n\n\n" "script version: ${version}" "test suite version: ${TESTSUITE_VERSION}" "${date}"
printf "<INFO>\nproject url: %s\nbranch: %s\ncommit: %s\nscript version: %s\ntest suite version: %s\n</INFO exitcode=0, completed=%s, duration=0s>\n\n\n" \
"$( echo "${PROJECT_URL}" | sed 's/\(.*:\/\/\).*@\(.*\)/\1\2/' )" \
"${PROJECT_BRANCH}" \
"${PROJECT_COMMIT}" \
"${version}" \
"${TESTSUITE_VERSION}" \
"${date}"


# Clone the specified student repo into the projectDir
# Exit if unable to clone the student's repo
printf "<PROJECT_PULL>\n"

startTime=$(date +%s)
./pull-repo.sh $@ "${projectDir}" 2>&1
./pull-repo.sh "${PROJECT_URL}" "${PROJECT_COMMIT}" "${projectDir}" 2>&1
status=$?
duration=$(($(date +%s) - $startTime))
date=$(date --utc +%FT%T.%3NZ)
Expand Down
7 changes: 4 additions & 3 deletions src/model/results/TestRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default class TestRecord implements DatabaseRecord {
this.githubToken,
this.team,
this.commit,
this.ref,
this.deliverable.image,
tempDir.path
];
Expand Down Expand Up @@ -241,12 +242,12 @@ export default class TestRecord implements DatabaseRecord {

public processInfoTag(stdout: string): any {
try {
let infoTagRegex: RegExp = /^<INFO>\nscript version: (.+)\ntest suite version: (.+)\n<\/INFO exitcode=(\d+), completed=(.+), duration=(\d+)s>$/gm
let infoTagRegex: RegExp = /^<INFO>\nproject url: (.+)\nbranch: (.+)\ncommit: (.+)\nscript version: (.+)\ntest suite version: (.+)\n<\/INFO exitcode=(\d+), completed=(.+), duration=(\d+)s>$/gm
//let infoMsgRegex: RegExp = /^(npm.*)$/gm;
let matches: string[] = infoTagRegex.exec(stdout);
let processed: any = {
scriptVersion: matches[1].trim(),
suiteVersion: matches[2].trim()
scriptVersion: matches[4].trim(),
suiteVersion: matches[5].trim()
};
return processed;
} catch (err) {
Expand Down

0 comments on commit d1f8878

Please sign in to comment.