Skip to content

Add running the unittests to the GitHub workflow#321

Open
Zubair Maalick (zmaalick) wants to merge 41 commits into
mainfrom
165_add_unittest_in_github_workflow
Open

Add running the unittests to the GitHub workflow#321
Zubair Maalick (zmaalick) wants to merge 41 commits into
mainfrom
165_add_unittest_in_github_workflow

Conversation

@zmaalick
Copy link
Copy Markdown
Collaborator

@zmaalick Zubair Maalick (zmaalick) commented Jan 8, 2026

Closes #165 .

PR creation checklist for the developer

  • Has <issue_number> above ☝️ been replaced with the issue number?
  • Has main been selected as the base branch?
  • Does the feature branch name follow the format <issue_number>_<short_description_of_feature>?
  • Does the text of the PR title exactly match with the text (not including the issue number) of the issue title?
  • Have appropriate reviewers been added to the PR (once it is ready for review)?
  • Has the PR been assigned to the developer(s)?
  • Have the same labels as on the issue (except for the good first issue label) been added to the PR?
  • Has the Climate Model Evaluation Workflow (CMEW) project been added to the PR?
  • Has the appropriate milestone been added to the PR?

Definition of Done for the developer

  • Does the change in this PR address the above issue / have all acceptance criteria been met?
  • Does the change in this PR follow the requirements in the wiki: Developer Guide (including copyrights)?
  • Have new tests related to the change been added?
  • Do all the GitHub workflow checks pass?
  • Do all the tests run locally and pass? (Note: the tests are not run by the GitHub workflow, see wiki: Run the tests locally)
  • Has the API documentation (e.g. docstrings in Python modules) related to the change been updated appropriately?
  • Has the user documentation (i.e. everything in the doc directory) related to the change been updated appropriately, including the Quick Start section?
  • Do the HTML pages render correctly? (See wiki: Build the documentation locally)

PR creation checklist for the reviewer

  • Has <issue_number> above ☝️ been replaced with the issue number?
  • Has main been selected as the base branch?
  • Does the feature branch name follow the format <issue_number>_<short_description_of_feature>?
  • Does the text of the PR title exactly match with the text (not including the issue number) of the issue title?
  • Have appropriate reviewers been added to the PR (once it is ready for review)?
  • Has the PR been assigned to the developer(s)?
  • Have the same labels as on the issue (except for the good first issue label) been added to the PR?
  • Has the Climate Model Evaluation Workflow (CMEW) project been added to the PR?
  • Has the appropriate milestone been added to the PR?

Definition of Done for the reviewer

  • Does the change in this PR address the above issue / have all acceptance criteria been met?
  • Does the change in this PR follow the requirements in the wiki: Developer Guide (including copyrights)?
  • Have new tests related to the change been added? N/A
  • Do all the GitHub workflow checks pass?
  • Do all the tests run locally and pass? (Note: the tests are not run by the GitHub workflow, see wiki: Run the tests locally)
  • Has the API documentation (e.g. docstrings in Python modules) related to the change been updated appropriately? N/A
  • Has the user documentation (i.e. everything in the doc directory) related to the change been updated appropriately including the Quick Start section? N/A
  • Do the HTML pages render correctly? (See wiki: Build the documentation locally)

@zmaalick Zubair Maalick (zmaalick) added good first issue Good for newcomers quality assurance Anything related to Quality Assurance (QA) testing Anything related to testing labels Jan 8, 2026
Copy link
Copy Markdown
Contributor

@mo-nikosbaltas mo-nikosbaltas left a comment

Choose a reason for hiding this comment

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

Although the unit tests block is correct and works, my suggestion is:
Instead of:

eval "$(conda shell.bash hook)"
conda activate cmew
...

Use conda run:
conda run -n cmew cylc validate -O metoffice -O unittest .

This eliminates shell activation issues and is more reliable in Actions.
This also applies to other tests in this file.
As already said this is a suggestion.

     - name: Run Cylc unit tests
        run: |
          cd CMEW
          conda run -n cmew cylc vip -O metoffice -O unittest .

Although not applicable for this issue I would suggest to include some logging by adding at the end:

      - name: Upload cylc-run logs on failure
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: cylc-run-logs
          path: ~/cylc-run

Otherwise it is all good for me.

@mo-nikosbaltas
Copy link
Copy Markdown
Contributor

The unit tests should read:

     - name: Run Cylc unit tests
        run: |
          cd CMEW
          conda run -n cmew cylc vip -O metoffice -O unittest .

not
conda run -n cmew cylc validate -O metoffice -O unittest .

In my previous comment I was giving an example for 'cylc validate'. Sorry if I confused you. Also the checks failed when pushing. Can you correct?

@zmaalick
Copy link
Copy Markdown
Collaborator Author

Although the unit tests block is correct and works, my suggestion is: Instead of:

eval "$(conda shell.bash hook)"
conda activate cmew
...

Use conda run: conda run -n cmew cylc validate -O metoffice -O unittest .

This eliminates shell activation issues and is more reliable in Actions. This also applies to other tests in this file. As already said this is a suggestion.

     - name: Run Cylc unit tests
        run: |
          cd CMEW
          conda run -n cmew cylc vip -O metoffice -O unittest .

Although not applicable for this issue I would suggest to include some logging by adding at the end:

      - name: Upload cylc-run logs on failure
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: cylc-run-logs
          path: ~/cylc-run

Otherwise it is all good for me.

Made the changes and also added the logging. Working fine.

@mo-nikosbaltas mo-nikosbaltas self-requested a review January 12, 2026 12:06
Copy link
Copy Markdown
Contributor

