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

Test pydata application #1073

Merged
merged 5 commits into from Nov 11, 2016
Merged

Conversation

aditnryn
Copy link

@aditnryn aditnryn commented Nov 4, 2016

PR created to test whether Travis creates multiple jobs.

@aditnryn aditnryn force-pushed the test-pydata branch 21 times, most recently from 9deec81 to b062943 Compare November 5, 2016 14:36
python:
- 3.5

env:
- PYDATA=true
Copy link
Author

Choose a reason for hiding this comment

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

PyData app introduces a migration since it adds a choice argument to the sponsorship amount field. So, I do not check for missing migrations here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where is that migration? I can't find it.

OK, I see it.

@aditnryn
Copy link
Author

aditnryn commented Nov 5, 2016

@pbanaszkiewicz @chrismedrela
I have added another job on Travis that runs the test suite while the pydata app is deployed.
Please review.

git pull -q --no-edit origin develop;
fi;
- if [[ $PYDATA == true ]]; then
git pull -q --no-edit origin deploy-pydata;
Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly is in deploy-pydata?

Are you sure git pull is the right way to go?

Can we use git config --local instead of git config --global?

Copy link
Author

Choose a reason for hiding this comment

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

What exactly is in deploy-pydata?

Adds pydata to INSTALLED_APPS and urlconfig. See the commit cf8603aa

Are you sure git pull is the right way to go?

Isn't pull an aggregate command that executes fetch and merge. Shouldn't be a problem.

Can we use git config --local instead of git config --global?

The instances destruct after every test. It does not make a difference.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adds pydata to INSTALLED_APPS and urlconfig. See the commit cf8603a

Why not conditionally include it in the config? It could be controlled via envvar.

Isn't pull an aggregate command that executes fetch and merge. Shouldn't be a problem.

Hmm well I can see some issues and questions here.

You're assuming that someone wants to merge into develop, which is not always true.

You're merging develop into PR branch (this may be the same as merging PR branch into develop - I'm not sure).

What happens when you get merge conflict. The test suite doesn't run?

And finally, according to the travis-ci docs:

Rather than test the commits that have been pushed to the branch the pull request is from, we test the merge between the origin and the upstream branch. To only build on push events, you can disable Build on Pull Requests from your repository settings.

So… is this what @chrismedrela intended in #1066?

Copy link
Author

Choose a reason for hiding this comment

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

Why not conditionally include it in the config? It could be controlled via envvar.

Nice suggestion. I am starting to reconsider #938. By overriding the envvar DJANGO_SETTINGS_MODULE, we can switch between a normal deployment and a PyData deployment.

So… is this what @chrismedrela intended in #1066?

Please refer to the discussion at #1066. As you pointed out, Travis does merge the develop branch before testing.

Copy link
Author

Choose a reason for hiding this comment

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

I have removed the fix for #1066. Also, I am moving the discussion out of this comment thread.

@aditnryn
Copy link
Author

aditnryn commented Nov 7, 2016

@pbanaszkiewicz

Why not conditionally include it in the config? It could be controlled via envvar.

Nice suggestion. I am starting to reconsider #938. By overriding the envvar DJANGO_SETTINGS_MODULE, we can switch between a normal deployment and a PyData deployment.

@aditnryn aditnryn added the PyData label Nov 7, 2016
exit 1;
fi;
fi;

Copy link
Contributor

Choose a reason for hiding this comment

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

@narayanaditya95 Could you create a new PR, exactly the same as this one, but please remove the last migration file (0122_auto_20161101_1441.py) to proof that Travis build fails when there are missing migrations?

Copy link
Author

Choose a reason for hiding this comment

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

Okay

Copy link
Author

Choose a reason for hiding this comment

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

See #1078

@chrismedrela
Copy link
Contributor

I'm 👍 for merging when these three issues above are addressed. I've created a new issue #1075 to address monkey patching issue.

@aditnryn
Copy link
Author

aditnryn commented Nov 8, 2016

@chrismedrela
Are you fine with the current implementation of merging a branch, or would you rather consider a different approach that I suggested to @pbanaszkiewicz

Nice suggestion. I am starting to reconsider #938. By overriding the envvar DJANGO_SETTINGS_MODULE, we can switch between a normal deployment and a PyData deployment.

@chrismedrela
Copy link
Contributor

Nice suggestion. I am starting to reconsider #938. By overriding the envvar DJANGO_SETTINGS_MODULE, we can switch between a normal deployment and a PyData deployment.

@narayanaditya95 I'd like to have everything on one branch (develop). Maintaining second branch (deploy-pydata) would be a lot of work, because of backporting everything from develop to deploy-pydata. So, yes, I'm 👍 for varying between deployments with envvars, with one important modification: I'd like to have one settings.py file that reads from an ENABLE_PYDATA envvar and contains conditionals like if ENABLE_PYDATA:. IMO that is simpler than having two separate settings.py files and keeping them in sync.

@chrismedrela
Copy link
Contributor

BTW this is exactly what @pbanaszkiewicz has proposed:

What exactly is in deploy-pydata?

Adds pydata to INSTALLED_APPS and urlconfig. See the commit cf8603a

Why not conditionally include it in the config? It could be controlled via envvar.

1. Add fixtures introduced by pydata app in all tests
2. Mark tests that should fail as expectedFailures
3. Change amount field to one accepted by pydata app
@aditnryn aditnryn force-pushed the test-pydata branch 2 times, most recently from 419a3e4 to c93da36 Compare November 10, 2016 16:28
@aditnryn
Copy link
Author

@chrismedrela Please review.

Copy link
Contributor

@chrismedrela chrismedrela left a comment

Choose a reason for hiding this comment

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

This one is tough, but I think we're pretty close to get this merged. :-)

One general question: right now, we've only one Travis job. It runs tests with pydata enabled. Should not we have another job with pydata disabled?

INSTALLED_APPS.insert(
INSTALLED_APPS.index('workshops'),
'pydata'
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you replace it with:

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'workshops',
]
if ENABLE_PYDATA:
    INSTALLED_APPS += [
        'pydata',
    ]
INSTALLED_APPS += [
    # this should be after 'workshops' because templates in
    # 'templates/registration/' clash
    'django.contrib.admin',
    'crispy_forms',
    'selectable',
    'django_countries',
    'django_filters',
    'reversion',
    'rest_framework',
    'api',
    'extforms',
    'captcha',
    'compressor',
    'social.apps.django_app.default',
    'debug_toolbar',
]

So that INSTALLED_APPS is defined in one place.

Copy link
Author

Choose a reason for hiding this comment

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

Resolved

@@ -338,6 +338,17 @@
},
}

# settings for PyData application
ENABLE_PYDATA = os.environ.get('AMY_ENABLE_PYDATA', False)
Copy link
Contributor

Choose a reason for hiding this comment

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

What are valid values for AMY_ENABLE_PYDATA envvar? Which ones are truthy and which ones are falsy? What if somebody sets AMY_ENABLE_PYDATA=false?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably parse AMY_ENABLE_PYDATA the same way we parse AMY_DEBUG:

json.loads(os.environ.get('AMY_DEBUG', 'true'))

script:
- python manage.py makemigrations --dry-run -e; export STATUS_CODE=$?; if [[ "$STATUS_CODE" == "0" ]]; then exit 1; fi
- coverage run --source=amy,api,workshops manage.py test
Copy link
Contributor

Choose a reason for hiding this comment

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

@pbanaszkiewicz, BTW where does it sends the coverage data?

@narayanaditya95 should we include pydata in --source?

Copy link
Author

@aditnryn aditnryn Nov 10, 2016

Choose a reason for hiding this comment

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

@pbanaszkiewicz, BTW where does it sends the coverage data?

The coverage command generates a report. The coveralls command sends it to Coveralls.

@narayanaditya95 should we include pydata in --source?

I am not sure what will happen if two Travis jobs send coverage data to Coveralls for the same commit. Will it break?
@pbanaszkiewicz

Copy link
Contributor

Choose a reason for hiding this comment

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

The coverage command generates a report. The coveralls command sends it to Coveralls.

Yes, and where is the report available? https://coveralls.io/github/swcarpentry/amy results in 404.

Copy link
Author

Choose a reason for hiding this comment

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

Only @pbanaszkiewicz has the permission to access coveralls.io

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think I ever set up coveralls, but the codebase was ready for it.



if settings.ENABLE_PYDATA:
urlpatterns.insert(1, url(r'^workshops/', include('pydata.urls')))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you change it in a similar way to INSTALLED_APPS?

Copy link
Author

Choose a reason for hiding this comment

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

Resolved

'pydata'
)
PYDATA_USERNAME_SECRET = os.environ.get('AMY_PYDATA_USERNAME')
PYDATA_PASSWORD_SECRET = os.environ.get('AMY_PYDATA_PASSWORD')
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these two settings optional? That is, is None valid value for both username and password?

Copy link
Author

Choose a reason for hiding this comment

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

No. But we have checks in pydata/checks.py to ensure these variables are not None.

Copy link
Contributor

Choose a reason for hiding this comment

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

check_pydata_installed_before_workshops checks only if these variables are set, but doesn't check if they're not None.

Copy link
Author

Choose a reason for hiding this comment

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

Resolved

- AMY_ENABLE_PYDATA=true
AMY_PYDATA_USERNAME=username
AMY_PYDATA_PASSWORD=password
- CHECK_MIGRATION=true
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Is this necessary? We don't have two Travis jobs anymore.
  2. Previously, you couldn't enable pydata and, at the same time, enable migrations checks. What did you changed, that it works now?

Copy link
Author

Choose a reason for hiding this comment

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

  1. Yes, we need two Travis jobs. There are tests that are marked as expected failure by pydata app. We need to explicitly test them.
  2. Even now pydata and migration aren't enabled at the same time. In the first Travis job, pydata is enabled. In the second, we check for migrations along with the standard deployment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see, these lines define two builds.

@chrismedrela
Copy link
Contributor

@pbanaszkiewicz could you review the design?

@@ -33,6 +33,13 @@
SECRET_KEY = None
SECRET_KEY = os.environ.get('AMY_SECRET_KEY', SECRET_KEY)

# settings for PyData application
ENABLE_PYDATA = json.loads(os.environ.get('AMY_ENABLE_PYDATA', 'false'))
Copy link
Author

@aditnryn aditnryn Nov 10, 2016

Choose a reason for hiding this comment

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

I would love to add a layer of abstraction over this expression. :)
It took me a while to realize why json parsing was used here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just add a comment? :-)

@aditnryn
Copy link
Author

@chrismedrela
Addressed all concerns.

@chrismedrela
Copy link
Contributor

@narayanaditya95 thank you for your work on this PR! @pbanaszkiewicz please merge if you like it.

@pbanaszkiewicz pbanaszkiewicz merged commit d92ad89 into carpentries:develop Nov 11, 2016
@aditnryn aditnryn deleted the test-pydata branch November 14, 2016 11:23
@pbanaszkiewicz pbanaszkiewicz modified the milestones: v1.10, v1.9.1 Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants