Skip to content

Commit

Permalink
fix tests-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
chinelo-obitube authored and chinelo-obitube committed Jul 20, 2024
1 parent d771745 commit 8099bf4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
41 changes: 17 additions & 24 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,30 +271,23 @@ jobs:
id: after-tests
env:
GIT_SHA: ${{ github.sha }}
GITHUB_PULL_REQUEST: ${{ github.event.pull_request.number || 0 }}
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_REPO_SLUG: ${{ github.repository }}
GITHUB_TEST_RESULT: 0
GITHUB_BUILD_NUMBER: ${{ github.run_number }}
GITHUB_COMMIT_SHA: ${{ github.sha }}
GITHUB_JOB_NAME: ${{ job.name }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
docker-compose exec -T -e GIT_COMMIT_SHA=${{ github.sha }} \
docker-compose exec -T \
-e GIT_BRANCH=$GIT_BRANCH \
-e GITHUB_PULL_REQUEST=$GITHUB_PULL_REQUEST \
-e GITHUB_TEST_RESULT=$GITHUB_TEST_RESULT \
-e GITHUB_REPO_SLUG=$GITHUB_REPO_SLUG \
-e GITHUB_BUILD_NUMBER=$ GITHUB_BUILD_NUMBER \
-e GIT_COMMIT_SHA=$GITHUB_COMMIT_SHA \
-e CC_TEST_REPORTER_ID=$CC_TEST_REPORTER_ID \
-e GITHUB_REF_NAME=${{ github.head_ref || github.ref_name }} \
-e GITHUB_PULL_REQUEST=${{ github.event.pull_request.number || 0 }} \
-e GITHUB_JOB=${{ github.job }} \
-e AWS_CONFIG_FILE=/app/credentials \
api test/test-coverage.sh
- name: Generate coverage report
run: |
docker-compose exec -T -e CC_TEST_REPORTER_ID=${{ secrets.CC_TEST_REPORTER_ID }} \
-e GIT_COMMIT_SHA=${{ github.sha }} \
-e GITHUB_REF_NAME=${{ github.head_ref || github.ref_name }} \
-e AWS_CONFIG_FILE=/app/credentials \
api test/test-coverage.sh \
-t simplecov -o coverage/codeclimate.json
- name: Upload coverage report to Code Climate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
docker-compose exec -e -T CC_TEST_REPORTER_ID=${{ secrets.CC_TEST_REPORTER_ID }} \
-e GIT_COMMIT_SHA=${{ github.sha }} \
-e GITHUB_REF_NAME=${{ github.head_ref || github.ref_name }} \
-e GITHUB_JOB_NAME=$GITHUB_JOB_NAME \
-e AWS_CONFIG_FILE=/app/credentials \
api test/test-coverage.sh \
api test/test-coverage.sh
6 changes: 3 additions & 3 deletions test/format-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

apt-get install -y awscli

if [ "$TRAVIS_PULL_REQUEST" == "false" ]
if [ "$GITHUB_PULL_REQUEST" == "false" ]
then
./test/cc-test-reporter format-coverage -t simplecov --output ../coverage/codeclimate.$TRAVIS_JOB_NAME.json ../coverage/.resultset.json
aws s3 cp ../coverage/codeclimate.$TRAVIS_JOB_NAME.json s3://check-api-travis/codeclimate/$TRAVIS_REPO_SLUG/$TRAVIS_BUILD_NUMBER/codeclimate.$TRAVIS_JOB_NAME.json
./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
4 changes: 2 additions & 2 deletions test/sum-upload-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

if [[ "$TRAVIS_PULL_REQUEST" == "false" ]] && [[ $TRAVIS_TEST_RESULT == 0 ]]
if [[ "$GITHUB_PULL_REQUEST" == "false" ]] && [[ $GITHUB_TEST_RESULT == 0 ]]
then
rm -rf ../coverage/*
aws s3 cp --recursive s3://check-api-travis/codeclimate/$TRAVIS_REPO_SLUG/$TRAVIS_BUILD_NUMBER/ ../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
Expand Down

0 comments on commit 8099bf4

Please sign in to comment.