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

Switch from CircleCI to GitHub Actions #115

Merged
merged 42 commits into from
Oct 21, 2021
Merged

Switch from CircleCI to GitHub Actions #115

merged 42 commits into from
Oct 21, 2021

Conversation

HAEKADI
Copy link
Contributor

@HAEKADI HAEKADI commented Sep 2, 2021

Related to openfisca/openfisca-core/#1030
Related to openfisca/openfisca-core/#1027
Related to openfisca/openfisca-france/#1663
Closes #114

GitHub Actions

  • Technical improvement.
  • Impacted areas: CI configuration
  • Details:
    • Switch from CircleCI to GitHub Actions

Screenshot 2021-09-23 at 15 47 48

@HAEKADI HAEKADI changed the title GitHub actions Switch from CircleCI to GitHub actions Sep 2, 2021
@HAEKADI HAEKADI changed the title Switch from CircleCI to GitHub actions Switch from CircleCI to GitHub Actions Sep 2, 2021
@HAEKADI HAEKADI self-assigned this Sep 2, 2021
@HAEKADI HAEKADI marked this pull request as draft September 8, 2021 12:04
@HAEKADI HAEKADI marked this pull request as ready for review September 15, 2021 08:58
@HAEKADI
Copy link
Contributor Author

HAEKADI commented Sep 15, 2021

@MattiSG @maukoquiroga check-style in the Makefile uses both pylint and flake8 in Country-template but only flake8 in OpenFisca France.

The old CI did not include a linting job #114, when adding it to the new CI pylint causes the following error:

Screenshot 2021-09-15 at 11 02 05

Is there a consensus on whether one or both should be used?

@MattiSG
Copy link
Member

MattiSG commented Sep 15, 2021

Unless they do different things, I am in favour of having only one linter, to make linting faster and more deterministic.
I see that on Core, there's only flake8.

@HAEKADI didn't you mention superlinter? Do you think it would be appropriate here?

@HAEKADI
Copy link
Contributor Author

HAEKADI commented Sep 15, 2021

@MattiSG Yes, I have. It would definitely be appropriate. You can find the tests I ran with it here.

But if my memory serves me well, we decided to add it in a separate PR after the switch to GitHub Actions as to not introduce too many changes at once.

@MattiSG
Copy link
Member

MattiSG commented Sep 15, 2021

we decided to add it in a separate PR after the switch to GitHub Actions as to not introduce too many changes at once

We did indeed 🙂 Now, if we have to reconsider the current way of linting, I just wanted to throw this in 😉

@bonjourmauko
Copy link
Member

bonjourmauko commented Sep 17, 2021

Hi !

Is there a consensus on whether one or both should be used?

We have agreed on the rules to encforce, that's why you will find them in the country and extension templates, yet still not implemented them in openfisca/openfisca-core#960 .

Unless they do different things, I am in favour of having only one linter, to make linting faster and more deterministic.
I see that on Core, there's only flake8.

flake8 and pylint are lint "engines", they implement style codes, like PEP8 and so on.

What they do differently is hang indents (E128/133), a very specific style of the older OpenFisca community.

Other than that, I prefer whatever comes closes to the rules we have agreed upon (that excludes black for example).

Specific example: in OpenFisca, a Variable is a class, but it is snake cased, so the only prerequisite of a linter for me is that it can be highly configurable.

@HAEKADI didn't you mention superlinter? Do you think it would be appropriate here?

Haven't heard of that one, I'll take a look.

The minimal set of style rules for me is the one in the setup.cfg, well the exceptions:

