Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
fkorotkov committed Jun 28, 2019
1 parent 4678d21 commit 994e0cc
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions tests/test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ urlencode() {
echo "$1" | curl -Gso /dev/null -w %{url_effective} --data-urlencode @- "" | cut -c 3- | sed -e 's/%0A//'
}

TEST_DATA_GIT_COMMIT="180c0d097354fc1a451da8a3be5aba255f2ffd9f"

_SHA=$(git rev-parse HEAD)
_BRANCH=$(git rev-parse --abbrev-ref HEAD)
_BRANCH=$(urlencode $_BRANCH)
Expand Down Expand Up @@ -61,21 +63,21 @@ function test_fixes () {
function test_url_opt () {
reset
res=$(./codecov -d -u http://example.com | grep "http://example.com/")
diff <(echo "http://example.com/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=&flags=&pr=&job=") <(echo "$res")
diff <(echo "http://example.com/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&service=&flags=&pr=&job=") <(echo "$res")
assertTrue 'Expected output differs.' $?
}

function test_url_env () {
reset
res=$(CODECOV_URL="http://other.com" ./codecov -d | grep "http://other.com/")
diff <(echo "http://other.com/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=&flags=&pr=&job=") <(echo "$res")
diff <(echo "http://other.com/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&service=&flags=&pr=&job=") <(echo "$res")
assertTrue 'Expected output differs.' $?
}

function test_flags_opt () {
reset
res=$(./codecov -d -F f1 -F f2 | grep "https://codecov.io/")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=&flags=f1,f2&pr=&job=") <(echo "$res")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&service=&flags=f1,f2&pr=&job=") <(echo "$res")
assertTrue 'Expected output differs.' $?
}

Expand Down Expand Up @@ -104,15 +106,15 @@ function test_flags_opt () {
function test_build_arg () {
reset
res=$(./codecov -d -b 1.6 | grep "https://codecov.io/")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=1.6&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=&flags=&pr=&job=") <(echo "$res")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=1.6&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&service=&flags=&pr=&job=") <(echo "$res")
assertTrue 'Expected output differs.' $?
}

# function test_changes_merge_commit () {
# reset
# git commit --amend -m 'Merge 5d4123bcb99dd1bc9b5ae8b4271b39dbe4c3928b into 2f85ca252d69d6c52484f0c4b2e8500498228398'
# res=$(./codecov -d -b 1.6 | grep "https://codecov.io/")
# diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=5d4123bcb99dd1bc9b5ae8b4271b39dbe4c3928b&build=&build_url=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=&flags=&pr=&job=") <(echo "$res")
# diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=5d4123bcb99dd1bc9b5ae8b4271b39dbe4c3928b&build=&build_url=&tag=&slug=codecov%2Fcodecov-bash&service=&flags=&pr=&job=") <(echo "$res")
# assertTrue 'Expected output differs.' $?
# }

Expand Down Expand Up @@ -173,14 +175,14 @@ function test_env_env () {
function test_slug_opt () {
reset
res=$(./codecov -dr myowner/myrepo | grep "https://codecov.io/")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=myowner%2Fmyrepo&yaml=&service=&flags=&pr=&job=") <(echo "$res")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=myowner%2Fmyrepo&service=&flags=&pr=&job=") <(echo "$res")
assertTrue 'Expected output differs.' $?
}

function test_slug_env () {
reset
export CODECOV_SLUG="myowner/myrepo"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=myowner%2Fmyrepo&yaml=&service=&flags=&pr=&job="
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=$_BRANCH&commit=$TEST_DATA_GIT_COMMIT&build=&build_url=&name=&tag=&slug=myowner%2Fmyrepo&service=&flags=&pr=&job="
}

function test_gcov () {
Expand All @@ -198,14 +200,14 @@ function test_token_opt () {
reset
token="38cd42da-4df4-4760-a998-4ebeca536904"
res=$(./codecov -d -t "$token" | grep "https://codecov.io/")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=$token&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=&flags=&pr=&job=") <(echo "$res")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=$token&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&service=&flags=&pr=&job=") <(echo "$res")
assertTrue 'Expected output differs.' $?
}

function test_token_env () {
reset
res=$(CODECOV_TOKEN="38cd42da-4df4-4760-a998-4ebeca536904" ./codecov -d | grep "https://codecov.io/")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=$token&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=&flags=&pr=&job=") <(echo "$res")
diff <(echo "https://codecov.io/upload/v4?package=bash-tbd&token=$token&branch=$_BRANCH&commit=$_SHA&build=&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&service=&flags=&pr=&job=") <(echo "$res")
assertTrue 'Expected output differs.' $?
}

Expand All @@ -229,7 +231,7 @@ function test_token_env () {
# Test CI Companies
# -----------------
function assertURL () {
url=$(./codecov -d | grep 'https://codecov.io/')
url=$(./codecov -d -C ${TEST_DATA_GIT_COMMIT} | grep 'https://codecov.io/')
diff <(echo "$1") <(echo "$url")
assertTrue 'Expected output differs.' $?
}
Expand All @@ -240,59 +242,59 @@ function test_travis () {
export TRAVIS_JOB_ID="33116958"
export TRAVIS="true"
export TRAVIS_BRANCH="master"
export TRAVIS_COMMIT="c739768fcac68144a3a6d82305b9c4106934d31a"
export TRAVIS_COMMIT="$TEST_DATA_GIT_COMMIT"
export TRAVIS_REPO_SLUG='codecov/ci-repo'
export TRAVIS_JOB_ID="33116958"
export TRAVIS_PULL_REQUEST="false"
export TRAVIS_JOB_NUMBER="4.1"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=master&commit=c739768fcac68144a3a6d82305b9c4106934d31a&build=4.1&build_url=&name=&tag=&slug=codecov%2Fci-repo&yaml=&service=travis&flags=&pr=false&job=33116958"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=master&commit=$TEST_DATA_GIT_COMMIT&build=4.1&build_url=&name=&tag=&slug=codecov%2Fci-repo&service=travis&flags=&pr=false&job=33116958"
}

function test_jenkins (){
reset
export JENKINS_URL="something"
export GIT_BRANCH="develop"
export GIT_COMMIT="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
export GIT_COMMIT="$TEST_DATA_GIT_COMMIT"
export BUILD_NUMBER="15.1"
export BUILD_URL="http://endpoint"
export WORKSPACE="."
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=15.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=jenkins&flags=&pr=&job="
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=15.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&service=jenkins&flags=&pr=&job="
}

function test_jenkins_blue (){
reset
export JENKINS_URL="something"
export BRANCH_NAME="develop"
export CHANGE_ID="1"
export GIT_COMMIT="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
export GIT_COMMIT="$TEST_DATA_GIT_COMMIT"
export BUILD_NUMBER="15.1"
export BUILD_URL="http://endpoint"
export WORKSPACE="."
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=15.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=jenkins&flags=&pr=1&job="
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=15.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&service=jenkins&flags=&pr=1&job="
}

function test_bitrise (){
reset
export CI="true"
export BITRISE_IO="true"
export BITRISE_GIT_BRANCH="develop"
export GIT_CLONE_COMMIT_HASH="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
export GIT_CLONE_COMMIT_HASH="$TEST_DATA_GIT_COMMIT"
export BITRISE_BUILD_NUMBER="15.1"
export BITRISE_PULL_REQUEST="1"
export BITRISE_BUILD_URL="http://endpoint"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=15.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=bitrise&flags=&pr=1&job="
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=15.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&service=bitrise&flags=&pr=1&job="
}

function test_jenkins_vars (){
reset
export JENKINS_URL="something"
export ghprbSourceBranch="develop"
export ghprbActualCommit="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
export ghprbActualCommit="$TEST_DATA_GIT_COMMIT"
export BUILD_NUMBER="15.1"
export BUILD_URL="http://endpoint"
export WORKSPACE="."
export ghprbPullId="5"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=15.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=jenkins&flags=&pr=5&job="
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=15.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&service=jenkins&flags=&pr=5&job="
}

function test_codeship (){
Expand All @@ -302,8 +304,8 @@ function test_codeship (){
export CI_BRANCH="develop"
export CI_BUILD_NUMBER="12.1"
export CI_BUILD_URL="http://endpoint"
export CI_COMMIT_ID="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=12.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=codeship&flags=&pr=&job="
export CI_COMMIT_ID="$TEST_DATA_GIT_COMMIT"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=12.1&build_url=http%3A%2F%2Fendpoint&name=&tag=&slug=codecov%2Fcodecov-bash&service=codeship&flags=&pr=&job="
}


Expand All @@ -315,8 +317,8 @@ semaphore (){
export BRANCH_NAME="develop"
export SEMAPHORE_BUILD_NUMBER="8"
export SEMAPHORE_CURRENT_THREAD="2"
export REVISION="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=8&build_url=&name=&tag=&slug=myowner%2Fmyrepo&yaml=&service=semaphore&flags=&pr=&job=2"
export REVISION="$TEST_DATA_GIT_COMMIT"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=8&build_url=&name=&tag=&slug=myowner%2Fmyrepo&service=semaphore&flags=&pr=&job=2"
}

function test_buildkite (){
Expand All @@ -328,8 +330,8 @@ function test_buildkite (){
export BUILDKITE_BUILD_NUMBER="8"
export BUILDKITE_JOB_ID="1"
export BUILDKITE_BUILD_URL="http://buildkite"
export BUILDKITE_COMMIT="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=8&build_url=http%3A%2F%2Fbuildkite&name=&tag=&slug=myowner%2Fmyrepo&yaml=&service=buildkite&flags=&pr=&job=1"
export BUILDKITE_COMMIT="$TEST_DATA_GIT_COMMIT"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=8&build_url=http%3A%2F%2Fbuildkite&name=&tag=&slug=myowner%2Fmyrepo&service=buildkite&flags=&pr=&job=1"
}

function test_solano (){
Expand All @@ -338,8 +340,8 @@ function test_solano (){
export TDDIUM_CURRENT_BRANCH="develop"
export TDDIUM_TID="12311"
export TDDIUM_PR_ID="false"
export TDDIUM_CURRENT_COMMIT="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=12311&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=solano&flags=&pr=false&job="
export TDDIUM_CURRENT_COMMIT="$TEST_DATA_GIT_COMMIT"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=12311&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&service=solano&flags=&pr=false&job="
}

function test_drone (){
Expand All @@ -348,7 +350,7 @@ function test_drone (){
export DRONE_BRANCH="develop"
export DRONE_BUILD_NUMBER="7.5"
export DRONE_BUILD_LINK="http://drone"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$_SHA&build=7.5&build_url=http%3A%2F%2Fdrone&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=drone.io&flags=&pr=&job="
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=7.5&build_url=http%3A%2F%2Fdrone&name=&tag=&slug=codecov%2Fcodecov-bash&service=drone.io&flags=&pr=&job="
}

function test_appveyor (){
Expand All @@ -362,8 +364,8 @@ function test_appveyor (){
export APPVEYOR_ACCOUNT_NAME="a"
export APPVEYOR_PROJECT_SLUG="b"
export APPVEYOR_JOB_ID="9r2qufuu8"
export APPVEYOR_REPO_COMMIT="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=9r2qufuu8&build_url=&name=&tag=&slug=myowner%2Fmyrepo&yaml=&service=appveyor&flags=&pr=1&job=a%2Fb%2F1.2.3"
export APPVEYOR_REPO_COMMIT="$TEST_DATA_GIT_COMMIT"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=9r2qufuu8&build_url=&name=&tag=&slug=myowner%2Fmyrepo&service=appveyor&flags=&pr=1&job=a%2Fb%2F1.2.3"
}

function test_wercker (){
Expand All @@ -373,8 +375,8 @@ function test_wercker (){
export WERCKER_MAIN_PIPELINE_STARTED="12311"
export WERCKER_GIT_OWNER="myowner"
export WERCKER_GIT_REPOSITORY="myrepo"
export WERCKER_GIT_COMMIT="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=12311&build_url=&name=&tag=&slug=myowner%2Fmyrepo&yaml=&service=wercker&flags=&pr=&job="
export WERCKER_GIT_COMMIT="$TEST_DATA_GIT_COMMIT"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=12311&build_url=&name=&tag=&slug=myowner%2Fmyrepo&service=wercker&flags=&pr=&job="
}

function test_magnum (){
Expand All @@ -383,8 +385,8 @@ function test_magnum (){
export MAGNUM="true"
export CI_BRANCH="develop"
export CI_BUILD_NUMBER="12311"
export CI_COMMIT="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=12311&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&yaml=&service=magnum&flags=&pr=&job="
export CI_COMMIT="$TEST_DATA_GIT_COMMIT"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=12311&build_url=&name=&tag=&slug=codecov%2Fcodecov-bash&service=magnum&flags=&pr=&job="
}

function test_shippable (){
Expand All @@ -395,8 +397,8 @@ function test_shippable (){
export REPO_FULL_NAME="myowner/myrepo"
export BUILD_URL="http://shippable"
export PULL_REQUEST="2"
export COMMIT="180c0d097354fc1a451da8a3be5aba255f2ffd9f"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=180c0d097354fc1a451da8a3be5aba255f2ffd9f&build=1.2&build_url=http%3A%2F%2Fshippable&name=&tag=&slug=myowner%2Fmyrepo&yaml=&service=shippable&flags=&pr=2&job="
export COMMIT="$TEST_DATA_GIT_COMMIT"
assertURL "https://codecov.io/upload/v4?package=bash-tbd&token=&branch=develop&commit=$TEST_DATA_GIT_COMMIT&build=1.2&build_url=http%3A%2F%2Fshippable&name=&tag=&slug=myowner%2Fmyrepo&service=shippable&flags=&pr=2&job="
}


Expand Down

0 comments on commit 994e0cc

Please sign in to comment.