Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ pipeline:
- github_automation_api_key
- skip_check_membership
commands:
- echo ${DRONE_COMMIT_AUTHOR}
- echo $SKIP_CHECK_MEMBERSHIP
- if [ "$SKIP_CHECK_MEMBERSHIP" = "true" ]; then echo 'check-org-membership step skipped'; else /bin/bash -c '[[ ! $(curl --silent "https://api.github.com/orgs/vmware/members/${DRONE_COMMIT_AUTHOR}?access_token=$GITHUB_AUTOMATION_API_KEY") ]]'; fi
- tests/check-org-membership.sh
when:
status: success

Expand Down
32 changes: 32 additions & 0 deletions tests/check-org-membership.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Copyright 2020-2021 VMware, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -ex

echo ${DRONE_COMMIT_AUTHOR}
echo $SKIP_CHECK_MEMBERSHIP

if [ "$SKIP_CHECK_MEMBERSHIP" == "true" ]; then
echo 'check-org-membership step skipped'
exit 0
fi

if [ ! $(curl --silent -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" "https://api.github.com/orgs/vmware/members/${DRONE_COMMIT_AUTHOR}") ]; then
echo "checked origin membership successfully"
else
echo "failed to check origin membership"
exit 1
fi
2 changes: 1 addition & 1 deletion tests/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set -x
buildinfo=$(drone build info vmware/vic $DRONE_BUILD_NUMBER)
prNumber=$(drone build info --format "{{ .Ref }}" vmware/vic $DRONE_BUILD_NUMBER | cut -f 3 -d'/')
set +x
prBody=$(curl https://api.github.com/repos/vmware/vic/pulls/$prNumber?access_token=$GITHUB_AUTOMATION_API_KEY | jq -r ".body")
prBody=$(curl -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" https://api.github.com/repos/vmware/vic/pulls/$prNumber | jq -r ".body")

if (echo $prBody | grep -q "\[fast fail\]"); then
export FAST_FAILURE=1
Expand Down
4 changes: 2 additions & 2 deletions tests/pass-rate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# sprint calendar in each new calendar year.
sprint_start=$(gdate -d "last wednesday-$(( ($(gdate +%W 2>/dev/null)+0)%2 )) weeks" "+%Y-%m-%dT%H:%M:%S" 2>/dev/null) || sprint_start=$(date -d "last wednesday-$(( ($(date +%W)+0)%2 )) weeks" "+%Y-%m-%dT%H:%M:%S")

commits=$(curl -s https://api.github.com/repos/vmware/vic/commits?access_token=$GITHUB_AUTOMATION_API_KEY\&since=$sprint_start | jq -r ' map(.sha) | join(",")')
curl -s https://api.github.com/repos/vmware/vic/status/{$commits}?access_token=$GITHUB_AUTOMATION_API_KEY | jq '.statuses[] | select(.context == "continuous-integration/vic/push") | "\(.target_url): \(.state)"' | tee status.out
commits=$(curl -s -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" https://api.github.com/repos/vmware/vic/commits?since=$sprint_start | jq -r ' map(.sha) | join(",")')
curl -s -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" https://api.github.com/repos/vmware/vic/status/{$commits} | jq '.statuses[] | select(.context == "continuous-integration/vic/push") | "\(.target_url): \(.state)"' | tee status.out

failures=$(cat status.out | grep -c failure)
successes=$(cat status.out | grep -c success)
Expand Down
6 changes: 3 additions & 3 deletions tests/resources/Github-Util.robot
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Get State Of Github Issue
[Arguments] ${num}
[Tags] secret
:FOR ${idx} IN RANGE 0 5
\ ${status} ${result}= Run Keyword And Ignore Error Get https://api.github.com/repos/vmware/vic/issues/${num}?access_token\=%{GITHUB_AUTOMATION_API_KEY}
\ ${status} ${result}= Run Keyword And Ignore Error Get https://api.github.com/repos/vmware/vic/issues/${num} headers={"Authorization": "token %{GITHUB_AUTOMATION_API_KEY}"}
\ Exit For Loop If '${status}'
\ Sleep 1
Should Be Equal ${result.status_code} ${200}
Expand All @@ -31,7 +31,7 @@ Post Comment To Github Issue
[Arguments] ${num} ${comment}
[Tags] secret
:FOR ${idx} IN RANGE 0 5
\ ${status} ${result}= Run Keyword And Ignore Error Post https://api.github.com/repos/vmware/vic/issues/${num}/comments?access_token\=%{GITHUB_AUTOMATION_API_KEY} data={"body": "${comment}"}
\ ${status} ${result}= Run Keyword And Ignore Error Post https://api.github.com/repos/vmware/vic/issues/${num}/comments data={"body": "${comment}"} headers={"Authorization": "token %{GITHUB_AUTOMATION_API_KEY}"}
\ Exit For Loop If '${status}'
\ Sleep 1
Should Be Equal ${result.status_code} ${201}
Expand All @@ -40,7 +40,7 @@ Check VMware Organization Membership
[Arguments] ${username}
[Tags] secret
:FOR ${idx} IN RANGE 0 5
\ ${status} ${result}= Run Keyword And Ignore Error Get https://api.github.com/orgs/vmware/members/${username}?access_token\=%{GITHUB_AUTOMATION_API_KEY}
\ ${status} ${result}= Run Keyword And Ignore Error Get https://api.github.com/orgs/vmware/members/${username} headers={"Authorization": "token %{GITHUB_AUTOMATION_API_KEY}"}
\ Exit For Loop If '${status}'
\ Sleep 1
${isMember}= Run Keyword And Return Status Should Be Equal ${result.status_code} ${204}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-test-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
set -e -o pipefail +h && [ -n "$DEBUG" ] && set -x

prNumber=$(drone build info --format "{{ .Ref }}" vmware/vic "${DRONE_BUILD_NUMBER}" | cut -f 3 -d'/')
prBody=$(curl "https://api.github.com/repos/vmware/vic/pulls/${prNumber}?access_token=${GITHUB_AUTOMATION_API_KEY}" | jq -r ".body")
prBody=$(curl -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" "https://api.github.com/repos/vmware/vic/pulls/${prNumber}" | jq -r ".body")

if ! (echo "${prBody}" | grep -q "\[skip unit\]"); then
make test
Expand Down