Skip to content

Commit

Permalink
rewrite coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
chinelo-obitube authored and chinelo-obitube committed Jul 21, 2024
1 parent 0ac1dc2 commit 270929b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ jobs:
# - name: Give test coverage reporter executable permissions
# run: chmod +x /test/cc-test-reporter

- name: Save coverage
- name: After coverage Test
env:
GIT_SHA: ${{ github.sha }}
GITHUB_PULL_REQUEST: 'false'
GITHUB_PULL_REQUEST: {{ github.event_name}}
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_REPO_SLUG: ${{ github.repository }}
GITHUB_TEST_RESULT: 0
GITHUB_TEST_RESULT: ${{ steps.run-tests.outcome}}
GITHUB_BUILD_NUMBER: ${{ github.run_number }}
GITHUB_COMMIT_SHA: ${{ github.sha }}
GITHUB_JOB_NAME: ${{ github.job }}
Expand Down
7 changes: 4 additions & 3 deletions test/format-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash

# apt-get install -y awscli
apt-get install -y awscli

# if [ "$GITHUB_PULL_REQUEST" == "false" ]
# then
if [ "$GITHUB_PULL_REQUEST" != "pull_request" ]
then
./test/cc-test-reporter format-coverage -t simplecov --output ../coverage/codeclimate.$GITHUB_JOB_NAME.json ../coverage/.resultset.json
aws s3 cp ../coverage/codeclimate.$GITHUB_JOB_NAME.json s3://check-api-travis/codeclimate/$GITHUB_REPO_SLUG/$GITHUB_BUILD_NUMBER/codeclimate.$GITHUB_JOB_NAME.json
fi

# #!/bin/bash

Expand Down
2 changes: 1 addition & 1 deletion test/sum-upload-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

if [[ "$GITHUB_PULL_REQUEST" == "false" ]] && [[ $GITHUB_TEST_RESULT == 0 ]]
if [[ "$GITHUB_PULL_REQUEST" != "pull_request" ]] && [[ $GITHUB_TEST_RESULT == 'success' ]]
then
rm -rf ../coverage/*
aws s3 cp --recursive s3://check-api-travis/codeclimate/$GITHUB_REPO_SLUG/$GITHUB_BUILD_NUMBER/ ../coverage
Expand Down
66 changes: 40 additions & 26 deletions test/test-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
# #!/bin/bash

# apt-get install -y golang-go golang-glide
# printf '#!/bin/bash\ngo run /tmp/go/src/github.com/codeclimate/test-reporter/main.go $@\n' > test/cc-test-reporter && chmod +x test/cc-test-reporter
# export GOPATH=/tmp/go
# git config --global --add safe.directory /app
# mkdir -p /tmp/go/src/github.com/codeclimate
# git clone -b 0.10.3 https://github.com/codeclimate/test-reporter /tmp/go/src/github.com/codeclimate/test-reporter
# cd /tmp/go/src/github.com/codeclimate/test-reporter
# go mod init github.com/codeclimate/test-reporter
# go mod tidy
# apt install -y awscli
# cd -
# ./test/cc-test-reporter format-coverage -t simplecov --output ../coverage/codeclimate.$GITHUB_JOB_NAME.json ../coverage/.resultset.json
# aws s3 cp ../coverage/codeclimate.$GITHUB_JOB_NAME.json s3://check-api-travis/codeclimate/$GITHUB_REPO_SLUG/$GITHUB_BUILD_NUMBER/codeclimate.$GITHUB_JOB_NAME.json
# echo 'Combining and uploading coverage...' && cd test
# rm -rf ../coverage/*
# aws s3 cp --recursive s3://check-api-travis/codeclimate/$GITHUB_REPO_SLUG/$GITHUB_BUILD_NUMBER/ ../coverage
# if [[ $(ls ../coverage/codeclimate.* | wc -l) -eq 3 ]]
# then
# # Make sure we are not dealing with a file that is still being uploaded
# previous_size=0
# size=$(du -s ../coverage/ | cut -f1)
# while [ $size -gt $previous_size ]
# do
# previous_size=$size
# sleep 5
# size=$(du -s ../coverage/ | cut -f1)
# done
# ./cc-test-reporter sum-coverage --output - --parts 3 ../coverage/codeclimate.* | sed 's/\/home\/runner\/work\/check-api\///g' > ../coverage/codeclimate.json
# cat ../coverage/codeclimate.json | ./cc-test-reporter upload-coverage --input -
# ./cc-test-reporter show-coverage ../coverage/codeclimate.json
# fi
# cd -
# echo 'Parallel tests runtime log' && cat tmp/parallel_runtime_test.log



#!/bin/bash

apt-get install -y golang-go golang-glide
Expand All @@ -6,30 +44,6 @@ export GOPATH=/tmp/go
git config --global --add safe.directory /app
mkdir -p /tmp/go/src/github.com/codeclimate
git clone -b 0.10.3 https://github.com/codeclimate/test-reporter /tmp/go/src/github.com/codeclimate/test-reporter
cd /tmp/go/src/github.com/codeclimate/test-reporter
go mod init github.com/codeclimate/test-reporter
go mod tidy
apt install -y awscli
cd -
./test/cc-test-reporter format-coverage -t simplecov --output ../coverage/codeclimate.$GITHUB_JOB_NAME.json ../coverage/.resultset.json
aws s3 cp ../coverage/codeclimate.$GITHUB_JOB_NAME.json s3://check-api-travis/codeclimate/$GITHUB_REPO_SLUG/$GITHUB_BUILD_NUMBER/codeclimate.$GITHUB_JOB_NAME.json
echo 'Combining and uploading coverage...' && cd test
rm -rf ../coverage/*
aws s3 cp --recursive s3://check-api-travis/codeclimate/$GITHUB_REPO_SLUG/$GITHUB_BUILD_NUMBER/ ../coverage
if [[ $(ls ../coverage/codeclimate.* | wc -l) -eq 3 ]]
then
# Make sure we are not dealing with a file that is still being uploaded
previous_size=0
size=$(du -s ../coverage/ | cut -f1)
while [ $size -gt $previous_size ]
do
previous_size=$size
sleep 5
size=$(du -s ../coverage/ | cut -f1)
done
./cc-test-reporter sum-coverage --output - --parts 3 ../coverage/codeclimate.* | sed 's/\/home\/runner\/work\/check-api\///g' > ../coverage/codeclimate.json
cat ../coverage/codeclimate.json | ./cc-test-reporter upload-coverage --input -
./cc-test-reporter show-coverage ../coverage/codeclimate.json
fi
cd -
./test/format-coverage.sh
echo 'Combining and uploading coverage...' && cd test && ./sum-upload-coverage.sh && cd -
echo 'Parallel tests runtime log' && cat tmp/parallel_runtime_test.log

0 comments on commit 270929b

Please sign in to comment.