-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce 95% unit test coverage for new code #1112
Open
farshidz
wants to merge
6
commits into
mainline
Choose a base branch
from
farshid/unit-test-coverage
base: mainline
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+123
−9
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e44cdf8
Enforce 95% unit test coverage for new code
farshidz 8ff3ed2
Upload diff coverage report
farshidz fd8f5a8
Add coverage workflow changes reverted accidentally in #1047
farshidz 64822ff
Update unit tests pipeline to print coverage and report
farshidz 11cdfc6
Fail workflow on step failure
farshidz b59d44c
Fail when tests fail
farshidz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,15 @@ permissions: | |
|
||
jobs: | ||
Test-Marqo: | ||
name: Run Unit Tests | ||
name: Run unit tests | ||
runs-on: ubuntu-latest | ||
environment: marqo-test-suite | ||
steps: | ||
- name: Checkout marqo repo | ||
- name: Check out marqo repo | ||
uses: actions/checkout@v3 | ||
with: | ||
path: marqo | ||
fetch-depth: 0 # Needed for diff coverage | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v3 | ||
|
@@ -49,14 +50,49 @@ jobs: | |
# override base requirements with marqo requirements, if needed: | ||
pip install -r marqo/requirements.dev.txt | ||
- name: Run Unit Tests | ||
- name: Run unit tests | ||
id: run_unit_tests | ||
continue-on-error: true | ||
run: | | ||
cd marqo | ||
export PYTHONPATH="./src" | ||
pytest tests/unit_tests/ --durations=100 --cov=src --cov-branch --cov-context=test --cov-report=html:cov_html --cov-report=lcov:lcov.info | ||
set -o pipefail | ||
pytest --durations=100 --cov=src --cov-branch --cov-context=test \ | ||
--cov-report=html:cov_html --cov-report=xml:cov.xml --cov-report term:skip-covered \ | ||
--md-report --md-report-flavor gfm --md-report-output pytest_result_summary.md \ | ||
tests/unit_tests/ | tee pytest_output.txt | ||
- name: Upload Test Report | ||
- name: Check new code coverage | ||
id: check_test_coverage | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
cd marqo | ||
diff-cover cov.xml --compare-branch=origin/${{ github.base_ref }} --fail-under=95 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If unit test coverage is enforced to be above 95, do we still need to keep the same check in unit_test_200gb_CI workflow? |
||
--html-report diff_cov.html --markdown-report diff_cov.md | ||
- name: Upload test report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: marqo-test-report | ||
path: marqo/cov_html/ | ||
path: | | ||
marqo/cov_html/ | ||
marqo/diff_cov.html | ||
- name: Test and coverage report summary | ||
run: | | ||
echo "# Test Summary" >> $GITHUB_STEP_SUMMARY | ||
cat marqo/pytest_result_summary.md >> $GITHUB_STEP_SUMMARY | ||
echo "# Coverage summary, slow tests and failed tests" >> $GITHUB_STEP_SUMMARY | ||
echo '```text' >> $GITHUB_STEP_SUMMARY | ||
awk '/---------- coverage:/ {flag=1} flag' marqo/pytest_output.txt >> $GITHUB_STEP_SUMMARY | ||
echo '```' >> $GITHUB_STEP_SUMMARY | ||
cat marqo/diff_cov.md >> $GITHUB_STEP_SUMMARY | ||
- name: Fail if tests or coverage failed | ||
if: ${{ steps.run_unit_tests.outcome == 'failure' || steps.check_test_coverage.outcome == 'failure' }} | ||
run: | | ||
echo "Tests or coverage checks failed. Marking job as failed." | ||
exit 1 | ||
shell: bash |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the plan going forward? Will we set separate coverage threshold for unit tests and integration tests? Or do we combine the coverage report and set one threshold for all the tests.