Skip to content
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

Running tests together on github-actions. #4108

Merged
merged 5 commits into from
May 27, 2024

Conversation

prady0t
Copy link
Contributor

@prady0t prady0t commented May 24, 2024

Description

Running unit and integration tests together for speedup.

Fixes #4099

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

I guess this duplicates the coverage job but we can look at this further here itself, could you please fix the conflicts first before I leave another review?

.github/workflows/test_on_push.yml Outdated Show resolved Hide resolved
@prady0t
Copy link
Contributor Author

prady0t commented May 25, 2024

I guess this duplicates the coverage job but we can look at this further here itself, could you please fix the conflicts first before I leave another review?

Using the exclude block would have resulted in integration tests also getting excluded. Can we also run coverage test together with this?

@agriyakhetarpal
Copy link
Member

agriyakhetarpal commented May 25, 2024

Using the exclude block would have resulted in integration tests also getting excluded. Can we also run coverage test together with this?

You can do something like

      - name: Run unit/coverage and integration tests
        run: |
          if [ ${{ matrix.python-version }} == "3.12" && ${{ matrix.os }} == "ubuntu-latest" ]; then
            python -m nox -s coverage
          else
            python -m nox -s unit
          fi
          python -m nox -s integration

and then include the excluded Linux 3.12 job. You might need to either add shell: bash to the step or adjust the syntax for pwsh on Windows (former is better)

Copy link

codecov bot commented May 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.54%. Comparing base (6ba81b7) to head (4077c31).

Current head 4077c31 differs from pull request most recent head eb586f0

Please upload reports for the commit eb586f0 to get more accurate results.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4108   +/-   ##
========================================
  Coverage    99.54%   99.54%           
========================================
  Files          287      287           
  Lines        21753    21753           
========================================
  Hits         21655    21655           
  Misses          98       98           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@prady0t
Copy link
Contributor Author

prady0t commented May 25, 2024

Using the exclude block would have resulted in integration tests also getting excluded. Can we also run coverage test together with this?

You can do something like

      - name: Run unit/coverage and integration tests
        run: |
          if [ ${{ matrix.python-version }} == "3.12" && ${{ matrix.os }} == "ubuntu-latest" ]; then
            python -m nox -s coverage
          else
            python -m nox -s unit
          fi
          python -m nox -s integration

and then include the excluded Linux 3.12 job. You might need to either add shell: bash to the step or adjust the syntax for pwsh on Windows (former is better)

Wouldn't the above if else condition already do the job? Do we still need to add "exclude block" after this?

@agriyakhetarpal
Copy link
Member

Wouldn't the above if else condition already do the job? Do we still need to add "exclude block" after this?

We're referring to the same thing, yes – "include the excluded block" would be the same as not excluding it. We can then move the coverage upload step to this job and run it with an if: condition.

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

Thanks, @prady0t! Looks all good to me. The Windows integration tests look like they were on a slower runner, and we can't do much about this until we migrate all the integration tests to pytest and thereby make use of pytest-xdist. I'll merge this in a while if there are no objections.

For additional context for any other reviewers: we can receive 12 or so concurrent jobs from GitHub runners on a free plan, so requesting 40 or so jobs means we need to wait until some of them pass in order to run further requested jobs, which meant that we were not benefiting from the parallelisation between unit and integration tests. With this PR, the number of requested jobs is now 24 (including the style and the link checkers).

@kratman kratman merged commit b972782 into pybamm-team:develop May 27, 2024
24 checks passed
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this pull request Aug 12, 2024
* Running tests together

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>

* Running coverage tests together as well

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>

* Added if condition to coverage tests

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>

* Running integration tests as a seperate step

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>

---------

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Co-authored-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run unit tests and integration tests together to speed up PR builds
3 participants