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

Use GitHub Actions for CI #92

Merged
merged 30 commits into from Dec 7, 2019
Merged

Use GitHub Actions for CI #92

merged 30 commits into from Dec 7, 2019

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Nov 22, 2019

This PR was initially created to add linting to our repo separately to travis, and it has now evolved into the following changes, authored jointly with @CasperWA:

On all PRs, and pushes to master, the following will run:

  • flake8:
    • currently this is required to pass before merging, but the only checks that break this are syntax errors and undefined names. Other errors (e.g. line too long, of which we have many due to our docstrings...) appear as warnings that do not prevent merging.
  • pre-commit (which only runs black at the moment)
    • this currently never blocks merges, but perhaps should.
  • install this package with the all requirements pinned and run the tests, under Python 3.7 and 3.8.
    • obviously blocks merging.
    • codecov upload occurs on the 3.7 build only.
    • currently backend requirements have been left floating in the hope that they do not change their API frequently.
  • install the package with floating requirements, under both 3.7 and 3.8 and run tests again.
    • this never blocks merges, but allows us to keep an eye on things as they break and make separate dependency updates when needed.
    • backend requirements are pinned to major versions due to expected breakages.

@codecov
Copy link

codecov bot commented Nov 22, 2019

Codecov Report

Merging #92 into master will decrease coverage by 0.33%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #92      +/-   ##
==========================================
- Coverage   85.36%   85.02%   -0.34%     
==========================================
  Files          45       44       -1     
  Lines        2425     2371      -54     
==========================================
- Hits         2070     2016      -54     
  Misses        355      355
