-
-
Notifications
You must be signed in to change notification settings - Fork 437
adjust GitHub actions and tox config #506
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
adjust GitHub actions and tox config #506
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot something, the linters are not checked in these tests.
Probably the option in matrix
section is missing.
Furthermore I am not a fan of tox and prefer the django approach to separate the linters so that it is easier to see the different job failures. Here is the django way of linting.
So I would say to leave the lint action and separate the listing jobs, I know it takes longer because the installation has to be done from scratch before executing the linter check, it is just personal taste and cleanliness.
That said, I am open to discuss different options.
It's defined for a specific run as seen in the tox config https://github.com/jazzband/django-redis/pull/506/checks?check_run_id=2251646864#step:8:140 I mainly made the change because the lint workflow was using tox too. |
It would probably be best to eventually configure a check runner which can add inline annotations to the PRs and not require users to parse the log output. |
could you elaborate? I don't understand. What do you think about my proposal? |
These are status "checks" https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-status-checks which are different than "statuses" which is just a pass/fail from a build action.
You are saying to split them out individually? Yes I'm aware of that way of doing that. We don't need a separate workflow to make that happen though.
Is there a reason you don't like tox? It is convenient to have a simple command run all the tests locally. I do understand there is more output that you have to parse, but that was why I suggested in the long term it would be good to surface the issues in the PR rather in the logs. |
4b68659
to
75405d7
Compare
I realized one issue you may have had with the current tox setup is that all lint steps are combined. I could split out each of the lint tools into their own env which may make it easier to see failures (and it will allow them all to run regardless if the other failed). Each of the tox envs are grouped by tox-gh-actions, and can be expanded (I thought they expanded by default if the section failed, but not so sure about that now). |
DISCAIMER: this is just an opinion, I am not here to fight any battles or impose my viewsI don't like tox because it is not a straightforward tool in my opinion, I find it useful because you can run different combinations of tools (in this case python, django and redis). But I think it is overdoing it because GitHub actions already have matrix support. Sure you can't do that locally, but do you want to run tests on every version possible locally every time? Furthermore by just looking at the workflow you don't understand what is it doing. For the same reason, for linting, I prefer to have separate jobs in separate actions to keep things simple. I am not a big fan of merging everything together with one tool, in this case lint workflows and tests. Also adding different split linters inside tox it seems too much for me. Having one tool to do everything is a simplification on one side and a complication on another. As a matter of fact what you are proposing is much more complicated than just do it the "django" way, or I might say the "django's repo" way, I find it more elegant. Finally I don't mind proceeding with what you have proposed here, as I said in the disclaimer I am not here to fight any battles, it is not worth it for this kind of things. |
While that's true tox makes installing the dependencies easier. Otherwise you'd need to write your own shell script to install potential different requirements.txt files. Also I hadn't seen
Maybe yes, and maybe no. It definitely helps for testing against multiple versions of Python and although Python 2 support has been dropped, for the time that it was supported it was nice to easily have both run (I had both installed on my system). Since I don't have 3.6 on my system anymore there's not too many runs that happen by default anymore. I'm definitely on the fence about tox running everything by default, but I encourage you to get familiar with the I know tox can be cumbersome, but it can also be really useful if set up correctly. One thing I noticed is we probably should have a way to detect if redis is available and also have a simple way to start it up so people can run the tests locally since that's a gap that's not "trivial" to fix now that the tests expect redis and a sentinel. We may also want to migrate the tests to use
I'll definitely buy that, but how things are organized is debatable and depending on the size of things splitting out may not help.
You may be misunderstanding what I'm suggesting (or maybe not). I don't think it would be complicating the config more than it already is, which I'll agree we could split out of tox.
Part of my change to merge the workflow runs was to make sure the badge on the README was specified correctly and pointed to the actual state of things. Since this code doesn't change much are we ok merging this in and continuing to update things? Or would you prefer the lint run to be separate but specified in the same workflow file? I don't mind holding off on that part of the change and can make the lint check remain Just a small reminder that the main reason I'd like to merge this in because the duplicate redis service definition is keeping the tests from running. |
I understand what you mean, I prefer to do things little by little, so here is my proposal and reason to proceed this way. Let's make only the fix to the squash now, and tidy tox a little. Let's keep lint workflow so if that fails on the email you already get the workflow that has failed (lint or test). After that I propose to have a separate issue to split linters in tox. I am also in favor of your change to put tox config in Also it would be nice to close this issue asap so we could proceed to fix codecov and add coverage badge and checks in #510. Last but not least I had in mind to change a little bit the linting settings, in favor of black compatibility tips, you can consult them here |
And I forgot to mention, for redis health check and sentinel I think we could create a directory with utility scripts. By the way that is what I do instead of using tox, in my projects I have check and run linters scripts that look like this. check-linters.sh #!/usr/bin/env zsh
echo "Checking black"
black --target-version py38 --check --diff .
echo "Checking flake8"
flake8 --exclude .venv,.mypy_cache
echo "Checking isort"
isort --check-only --diff .
echo "Checking mypy"
mypy lib
run-linters.sh #!/usr/bin/env zsh
echo "Running black"
black --target-version py38 .
echo "Running flake8"
flake8 --exclude .venv,.mypy_cache
echo "Running isort"
isort . and the lint.yml would look like this, also I forgot to mention that I use pipenv name: Lint
on:
- push
- pull_request
jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Get python version
run: echo "PYTHON_VERSION=$(python3 --version | awk '{print $2}')" >> $GITHUB_ENV
- name: Install pipenv
run: pip install pipenv
- name: Cache pipenv
uses: actions/cache@v2
with:
path: ~/.local/share/virtualenvs
key: lint-pipenv-${{ env.PYTHON_VERSION }}-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
lint-pipenv-${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: pipenv install --dev --python 3.8
- name: Run black
run: pipenv run black --target-version py38 --check --diff .
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Get python version
run: echo "PYTHON_VERSION=$(python3 --version | awk '{print $2}')" >> $GITHUB_ENV
- name: Install pipenv
run: pip install pipenv
- name: Cache pipenv
uses: actions/cache@v2
with:
path: ~/.local/share/virtualenvs
key: lint-pipenv-${{ env.PYTHON_VERSION }}-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
lint-pipenv-${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: pipenv install --dev --python 3.8
- name: Run flake8
run: pipenv run flake8
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Get python version
run: echo "PYTHON_VERSION=$(python3 --version | awk '{print $2}')" >> $GITHUB_ENV
- name: Install pipenv
run: pip install pipenv
- name: Cache pipenv
uses: actions/cache@v2
with:
path: ~/.local/share/virtualenvs
key: lint-pipenv-${{ env.PYTHON_VERSION }}-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
lint-pipenv-${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: pipenv install --dev --python 3.8
- name: Run isort
run: pipenv run isort --check-only --diff .
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Get python version
run: echo "PYTHON_VERSION=$(python3 --version | awk '{print $2}')" >> $GITHUB_ENV
- name: Install pipenv
run: pip install pipenv
- name: Cache pipenv
uses: actions/cache@v2
with:
path: ~/.local/share/virtualenvs
key: lint-pipenv-${{ env.PYTHON_VERSION }}-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
lint-pipenv-${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: pipenv install --dev --python 3.8
- name: Run mypy
run: pipenv run mypy lib
I am not propose to go this way, I just wanted to show how I work, in my projects we usually do not use matrix at all. |
.github/workflows/test.yml
Outdated
jobs: | ||
build: | ||
name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}, Redis.py ${{ matrix.redis-version }}) | ||
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}, Redis.py ${{ matrix.redis-version }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually not change this or maybe call it test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title already includes "test" because that's the name of the workflow. You can see what this looks like on this pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to test because I added back the lint check at your request.
Okay, I had a look at tox and it does not seem that difficult to learn, I would suggest to add another environment called lintenv and split the lint tools so that they can run in different jobs. Another thing is that we need to discuss on another issue or pr is on how to use pytest and enable coverage reports |
d9e2c55
to
ca7df53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you separate the lint steps?
You could also leave a step that executes the others for development, and also why there are two lint environments?
They are separate. If you're asking for separate workflow files, no. The badge on the README should point to the workflow run and that was the point of me merging the two. There's not really a benefit to separate the workflows other than to have more files. The build definitions are rather short and the definition is only important to the maintainers not people submitting PRs. If you're asking about the different lint tools let's do that separately. I'm just trying to keep this "compatible" with the previous env setup / your requests to have them separate.
Not sure what this means
I left this in because it doesn't hurt and we're still working towards the future ci setup. Just a fyi I'm not going to be near my computer for the rest of the day. I just wanted to push at least a compromise with the lint step so we could get this merged in. (Not sure if you were aiming to do that today or later in the week is fine) |
No I mean, inside tox, so you could have different checks showing up. I mean these two |
And I see |
That looks to be correct. It was no longer referenced in 2af9ab9 when tox was used on the CI.
I'm not sure what this comment was pertaining to. I believe I had responded to the original question:
You may have interpreted:
But I was following quotes, not preceeding them, so my question was:
|
I meant having
it is nice to have the runs that have failed in the email and pr page rather than looking at logs. On that manner, I think About the test changes that you have made, |
tests/README.txt
Outdated
.. code-block:: bash | ||
|
||
Install the development requirements using the requirements.txt file: | ||
# start redis and a sentinel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little disclaimer that the setup it is done with docker would be nice
tests/runtests.py
Outdated
SOCK_SETTINGS = "settings.sqlite_usock" | ||
|
||
if __name__ == "__main__": | ||
if any(SOCK_SETTINGS in i for i in sys.argv) or SOCK_SETTINGS in os.environ.get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any ideas on how to enable tests with unix socket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They work locally now, we probably need to move the CI to use the start redis script which can pass the arguments needed to configure redis. Alternatively we could probably use socat to pipe the tests to redis...
That is what I meant by:
But you had replied:
So I figured we could get this PR in and then either pull out tox for the lint steps or split it as you're suggesting now. |
8341bad
to
dd9167e
Compare
dd9167e
to
6308e85
Compare
I backed out the env |
I understand you are in hurry, but you could at least for other people to review and merge your changes. Why did you remove django 3.0 from matrix? |
Django 3.2 was released and 3.0 hit end of extended support (https://www.djangoproject.com/download/) |
Changes to GitHub actions:
Changes to README:
Changes to tests and testing environment:
runtest.py --settings=<settings>
x-ref: ymyzk/tox-gh-actions#60 will remove the need for
lint-dj31-redislatest