; D101:                   Variables already provide label/description
; D107:                   We do not document __init__ method
; D401:                   We do not require the imperative mood
; E128/133:               We prefer hang-closing visual indents
; E251:                   We prefer `function(x = 1)` over `function(x=1)`
; E501:                   We do not enforce a maximum line length
; W503/4:                 We break lines before binary operators (Knuth's style)

; C0103:                  We (still) snake case variables and reforms
; C0115:                  Variables already provide label/description
; C0301:                  We do not enforce a maximum line length
; E0213:                  This requires changes in OpenFisca-Core
; E1101:                  False positive, as entities have members
; E1102:                  False positive, as entities are callable
; W0621:                  We name variable values the variable name
; W1203:                  We prefer to log with f-strings

Beyond that, I'm OK with whatever is faster and more deterministic as @MattiSG said.

Update

superlinter provides pylint, flake8, and isort, so I think the current ruleset is enforceable with it! 🙌

@HAEKADI
Copy link
Contributor Author

HAEKADI commented Sep 17, 2021

Thank you for the clarification @maukoquiroga! I started implementing super-linter in Openfisca France here.
I used super-linter not only for new scripts but on the existing code-base and there were too many errors to count.
I was not aware that black was excluded and consequently started correcting those errors 😬

@bonjourmauko
Copy link
Member

I don't have a clear view on latest discussions in the French community, but for the historical record black has been rejected twice while I was leading product. I was agnostic since, now I'm more on the reluctant side.

used super-linter not only for new scripts but on the existing code-base and there were too many errors to count.

I can relate to that, see openfisca/openfisca-core#960 and https://github.com/openfisca/openfisca-france/issues?q=style+author%3Amaukoquiroga.

@HAEKADI
Copy link
Contributor Author

HAEKADI commented Sep 17, 2021

I see. Maybe it's time to put pen to paper and have a clear definition of linting rules across all repos. I see you already started working on it @maukoquiroga with openfisca/openfisca-core#960.

@bonjourmauko
Copy link
Member

I see. Maybe it's time to put pen to paper and have a clear definition of linting rules across all repos. I see you already started working on it @maukoquiroga with openfisca/openfisca-core#960.

That would be great!!!

See one of the discussions on black for example: openfisca/openfisca-core#977

I've started https://github.com/openfisca/openfisca-core/blob/master/STYLEGUIDE.md and I'm happy to help if you decide to continuing efforts on style coherence —which I think is a great idea.

It is an idea that has been going on and proposed by some members. See https://github.com/openfisca/country-template/pull/111/files for example, beyond the actual implementation (pre-commit), it would be great to have all linting rules in a separated repo and pull them as a development dependency.

@HAEKADI
Copy link
Contributor Author

HAEKADI commented Sep 22, 2021

I see. There are certainly many ways to go about doing that.
As a starting point, I suggest implementing these rules, in the new CI, with super-linter, across all repos (France, Country and Core) as discussed before, to have a unified style.

@MattiSG
Copy link
Member

MattiSG commented Sep 23, 2021

If I understand correctly, super-linter is just a way to ease working with linters on GitHub Actions:

The design of the Super-Linter is currently to allow linting to occur in GitHub Actions as a part of continuous integration occurring on pull requests as the commits get pushed. It works best when commits are being pushed early and often to a branch with an open or draft pull request. There is some desire to move this closer to local development for faster feedback on linting errors but this is not yet supported.

However, in openfisca/openfisca-core#1040, we decided to focus on consolidating tasks in a task manager, not in CI. Thus, I understand that if we want to call both flake8 and pylint, this should be wrapped in a task that is also executable locally and whose dependencies are declared and installed explicitly, not only indirectly through super-linter.

I also see in aaea4dd that the so-called “linting scripts” were removed, but these scripts do more than just activate linting: most of all, they select the subset of files to be linted in order to accelerate the process. I am thus not sure this should just be removed.

@MattiSG
Copy link
Member

MattiSG commented Sep 23, 2021

As discussed this morning with @HAEKADI, based on the conclusions from openfisca/openfisca-core#1040, let's focus this PR on being isofunctional and moving to GitHub Actions without changing the services.

@HAEKADI
Copy link
Contributor Author

HAEKADI commented Sep 23, 2021

I removed super-linter.
I just have to check deploy. @MattiSG could you please add the pypi password to GitHub secrets?

@MattiSG
Copy link
Member

MattiSG commented Sep 23, 2021

could you please add the pypi password to GitHub secrets?

Done!

Copy link
Member

@MattiSG MattiSG left a comment

Choose a reason for hiding this comment

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

Please make a search for circleci in the entire repo, in order to make sure that there are no more references to it, and update the existing ones accordingly.

For example, the bootstrap script is missing an update 🙂

.github/is-version-number-acceptable.sh Outdated Show resolved Hide resolved
.github/workflows/workflow.yml Outdated Show resolved Hide resolved
.github/workflows/workflow.yml Outdated Show resolved Hide resolved
.github/workflows/workflow.yml Show resolved Hide resolved
.github/workflows/workflow.yml Outdated Show resolved Hide resolved
@HAEKADI
Copy link
Contributor Author

HAEKADI commented Sep 23, 2021

The deploy seems functional.
Screenshot 2021-09-23 at 17 19 56

setup.py Outdated
@@ -4,7 +4,7 @@

setup(
name = "OpenFisca-Country-Template",
version = "3.12.9",
version = "3.12.10",
Copy link
Member

Choose a reason for hiding this comment

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

In the context of the Template, I believe that switching from CircleCI to GitHub Actions should be a minor, not a patch 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay :) so 3.13.0 ?

CHANGELOG.md Outdated Show resolved Hide resolved
Comment on lines 21 to 25
- name: Build package
if: steps.restore-build.outputs.cache-hit != 'true'
run: make build
Copy link
Member

Choose a reason for hiding this comment

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

Won't that leave the built package in its very first state, never updating the cache? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. We did encounter the problem in Openfisca-France. I opened a PR to solve it.

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 will integrate the changes here as well.

.github/workflows/workflow.yml Show resolved Hide resolved
Copy link
Member

@MattiSG MattiSG left a comment

Choose a reason for hiding this comment

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

The workflow name is not updated when the bootstrap script is executed: the workflow.yml file still contains name: Country Template.

Copy link
Member

@MattiSG MattiSG left a comment

Choose a reason for hiding this comment

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

Tested locally entirely on macOS 11.6 with an M1 processor, the bootstrap script seems to work well, but installing fails with ModuleNotFoundError: No module named 'Cython' when trying to install numexpr 2.7.3.

Since the tests pass, I assume this is related to my local setup and will approve this PR. I would appreciate a double check on this issue, as well as handling the macOS-specific comment 🙂

Looking forward to this landing!

.github/workflows/workflow.yml Show resolved Hide resolved
bootstrap.sh Show resolved Hide resolved
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.

Lint YAML and Python files on CI
3 participants