Skip to content

Commit

Permalink
CV2-4794-remove travis.yml for CI (#1961)
Browse files Browse the repository at this point in the history
* Migration from travis CI to Github Actions for tests
  • Loading branch information
chinelo-obitube authored Jul 22, 2024
1 parent 00add5d commit 010019d
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 105 deletions.
118 changes: 82 additions & 36 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- master
- develop
pull_request:
branches:
- develop
Expand Down Expand Up @@ -81,25 +82,40 @@ jobs:
chmod +w tmp/parallel_runtime_test.log
- name: Run Functional Tests
id: run-tests
id: functional-tests
env:
TEST_RETRY_COUNT: 3
run: |
docker-compose exec -e TEST_RETRY_COUNT=$TEST_RETRY_COUNT -T -e PATTERN='models mailers integration workers lib contract' api test/run-tests.sh
- name: After functional Tests
id: after-functional-tests
- name: After Functional Test
env:
GIT_SHA: ${{ github.sha }}
GIT_COMMITED_AT: ${{ github.event.head_commit.timestamp }}
run: |
docker-compose exec -T -e GIT_COMMIT_SHA=${{ github.sha }} \
-e GIT_COMMITTED_AT=${{ github.event.head_commit.timestamp }} \
GITHUB_PULL_REQUEST: ${{ github.event_name}}
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_REPO: ${{ github.repository }}
GITHUB_TEST_RESULT: ${{ steps.functional-tests.outcome}}
GITHUB_BUILD_NUMBER: ${{ github.run_number }}
GITHUB_COMMIT_SHA: ${{ github.sha }}
GITHUB_JOB_NAME: ${{ github.job }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
AWS_REGION: eu-west-1
run: |
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=$GITHUB_REPO \
-e GITHUB_BUILD_NUMBER=$GITHUB_BUILD_NUMBER \
-e GIT_COMMIT_SHA=$GITHUB_COMMIT_SHA \
-e CC_TEST_REPORTER_ID=$CC_TEST_REPORTER_ID \
-e PATH=$PATH \
-e JOB_NAME=functional-tests \
-e AWS_CONFIG_FILE=/app/credentials \
api test/test-coverage.sh
-e GITHUB_JOB_NAME=$GITHUB_JOB_NAME \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
-e ROLE_TO_ASSUME=$AWS_ROLE_TO_ASSUME \
-e AWS_REGION=$AWS_REGION \
-e AWS_CONFIG_FILE=/app/credentials api test/test-coverage.sh

unit-tests:
Expand Down Expand Up @@ -169,25 +185,40 @@ jobs:
chmod +w tmp/parallel_runtime_test.log
- name: Run Unit Tests
id: run-tests
id: unit-tests
env:
TEST_RETRY_COUNT: 3
run: |
docker-compose exec -e TEST_RETRY_COUNT=$TEST_RETRY_COUNT -T -e PATTERN='controllers contract' api test/run-tests.sh
- name: After unit Tests
id: unit-tests
- name: After Unit Test
env:
GIT_SHA: ${{ github.sha }}
GIT_COMMITED_AT: ${{ github.event.head_commit.timestamp }}
run: |
docker-compose exec -T -e GIT_COMMIT_SHA=${{ github.sha }} \
-e GIT_COMMITTED_AT=${{ github.event.head_commit.timestamp }} \
GITHUB_PULL_REQUEST: ${{ github.event_name}}
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_REPO: ${{ github.repository }}
GITHUB_TEST_RESULT: ${{ steps.unit-tests.outcome}}
GITHUB_BUILD_NUMBER: ${{ github.run_number }}
GITHUB_COMMIT_SHA: ${{ github.sha }}
GITHUB_JOB_NAME: ${{ github.job }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
AWS_REGION: eu-west-1
run: |
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=$GITHUB_REPO \
-e GITHUB_BUILD_NUMBER=$GITHUB_BUILD_NUMBER \
-e GIT_COMMIT_SHA=$GITHUB_COMMIT_SHA \
-e CC_TEST_REPORTER_ID=$CC_TEST_REPORTER_ID \
-e PATH=$PATH \
-e JOB_NAME=unit-tests \
-e AWS_CONFIG_FILE=/app/credentials \
api test/test-coverage.sh
-e GITHUB_JOB_NAME=$GITHUB_JOB_NAME \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
-e ROLE_TO_ASSUME=$AWS_ROLE_TO_ASSUME \
-e AWS_REGION=$AWS_REGION \
-e AWS_CONFIG_FILE=/app/credentials api test/test-coverage.sh
contract-tests:
Expand Down Expand Up @@ -265,17 +296,32 @@ jobs:
TEST_RETRY_COUNT: 3
run: |
docker-compose exec -e TEST_RETRY_COUNT=$TEST_RETRY_COUNT -T -e PATTERN='controllers models mailers integration workers lib' api test/run-tests.sh
- name: After contract Tests
id: after-tests
- name: After Contract Test
env:
GIT_SHA: ${{ github.sha }}
GIT_COMMITED_AT: ${{ github.event.head_commit.timestamp }}
run: |
docker-compose exec -T -e GIT_COMMIT_SHA=${{ github.sha }} \
-e GIT_COMMITTED_AT=${{ github.event.head_commit.timestamp }} \
GITHUB_PULL_REQUEST: ${{ github.event_name}}
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_REPO: ${{ github.repository }}
GITHUB_TEST_RESULT: ${{ steps.run-tests.outcome}}
GITHUB_BUILD_NUMBER: ${{ github.run_number }}
GITHUB_COMMIT_SHA: ${{ github.sha }}
GITHUB_JOB_NAME: ${{ github.job }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
AWS_REGION: eu-west-1
run: |
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=$GITHUB_REPO \
-e GITHUB_BUILD_NUMBER=$GITHUB_BUILD_NUMBER \
-e GIT_COMMIT_SHA=$GITHUB_COMMIT_SHA \
-e CC_TEST_REPORTER_ID=$CC_TEST_REPORTER_ID \
-e PATH=$PATH \
-e JOB_NAME=contract-tests \
-e AWS_CONFIG_FILE=/app/credentials \
api test/test-coverage.sh
-e GITHUB_JOB_NAME=$GITHUB_JOB_NAME \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
-e ROLE_TO_ASSUME=$AWS_ROLE_TO_ASSUME \
-e AWS_REGION=$AWS_REGION \
-e AWS_CONFIG_FILE=/app/credentials api test/test-coverage.sh
63 changes: 0 additions & 63 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions test/format-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

apt-get install -y awscli

if [ "$TRAVIS_PULL_REQUEST" == "false" ]
if [ "$GITHUB_PULL_REQUEST" == "pull_request" ]
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-github/codeclimate/$GITHUB_REPO/$GITHUB_BUILD_NUMBER/codeclimate.$GITHUB_JOB_NAME.json
fi

6 changes: 3 additions & 3 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" == "pull_request" ]] && [[ "$GITHUB_TEST_RESULT" == 'success' ]]
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-github/codeclimate/$GITHUB_REPO/$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 All @@ -15,7 +15,7 @@ then
sleep 5
size=$(du -s ../coverage/ | cut -f1)
done
./cc-test-reporter sum-coverage --output - --parts 3 ../coverage/codeclimate.* | sed 's/\/home\/travis\/build\/meedan\/check-api\///g' > ../coverage/codeclimate.json
./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
Expand Down

0 comments on commit 010019d

Please sign in to comment.