Skip to content

Instantly share code, notes, and snippets.

@quinn
Created May 15, 2018 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quinn/6ca0128fed3f837ce835ba9d8f8e0252 to your computer and use it in GitHub Desktop.
Save quinn/6ca0128fed3f837ce835ba9d8f8e0252 to your computer and use it in GitHub Desktop.
#!bin/bash
set -e
FILE_COUNT=0
check_env() {
if [ -z $CC_TEST_REPORTER_ID ]
then
echo "Please set CC_TEST_REPORTER_ID variable."
exit 1
fi
if [ -z $BUCKET_NAME ]
then
echo "Please set BUCKET_NAME variable."
exit 2
fi
if [ -z $AWS_ACCESS_KEY_ID ]
then
echo "Please set AWS_ACCESS_KEY_ID variable."
exit 3
fi
if [ -z $AWS_SECRET_ACCESS_KEY ]
then
echo "Please set AWS_SECRET_ACCESS_KEY variable."
exit 4
fi
}
copy_files() {
echo "Copying files to bucket..."
aws s3 cp $SEMAPHORE_PROJECT_DIR/integration-tests/codeclimate.$SEMAPHORE_CURRENT_JOB.json "s3://$BUCKET_NAME/coverage/$SEMAPHORE_BUILD_NUMBER/"
}
upload_files() {
echo "Uploading files to CodeClimate..."
./cc-test-reporter sum-coverage --output - --parts $SEMAPHORE_JOB_COUNT coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --input -
}
sync_files() {
echo "Syncing files..."
aws s3 sync "s3://$BUCKET_NAME/coverage/$SEMAPHORE_BUILD_NUMBER/" coverage/ 2>/dev/null
}
count_files() {
echo "Counting files..."
FILE_COUNT=$(ls -l coverage/codeclimate.*.json | wc -l)
}
main() {
check_env
copy_files
sync_files
count_files
if [ $FILE_COUNT -eq $SEMAPHORE_JOB_COUNT ]
then
upload_files
echo "Upload completed."
else
echo "Not all jobs are done. Waiting for others to finish..."
fi
}
main
#!bin/bash
set -e
check_env() {
if [ -z $CC_TEST_REPORTER_ID ]
then
echo "Please set CC_TEST_REPORTER_ID variable."
exit 1
fi
if [ -z $BUCKET_NAME ]
then
echo "Please set BUCKET_NAME variable."
exit 2
fi
if [ -z $AWS_ACCESS_KEY_ID ]
then
echo "Please set AWS_ACCESS_KEY_ID variable."
exit 3
fi
if [ -z $AWS_SECRET_ACCESS_KEY ]
then
echo "Please set AWS_SECRET_ACCESS_KEY variable."
exit 4
fi
}
setup_test_reporter() {
echo "Downloading test-reporter tool..."
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
echo "Making test-reporter tool executable..."
chmod +x cc-test-reporter
}
prepare_code_climate() {
echo "Preparing the CodeClimate for receiving coverage data..."
./cc-test-reporter before-build
}
main() {
check_env
setup_test_reporter
prepare_code_climate
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment