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

Run tests with a realistic version of git #2043

Merged
merged 4 commits into from
Nov 30, 2022
Merged

Conversation

Aratz
Copy link
Contributor

@Aratz Aratz commented Nov 22, 2022

This PR fixes the following issues:

  • Github's Ubuntu images use the very latest version of git (i.e. v2.38.1, see here). More specifically, this is different from the version available on the image that is used for the tests (Ubuntu 20.04, git 2.25.1). Since nf-core/tools heavily depends on the git version available to the user, this PR downgrades git so that the testing environment is more similar to what a typical user would have.
  • Consequently, some failed tests have been going under the radar in test_create and test_sync. This PR also fixes these tests.

Additionally, this is at least the second time we encounter bugs that are specific to the version of git being used so maybe we should consider testing with older and newer LTS Ubuntu versions (and their respective versions of git)?

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!

@codecov
Copy link

codecov bot commented Nov 22, 2022

Codecov Report

Merging #2043 (452f243) into dev (ea388b3) will decrease coverage by 0.14%.
The diff coverage is n/a.

❗ Current head 452f243 differs from pull request most recent head 755b9f2. Consider uploading reports for the commit 755b9f2 to get more accurate results

@@            Coverage Diff             @@
##              dev    #2043      +/-   ##
==========================================
- Coverage   67.76%   67.61%   -0.15%     
==========================================
  Files          43       43              
  Lines        5559     5558       -1     
==========================================
- Hits         3767     3758       -9     
- Misses       1792     1800       +8     
Impacted Files Coverage Δ
nf_core/components/components_utils.py 32.20% <0.00%> (-15.99%) ⬇️
nf_core/lint_utils.py 73.68% <0.00%> (-12.04%) ⬇️
nf_core/modules/modules_utils.py 62.79% <0.00%> (-11.02%) ⬇️
nf_core/components/components_test.py 56.09% <0.00%> (-2.14%) ⬇️
nf_core/components/info.py 78.72% <0.00%> (-1.28%) ⬇️
nf_core/modules/test_yml_builder.py 49.09% <0.00%> (-0.46%) ⬇️
nf_core/__main__.py 58.62% <0.00%> (+0.16%) ⬆️
nf_core/components/update.py 82.21% <0.00%> (+0.49%) ⬆️
nf_core/modules/lint/__init__.py 83.42% <0.00%> (+0.53%) ⬆️
nf_core/modules/modules_repo.py 84.13% <0.00%> (+0.64%) ⬆️
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@fabianegli fabianegli left a comment

Choose a reason for hiding this comment

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

I think this makes a lot of sense, but we could also just alert people who have an outdated version of git installed to please update. That might be the simpler solution.

The git customization adds 20+ seconds to the test setup - We might want to somehow set a sunset trigger for this to remove it once newer versions of git can be reasonably expected. This could be in an issue, or as a trigger in the setup that fails when the installed git version after the setup is newer than some version.

Comment on lines 40 to 42
sudo apt remove git git-man
sudo add-apt-repository --remove ppa:git-core/ppa
sudo apt install git
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not knowledgable enough to judge this, but isn't there an apt update missing before the installation? Or is it intentionally missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

apt update is needed when you add a new source and need to update package information. When you remove a source, there is no new info to get :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant between the repository removal and the install. I figured running update after removing the repository might change what package install pulls.

@mashehu
Copy link
Contributor

mashehu commented Nov 22, 2022

That's a great catch, thank you!

@Aratz
Copy link
Contributor Author

Aratz commented Nov 23, 2022

Thanks for the quick replies!

@fabianegli I think few people are likely to add their own PPA to get the latest version and will just go with the latest version available in the official Ubuntu repository (2.17 for Ubuntu 18.04 and 2.25 for Ubuntu 20.04). Ubuntu 20.04 will be supported until 2025-04 and I think we should do just the same. Some people just don't have the option to update the system they are given access to.

I think in general it makes sense to use the git package from the official Ubuntu repository rather than from the custom PPA, so I'd rather keep this even in the future. I think that, as much as possible, the test environment should look like what users will have. I mean the bugs we found were due to the new default branch feature but it could be something else with future versions of git.

@fabianegli
Copy link
Contributor

fabianegli commented Nov 23, 2022

@Aratz I agree with you for basically everything.

@fabianegli
Copy link
Contributor

Related, but a separate issue: #2044

@Aratz
Copy link
Contributor Author

Aratz commented Nov 25, 2022

I think I've managed to fix it. I've creating a release on my own fork for validation purposes. The tests fail for unrelated reasons but the full matrix was scheduled at least: https://github.com/Aratz/nf-core-tools/actions/runs/3547118628/jobs/5956896579#step:7:81

@fabianegli
Copy link
Contributor

It would be nice to have a way to query our past runs to see how often specific python versions had failing tests while others succeeded to get some data on wether dropping all in-between version tests for both ubuntu version is reasonable. Otherwise I would try to keep testing all Python versions on the newer Ubuntu release.

steps:
- id: set-matrix
run: |
if [ ${{ github.event_name }} == "release" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

If we run this only for PRs towards master (which is basically a release) the logic might be bit simpler no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I follow, do you mean the select-strategy job should run only on PR that target master? I think this becomes a problem in the pytest job because of the needs: select-strategy line, i.e. the way it is written it is expected select-strategy is run in all cases.

I've tried to implement this using only "workflow logic" but couldn't really come up with a good solution, so that's why I had to incorporate these bash lines instead.

@Aratz
Copy link
Contributor Author

Aratz commented Nov 25, 2022

@fabianegli hmm, yes in that case the workflow description would be much simpler actually. Maybe testing every python version on ubuntu-22.04 and only python-3.8 on ubuntu-20.04 (that is, the version available on the official repository) is enough?

@fabianegli
Copy link
Contributor

@Aratz yes, I think this would suffice. We'd then have the tests for the "frozen system" Ubuntu 20.04 with it's original python and git version plus a more comprehensive approach regarding Python versions on "ubuntu-latest". And now I am thinking that it might be preferable to set the test up in a separate workflow named something like "pytest-frozen-ubuntu-20.04" and keep the current pytest workflow as is - trading some code duplication for easier communication of intent.

The issue here is that renaming a branch in an empty repository will
fail with earlier versions of git (e.g. 2.25), where the default branch
is always master anyways.
@Aratz Aratz force-pushed the fix_git_rename branch 2 times, most recently from a257e35 to 755b9f2 Compare November 30, 2022 12:33
Copy link
Contributor

@fabianegli fabianegli left a comment

Choose a reason for hiding this comment

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

I think this does what we want/need. Well done @Aratz

@Aratz Aratz merged commit 07f64b9 into nf-core:dev Nov 30, 2022
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.

3 participants