Flag Coverage Δ
#unittests 85.02% <100%> (?)
Impacted Files Coverage Δ
optimade/models/utils.py 87.5% <100%> (ø) ⬆️
optimade/filtertransformers/elasticsearch.py 87.74% <100%> (ø) ⬆️
optimade/models/optimade_json.py 84% <0%> (-2.21%) ⬇️
optimade/models/structures.py 81.3% <0%> (-2.04%) ⬇️
optimade/models/links.py 83.33% <0%> (-1.29%) ⬇️
optimade/validator/validator.py 60.73% <0%> (-1.05%) ⬇️
optimade/filtertransformers/mongo.py 74.19% <0%> (-1.01%) ⬇️
optimade/filtertransformers/tests/test_django.py 88.23% <0%> (-0.66%) ⬇️
optimade/models/jsonapi.py 90.36% <0%> (-0.55%) ⬇️
optimade/models/baseinfo.py 92.3% <0%> (-0.29%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6675838...786cd5e. Read the comment docs.

@ml-evs
Copy link
Member Author

ml-evs commented Dec 1, 2019

Hopefully this can now be merged after #95 and #99 (after bumping the versions in requirements.txt and setup.py), following the dicussion in #96

@CasperWA
Copy link
Member

CasperWA commented Dec 4, 2019

I have played around with this on my own implementation, and have set it up for black. Since we are using black for linting, do you not also want to use that here, instead of flake8?

@CasperWA
Copy link
Member

CasperWA commented Dec 4, 2019

Ah, I seem to have lost the point of re-introducing requirements.txt. I will revert my change to delete it. Sorry.

@ml-evs
Copy link
Member Author

ml-evs commented Dec 4, 2019

I have played around with this on my own implementation, and have set it up for black. Since we are using black for linting, do you not also want to use that here, instead of flake8?

They perform different functions no? I'm happy with running the pre-commit here too, but a blackened repo isn't necessarily flake8 compliant. We could also add e.g. pylint on top of flake8 to detect further bad code smells.

Re-introduce requirements.txt with static versions for base
dependencies.
Create three different dependency GitHub Actions jobs:
- static
- eager
- as user
@CasperWA
Copy link
Member

CasperWA commented Dec 4, 2019

I have played around with this on my own implementation, and have set it up for black. Since we are using black for linting, do you not also want to use that here, instead of flake8?

They perform different functions no? I'm happy with running the pre-commit here too, but a blackened repo isn't necessarily flake8 compliant. We could also add e.g. pylint on top of flake8 to detect further bad code smells.

Ah, didn't know this. Yeah sure. I'll add it in again.

@ml-evs
Copy link
Member Author

ml-evs commented Dec 4, 2019

This looks good, but now we've veered into replacing travis entirely (fine). Do we know how to prevent a particular step from blocking a merge (e.g. the future deps)? If we want to go all the way with this, codecov can be added to the gh action too.

@CasperWA
Copy link
Member

CasperWA commented Dec 4, 2019

This looks good, but now we've veered into replacing travis entirely (fine).

True. But maybe that's fine? We just need to know how to move releasing over as well...

Do we know how to prevent a particular step from blocking a merge (e.g. the future deps)? If we want to go all the way with this, codecov can be added to the gh action too.

codecov can indeed be added, using codecov-action.
I am not sure how to block merging for a single test. Maybe it's fine just to block merge if any of the tests fail, since we also want "pretty"/linted code?

@ml-evs
Copy link
Member Author

ml-evs commented Dec 5, 2019

Do we maybe only want to run Actions on push if it is on the master branch, and then for PRs always?

The danger here being that actions will not be run on WIP branches until a PR is made.
But we also "only" have 2k minutes of Actions run-time on this account.

Oh, that's interesting, I assumed it would be unlimited use (of course, until they have everyone using it...) In that case your suggestion sounds sensible!

@CasperWA
Copy link
Member

CasperWA commented Dec 5, 2019

But we also "only" have 2k minutes of Actions run-time on this account.

Oh, that's interesting, I assumed it would be unlimited use (of course, until they have everyone using it...)

Nope. See here.
Since Materials-Consortia is a Github Team for Open Source, we only get 2k minutes, whereas a GitHub Team would get 10k.

@ltalirz
Copy link
Member

ltalirz commented Dec 5, 2019

The 2k limit is for private repos

@CasperWA
Copy link
Member

CasperWA commented Dec 5, 2019

The 2k limit is for private repos

My mistake - glitch-reading the page. Thanks for the eye-opener.

@ml-evs
Copy link
Member Author

ml-evs commented Dec 5, 2019

I've updated the description of this PR, so please "review" that too, but I think this is now ready to go. We still need to update the installation and contributing instructions, I'll add that to the other PR over at #68.

@ml-evs ml-evs requested review from CasperWA and ltalirz and removed request for ltalirz December 5, 2019 19:16
@CasperWA
Copy link
Member

CasperWA commented Dec 6, 2019

  • pre-commit (which only runs black at the moment)
    • this currently never blocks merges, but perhaps should.

I agree. In particular, I suggest we have a develop branch (after we create a proper release) and have pre-commit be blocking for merging to master but not necessarily to develop?

  • install this package with the pinned core requirements and run the tests, under Python 3.7 and 3.8.
    • obviously blocks merging.
    • codecov upload occurs on the 3.7 build only.
    • currently backend requirements have been left floating in the hope that they do not change their API frequently. I would favor pinning to at least major versions of these packages.

After some thought, I agree. Especially since I saw that django just release v3 the other day. Having this stay at v2 for this test absolutely makes sense. For the one mentioned below, however, it is essential that we install the very latest.

  • install the package with floating requirements, under both 3.7 and 3.8 and run tests again.
    • this never blocks merges, but allows us to keep an eye on things as they break and make separate dependency updates when needed.

@CasperWA
Copy link
Member

CasperWA commented Dec 6, 2019

Btw, I will add the "publish on PyPI" workflow in another PR. I think that's better? However that also means that between this as that, the repository looses the ability to auto-publish on valid tag pushes.

Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Happy with this.

In order to accommodate our latest wishes, requirements.txt needs to be updated with django>=2.* or django~=2 or something similar. I am not exactly sure what is correct to make sure all minor version are updated, but the major is not.
If we update the setup.py with restrictive versions, the eager test will not run properly, I think.

.github/workflows/deps_lint.yml Outdated Show resolved Hide resolved
@ml-evs
Copy link
Member Author

ml-evs commented Dec 6, 2019

In order to accommodate our latest wishes, requirements.txt needs to be updated with django>=2.* or django~=2 or something similar. I am not exactly sure what is correct to make sure all minor version are updated, but the major is not.

I think maybe django>=2,<3 will work?

If we update the setup.py with restrictive versions, the eager test will not run properly, I think.

Yes, we end up back in the scenario of multiple requirements files... Since the backends only require only one package each, we could hardcode the pip installation of the latest version in the eager tests?

@CasperWA
Copy link
Member

CasperWA commented Dec 6, 2019

In order to accommodate our latest wishes, requirements.txt needs to be updated with django>=2.* or django~=2 or something similar. I am not exactly sure what is correct to make sure all minor version are updated, but the major is not.

I think maybe django>=2,<3 will work?

I have looked more into this. We can use ~=. The way I understand it is that pip will update to the newest version of the last version specified, i.e.:
django~=2.2 will install the latest minor version, never exceeding major version 2.
django~=2.2.1 will install the latest patch version for major.minor version 2.2.

This notation is quite minimalist, which I like, but at the same time, it may not be very informative to the uninitiated.

So I would probably update setup.py with these, i.e., just replacing the first = with a ~.

If we update the setup.py with restrictive versions, the eager test will not run properly, I think.

Yes, we end up back in the scenario of multiple requirements files... Since the backends only require only one package each, we could hardcode the pip installation of the latest version in the eager tests?

Let's just not do my suggestion here? And hardcoding fails to meet the automation aspect of the workflow job, I think?

@ml-evs
Copy link
Member Author

ml-evs commented Dec 6, 2019

Ah sorry, misunderstood your comment. I thought by restrictive versioning you were referring to your own suggestion. I'll do this now.

@CasperWA
Copy link
Member

CasperWA commented Dec 6, 2019

Ah sorry, misunderstood your comment. I thought by restrictive versioning you were referring to your own suggestion. I'll do this now.

Ah, yeah. I kind of was. But I was thinking of adding these things to requirements.txt or setup.py.
If we only ever use requirements.txt for testing, I think it's fine to add all dependencies here. Indeed, it would actually make the most sense for testing.

ml-evs and others added 3 commits December 6, 2019 13:36
- Restricted versions of backends to major versions in setup.py
- Added pinned versions of backends to requirements.txt
- Moved requirements.txt to be CI specific
Co-Authored-By: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
@CasperWA
Copy link
Member

CasperWA commented Dec 6, 2019

I tried to be clever. I started to write a script to update the requirements files if setup.py was updated. But in the end, it was too much work for a very small gain.
So now there are just manually maintained requirements files ...

@CasperWA
Copy link
Member

CasperWA commented Dec 6, 2019

Another question I have pondered: Should we truly be eager in the upgrade and remove all constraints, or should we keep to what the workflow is set up for now, i.e. keep the constraint for pydantic, and introduce similar constraints for the eager requirements in the future if we need it?

I guess this comes down to, what is the real purpose of the eager test job?

@ml-evs
Copy link
Member Author

ml-evs commented Dec 7, 2019

Another question I have pondered: Should we truly be eager in the upgrade and remove all constraints, or should we keep to what the workflow is set up for now, i.e. keep the constraint for pydantic, and introduce similar constraints for the eager requirements in the future if we need it?

I guess this comes down to, what is the real purpose of the eager test job?

Honestly, I would remove pydantic as an eager requirement altogether, so we instead are testing whether we support the latest version that FastAPI also supports (currently FastAPI has pydantic>=0.32,<2.0.0 in their reqs).

I'll make this change now, then I really think we should merge this as it is going to hold up other PRs (the checks in this PR are now required but cannot run on the others!)

Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Great! And I agree about pydantic and the purpose of the eager test.

Thanks a lot @ml-evs for starting and doing this PR. It was quite helpful for myself to learn Actions :)

@CasperWA CasperWA merged commit ea67905 into master Dec 7, 2019
@CasperWA CasperWA deleted the gh_action_linter branch December 7, 2019 23:15
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.

None yet

4 participants