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

[CI] Add Codecov and Test Logs #1349

Merged
merged 18 commits into from
Sep 8, 2020
Merged
51 changes: 48 additions & 3 deletions .github/workflows/unittests-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,62 @@ jobs:
- name: Test project on AWS Batch(For push)
if: ${{ github.event_name == 'push' }}
run: |
python ./tools/batch/submit-job.py --region us-east-1 --job-type g4dn.4x --source-ref ${{ github.ref }} --work-dir tools/batch --remote https://github.com/${{ github.repository }} --command "./batch_states/test.sh" --wait | tee > script.log
echo "Start submitting job"
python ./tools/batch/submit-job.py --region us-east-1 \
--job-type g4dn.4x \
--name GluonNLP-${{ github.ref }}-${{ github.run_id }} \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the ref contain PR number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For push event, ${{ github.ref }} will only contain the branch name the pr merged to, like 'master'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having the PR number in the job name will help identify them in AWS batch

--source-ref ${{ github.ref }} \
--work-dir tools/batch \
--save-path temp \
--remote https://github.com/${{ github.repository }} \
--command "./batch_states/test.sh | tee > ./script.log" \
--wait | tee > temp.log


- name: Test project on AWS Batch(For pull request)
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
run: |
python ./tools/batch/submit-job.py --region us-east-1 --job-type g4dn.4x --source-ref ${{ github.event.pull_request.head.ref }} --work-dir tools/batch --remote https://github.com/${{ github.event.pull_request.head.repo.full_name }} --command "./batch_states/test.sh" --wait | tee > script.log
echo "Start submitting job"
python ./tools/batch/submit-job.py --region us-east-1 \
--job-type g4dn.4x \
--name GluonNLP-${{ github.ref }}-${{ github.run_id }} \
--source-ref ${{ github.event.pull_request.head.ref }} \
--work-dir tools/batch \
--save-path temp \
--remote https://github.com/${{ github.event.pull_request.head.repo.full_name }} \
--command "./batch_states/test.sh | tee > ./script.log" \
--wait | tee > temp.log

- name: Wait for job and copy files from AWS s3
if: ${{ failure() || success() }}
run: |
head -100 temp.log | grep -oP -m 1 'jobId: \K(.*)' > jobid.log

echo "Job ID is"
cat jobid.log

cat jobid.log | xargs -i python ./tools/batch/wait-job.py --job-id {}

echo "Copy Codecov file"
cat jobid.log | xargs -i aws s3api wait object-exists --bucket gluon-nlp-dev --key batch/{}/temp/coverage.xml
cat jobid.log | xargs -i aws s3 cp s3://gluon-nlp-dev/batch/{}/temp/coverage.xml ./coverage.xml

echo "Copy log file"
cat jobid.log | xargs -i aws s3api wait object-exists --bucket gluon-nlp-dev --key batch/{}/temp/script.log
cat jobid.log | xargs -i aws s3 cp s3://gluon-nlp-dev/batch/{}/temp/script.log ./script.log

- name: Upload coverage to Codecov
if: ${{ failure() || success() }}
uses: codecov/[email protected]
with:
env_vars: OS,PYTHON
file: ./coverage.xml

- name: Upload log file for AWS Batch test results
if: ${{ failure() || success() }}
uses: actions/upload-artifact@v2
with:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe have an output folder where tests can dump outputs to, and then always expose that folder as artifact? This should help simplify maintenance for managing build artifacts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean redirect the test results as stdout and stderr to different files in a folder and then upload this folder as build artifact so that the developers can access it through github workflow's artifacts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes exactly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, I think both look fine and we may merge this is first and improve later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean redirect the test results as stdout and stderr to different files in a folder and then upload this folder as build artifact so that the developers can access it through github workflow's artifacts.

yes exactly.

That's the existing practice in 0.x but doesn't work well as it doesn't capture errors outside the immediate test execution. Instead, we need to capture the full cloudwatch log.

name: GPU_Test_Results
path: script.log
path: ./script.log