@mo-nikosbaltas mo-nikosbaltas left a comment

Choose a reason for hiding this comment

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

Modify PR title to : #321: Add running the unittests to the GitHub workflow. See https://github.com/MetOffice/CMEW/wiki/Detailed-Working-Practices#create-a-pull-request

@zmaalick Zubair Maalick (zmaalick) changed the title add unitests in github workflow Add running the unittests to the GitHub workflow Jan 12, 2026
@zmaalick
Copy link
Copy Markdown
Collaborator Author

Modify PR title to : #321: Add running the unittests to the GitHub workflow. See https://github.com/MetOffice/CMEW/wiki/Detailed-Working-Practices#create-a-pull-request

Done

@mo-nikosbaltas
Copy link
Copy Markdown
Contributor

Also, Zubair Maalick (@zmaalick) can you change the copyright years (# (C) Crown Copyright 2022-2025, Met Office.) in the file to 2022-2026.

@mo-nikosbaltas mo-nikosbaltas self-requested a review January 12, 2026 13:30
@zmaalick
Copy link
Copy Markdown
Collaborator Author

Also, Zubair Maalick (@zmaalick) can you change the copyright years (# (C) Crown Copyright 2022-2025, Met Office.) in the file to 2022-2026.

Done

mo-nikosbaltas
mo-nikosbaltas previously approved these changes Jan 12, 2026
Copy link
Copy Markdown
Contributor

@mo-nikosbaltas mo-nikosbaltas left a comment

Choose a reason for hiding this comment

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

All looks good.

@mo-nikosbaltas mo-nikosbaltas self-requested a review January 12, 2026 13:42
Copy link
Copy Markdown
Member

@ehogan Emma Hogan (ehogan) left a comment

Choose a reason for hiding this comment

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

Thanks Zubair Maalick (@zmaalick) 🥳

The "end of new line" issue with one of the files in this branch suggests you have not set up the pre-commit hooks. Please set up the pre-commit hooks. Instructions are available at https://github.com/MetOffice/CMEW/wiki/First-time-developer-instructions#first-time-developer-instructions.

Comment thread pytest.ini
Copy link
Copy Markdown
Member

@ehogan Emma Hogan (ehogan) left a comment

Choose a reason for hiding this comment

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

Thanks Zubair Maalick (@zmaalick) 😊

Now that the pytest configuration has been added, please remove the cd command to be removed from the unittest app.

Comment thread CMEW/app/configure_recipe/bin/test_configure_recipe.py
Comment thread CMEW/app/configure_standardise/bin/test_create_request_file.py
Comment thread pyproject.toml Outdated
Comment thread CMEW/site/metoffice.cylc
Comment thread pyproject.toml Outdated
Copy link
Copy Markdown
Member

@ehogan Emma Hogan (ehogan) left a comment

Choose a reason for hiding this comment

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

Almost there! 🤪

Comment thread CMEW/app/configure_standardise/bin/test_create_request_file.py
Comment thread CMEW/app/configure_recipe/bin/test_configure_recipe.py Outdated
Copy link
Copy Markdown
Contributor

@mo-nikosbaltas mo-nikosbaltas left a comment

Choose a reason for hiding this comment

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

Looks ok.

Copy link
Copy Markdown
Member

@ehogan Emma Hogan (ehogan) left a comment

Choose a reason for hiding this comment

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

Thanks Zubair Maalick (@zmaalick), just one more outstanding change (and I will add to the working practices that the developer should check the changes in the "Files changed" tab and perform a self-review before requesting a review).

Comment thread CMEW/app/configure_standardise/bin/test_create_request_file.py Outdated
Comment thread CMEW/app/unittest/rose-app.conf Outdated
Copy link
Copy Markdown
Member

@ehogan Emma Hogan (ehogan) left a comment

Choose a reason for hiding this comment

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

Thanks Zubair Maalick (@zmaalick) 🥳

pytest on the command line, cylc vip -O metoffice -O test and cylc vip -O metoffice -O unittest all return the same output 🎉

Comment thread pytest.ini Outdated
Comment thread CMEW/app/unittest/rose-app.conf Outdated
= cmew-esmvaltool-env pytest
=cmew-esmvaltool-env pytest

[file:pytest.ini]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel it would be clearer if the full path was specified here, rather than specifying file-install-root at the top of this file. Also, would it be possible to use .pytest.ini rather than pytest.ini, please?

Suggested change
[file:pytest.ini]
[file:${CYLC_WORKFLOW_RUN_DIR/.pytest.ini]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, would it be possible to use .pytest.ini rather than pytest.ini, please?

Please also update the name of the file in the repository from pytest.ini to .pytest.ini.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As mentioned at #321 (comment) and in a previous retro where we agreed to update the PR checklist with the point "Remember to re-check the Definition of Done after making changes in response to a review.", please re-check the Definition of Done after making this change (particularly the testing).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hi Emma Hogan (@ehogan)

in `app/unittest' we are doing:

[file:$CYLC_WORKFLOW_RUN_DIR/.pytest.ini]
source=git:https://github.com/MetOffice/CMEW.git::pytest.ini::165_add_unittest_in_github_workflow

cylc does not read hidden files. Making pytest.ini to .pytest.ini will not work in cylc. (that is why unitest are failing in cylc)

we need to convert it back to pytest.ini to make it work.

Comment thread CMEW/app/unittest/rose-app.conf Outdated
Comment thread CMEW/app/unittest/rose-app.conf Outdated
Comment thread CMEW/app/unittest/rose-app.conf Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

quality assurance Anything related to Quality Assurance (QA) testing Anything related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add running the unittests to the GitHub workflow

4 participants