-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
CI: Add Coverage Analysis #68624
CI: Add Coverage Analysis #68624
Conversation
b29bd6b
to
88154fa
Compare
88154fa
to
ba07f4b
Compare
Please fix the CI issues |
3ef37a9
to
d462d57
Compare
Fixed. |
@gbarkadiusz why is this still in draft? |
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.
see https://github.com/zephyrproject-rtos/zephyr-testing/actions/runs/7891137291/workflow for a workflow file that works
.github/workflows/codecov.yaml
Outdated
with: | ||
name: Coverage Reports | ||
path: | | ||
coverage/reports/${{ steps.run_date.outputs.run_date_short }}.json |
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.
prefix file name with coverage-report
.github/workflows/codecov.yaml
Outdated
- name: Generate Coverage Report | ||
if: always() | ||
run: | | ||
pip install xlsxwriter, ijson, json, yaml |
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.
remove the comma, just leave xlsxwrite and ijson.
Why do you need ijson and json and why cant this all be accomplished with json module alone?
not blocking, I would consider using openpyxl for excel in the future, it is much more powerful.
.github/workflows/codecov.yaml
Outdated
pip install xlsxwriter, ijson, json, yaml | ||
cd ./coverage/reports | ||
../scripts/twister -E testplan.json | ||
python3 ../scripts/ci/coverage/coverage_analysis.py -t testplan.json -m ../MAINTAINERS.yml -c merged.json \ |
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.
this is wrong, use something like that instead:
- cd ./coverage/reports
- ../scripts/twister -E testplan.json
- python3 ../scripts/ci/coverage/coverage_analysis.py -t testplan.json -m ../MAINTAINERS.yml -c merged.json \
- -o ${{ steps.run_date.outputs.run_date_short }} -f all
+ ./scripts/twister -E testplan.json
+ python3 ./scripts/ci/coverage/coverage_analysis.py -t testplan.json -m MAINTAINERS.yml -c coverage/reports/merged.json \
+ -o coverage-report-${{ steps.run_date.outputs.run_date_short }} -f all
+ cp coverage-report-* coverage/reports/
+
for item in self.maintainers_file: | ||
_found_flag = False | ||
try: | ||
tests = self.maintainers_file[item]['tests'] |
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.
that will fail if an area does not have tests....
You should look into using the maintainer file parser, see scripts/get_maintainer.py
then
from get_maintainer import Maintainers
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.
Regarding this. I tried to use get_maintainer, but there is no functionality. Search the area according to the name of the tests.
AFAIK, this script provides the following functionalities:
Get area according to paths. get_maintainer path PATH_TO_FILE
Get a list of files regarding the area. get_maintainer list AREA
While creating the report, I'm based on the component's name instead of area. The component's name came from test_case name.
That's why, I used that workaround.
d462d57
to
1a128c9
Compare
.github/workflows/codecov.yaml
Outdated
if: always() | ||
run: | | ||
pip install xlsxwriter ijson | ||
./scripts/twister -E testplan.json |
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.
This will not work, please look at the workflow link I provided. running twister here requires a different runner, you do not have the dependencies needed for twister in the default runner. see https://github.com/zephyrproject-rtos/zephyr-testing/actions/runs/7891137291/workflow
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.
You're right. I needed to take a look at this part of workflow again.
771b0ee
to
c7f9001
Compare
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.
thw workflow will not work, you really need to take my changes from here: zephyrproject-rtos/zephyr-testing@c6f555a
I can also push those changes into this PR if you like
.github/workflows/codecov.yaml
Outdated
@@ -90,6 +90,7 @@ jobs: | |||
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr | |||
mkdir -p coverage/reports | |||
pip3 install gcovr==6.0 | |||
./scripts/twister -E testplan.json |
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.
this will not work, we will generate this for each platform, so we have later to deal with the same file name. Just pin it tot he platform name and later just pick one to avoid issues. see my workflow on zephyr-testing
c7f9001
to
dbcc207
Compare
If my changes are not enough to work properly this workflow. Please push those changes into this PR. I'd like to learn what I did wrong. |
dbcc207
to
ff83321
Compare
Extend codecov workflow to include coverage analysis. Signed-off-by: Arkadiusz Cholewinski <[email protected]> Signed-off-by: Anas Nashif <[email protected]>
ff83321
to
50854b8
Compare
Extend codecov workflow to include coverage analysis.
Coverage_analysis.py generates coverage report in both (json and xlsx) formats.
The generated report contains information about coverage per component, covered and uncovered functions.
Report.json
Moreover, this script parses Testplan.json generated by twister ( twister -E testplan.json ) to collect the data regarding all testsuites.
Report.xlsx