From 1c11f0950f290ef8401a85afc83becbc95e363e3 Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Sat, 16 Feb 2019 13:34:11 +0200 Subject: [PATCH 1/9] Update django from 2.0.10 to 2.0.13 (#1936) --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 09ca8ddd..e43b70af 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -18,7 +18,7 @@ flower==0.9.2 # https://github.com/mher/flower # Django # ------------------------------------------------------------------------------ -django==2.0.10 # pyup: < 2.1 # https://www.djangoproject.com/ +django==2.0.13 # pyup: < 2.1 # https://www.djangoproject.com/ django-environ==0.4.5 # https://github.com/joke2k/django-environ django-model-utils==3.1.2 # https://github.com/jazzband/django-model-utils django-allauth==0.38.0 # https://github.com/pennersr/django-allauth From 0f8275911bcb297fd88624ddd2137d3ffb9e4ba1 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sat, 16 Feb 2019 03:34:22 -0800 Subject: [PATCH 2/9] Update pytest from 4.2.0 to 4.2.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1fd7fe7c..db6dcb6d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,5 +9,5 @@ flake8==3.7.5 # Testing # ------------------------------------------------------------------------------ tox==3.6.1 -pytest==4.2.0 +pytest==4.2.1 pytest-cookies==0.3.0 From 407ccb64ba1157283973225a357bbe78c30d94e7 Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Wed, 20 Feb 2019 19:10:41 +0200 Subject: [PATCH 3/9] Update pytest from 4.2.1 to 4.3.0 (#1944) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index db6dcb6d..a8db78f9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,5 +9,5 @@ flake8==3.7.5 # Testing # ------------------------------------------------------------------------------ tox==3.6.1 -pytest==4.2.1 +pytest==4.3.0 pytest-cookies==0.3.0 From b09d840b54f6b874a5e35c4cb59162f87d3f4cb5 Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Wed, 20 Feb 2019 19:10:52 +0200 Subject: [PATCH 4/9] Update flake8 from 3.7.5 to 3.7.6 (#1943) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a8db78f9..dabb5dd9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ binaryornot==0.4.4 # Code quality # ------------------------------------------------------------------------------ -flake8==3.7.5 +flake8==3.7.6 # Testing # ------------------------------------------------------------------------------ From 2676401ed79d74881b86821b35e5ce59254b5fd0 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sat, 23 Feb 2019 17:12:19 +1100 Subject: [PATCH 5/9] Update Gulp & other dependencies --- {{cookiecutter.project_slug}}/gulpfile.js | 157 +++++++++++---------- {{cookiecutter.project_slug}}/package.json | 33 ++--- 2 files changed, 101 insertions(+), 89 deletions(-) diff --git a/{{cookiecutter.project_slug}}/gulpfile.js b/{{cookiecutter.project_slug}}/gulpfile.js index bb18a535..1f65b30c 100644 --- a/{{cookiecutter.project_slug}}/gulpfile.js +++ b/{{cookiecutter.project_slug}}/gulpfile.js @@ -1,34 +1,32 @@ +//////////////////////////////// +// Setup +//////////////////////////////// -//////////////////////////////// - //Setup// -//////////////////////////////// +// Gulp and package +const { src, dest, parallel, series, watch } = require('gulp') +const pjson = require('./package.json') // Plugins -var gulp = require('gulp'), - pjson = require('./package.json'), - gutil = require('gulp-util'), - sass = require('gulp-sass'), - autoprefixer = require('gulp-autoprefixer'), - cssnano = require('gulp-cssnano'), - {% if cookiecutter.custom_bootstrap_compilation == 'y' %} - concat = require('gulp-concat'), - {% endif %} - rename = require('gulp-rename'), - del = require('del'), - plumber = require('gulp-plumber'), - pixrem = require('gulp-pixrem'), - uglify = require('gulp-uglify'), - imagemin = require('gulp-imagemin'), - spawn = require('child_process').spawn, - runSequence = require('run-sequence'), - browserSync = require('browser-sync').create(), - reload = browserSync.reload; - +const autoprefixer = require('autoprefixer') +const browserSync = require('browser-sync').create() +{% if cookiecutter.custom_bootstrap_compilation == 'y' %} +const concat = require('gulp-concat') +{% endif %} +const cssnano = require ('cssnano') +const imagemin = require('gulp-imagemin') +const pixrem = require('pixrem') +const plumber = require('gulp-plumber') +const postcss = require('gulp-postcss') +const reload = browserSync.reload +const rename = require('gulp-rename') +const sass = require('gulp-sass') +const spawn = require('child_process').spawn +const uglify = require('gulp-uglify-es').default // Relative paths function -var pathsConfig = function (appName) { - this.app = "./" + (appName || pjson.name); - var vendorsRoot = 'node_modules/'; +function pathsConfig(appName) { + this.app = "./" + (appName || pjson.name) + var vendorsRoot = 'node_modules/' return { {% if cookiecutter.custom_bootstrap_compilation == 'y' %} @@ -47,17 +45,26 @@ var pathsConfig = function (appName) { images: this.app + '/static/images', js: this.app + '/static/js' } -}; +} -var paths = pathsConfig(); +var paths = pathsConfig() //////////////////////////////// - //Tasks// +// Tasks //////////////////////////////// // Styles autoprefixing and minification -gulp.task('styles', function() { - return gulp.src(paths.sass + '/project.scss') +function styles() { + var processCss = [ + autoprefixer(), // adds vendor prefixes + pixrem(), // add fallbacks for rem units + ] + + var minifyCss = [ + cssnano({ preset: 'default' }) // minify result + ] + + return src(paths.sass + '/project.scss') .pipe(sass({ includePaths: [ {% if cookiecutter.custom_bootstrap_compilation == 'y' %} @@ -67,72 +74,80 @@ gulp.task('styles', function() { ] }).on('error', sass.logError)) .pipe(plumber()) // Checks for errors - .pipe(autoprefixer({browsers: ['last 2 versions']})) // Adds vendor prefixes - .pipe(pixrem()) // add fallbacks for rem units - .pipe(gulp.dest(paths.css)) + .pipe(postcss(processCss)) + .pipe(dest(paths.css)) .pipe(rename({ suffix: '.min' })) - .pipe(cssnano()) // Minifies the result - .pipe(gulp.dest(paths.css)); -}); + .pipe(postcss(minifyCss)) // Minifies the result + .pipe(dest(paths.css)) +} // Javascript minification -gulp.task('scripts', function() { - return gulp.src(paths.js + '/project.js') +function scripts() { + return src(paths.js + '/project.js') .pipe(plumber()) // Checks for errors .pipe(uglify()) // Minifies the js .pipe(rename({ suffix: '.min' })) - .pipe(gulp.dest(paths.js)); -}); - + .pipe(dest(paths.js)) +} {% if cookiecutter.custom_bootstrap_compilation == 'y' %} // Vendor Javascript minification -gulp.task('vendor-scripts', function() { - return gulp.src(paths.vendorsJs) +function vendorScripts() { + return src(paths.vendorsJs) .pipe(concat('vendors.js')) - .pipe(gulp.dest(paths.js)) + .pipe(dest(paths.js)) .pipe(plumber()) // Checks for errors .pipe(uglify()) // Minifies the js .pipe(rename({ suffix: '.min' })) - .pipe(gulp.dest(paths.js)); -}); + .pipe(dest(paths.js)) +} {% endif %} // Image compression -gulp.task('imgCompression', function(){ - return gulp.src(paths.images + '/*') +function imgCompression() { + return src(paths.images + '/*') .pipe(imagemin()) // Compresses PNG, JPEG, GIF and SVG images - .pipe(gulp.dest(paths.images)) -}); + .pipe(dest(paths.images)) +} + +// Generate all assets +const generateAssets = parallel( + styles, + scripts, + {% if cookiecutter.custom_bootstrap_compilation == 'y' %}vendorScripts,{% endif %} + imgCompression +) // Run django server -gulp.task('runServer', function(cb) { - var cmd = spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'}); +function runServer(cb) { + var cmd = spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'}) cmd.on('close', function(code) { - console.log('runServer exited with code ' + code); - cb(code); - }); -}); + console.log('runServer exited with code ' + code) + cb(code) + }) +} // Browser sync server for live reload -gulp.task('browserSync', function() { +function initBrowserSync() { browserSync.init( [paths.css + "/*.css", paths.js + "*.js", paths.templates + '*.html'], { proxy: "localhost:8000" - }); -}); + }) +} // Watch -gulp.task('watch', function() { +function watchPaths() { + watch(paths.sass + '/*.scss', styles) + watch(paths.js + '/*.js', scripts).on("change", reload) + watch(paths.images + '/*', imgCompression) + watch(paths.templates + '/**/*.html').on("change", reload) +} - gulp.watch(paths.sass + '/*.scss', ['styles']); - gulp.watch(paths.js + '/*.js', ['scripts']).on("change", reload); - gulp.watch(paths.images + '/*', ['imgCompression']); - gulp.watch(paths.templates + '/**/*.html').on("change", reload); +// Set up dev environment +const dev = parallel( + runServer, + initBrowserSync, + watchPaths +) -}); - -// Default task -gulp.task('default', function() { - runSequence(['styles', 'scripts', {% if cookiecutter.custom_bootstrap_compilation == 'y' %}'vendor-scripts', {% endif %}'imgCompression'], ['runServer', 'browserSync', 'watch']); -}); +exports.default = series(generateAssets, dev) diff --git a/{{cookiecutter.project_slug}}/package.json b/{{cookiecutter.project_slug}}/package.json index b29d5296..a15df941 100644 --- a/{{cookiecutter.project_slug}}/package.json +++ b/{{cookiecutter.project_slug}}/package.json @@ -6,32 +6,29 @@ {% if cookiecutter.js_task_runner == 'Gulp' -%} {% if cookiecutter.custom_bootstrap_compilation == 'y' -%} "bootstrap": "4.1.1", - {% endif -%} - "browser-sync": "^2.14.0", - "del": "^2.2.2", - "gulp": "^3.9.1", - "gulp-autoprefixer": "^5.0.0", - {% if cookiecutter.custom_bootstrap_compilation == 'y' -%} "gulp-concat": "^2.6.1", - {% endif -%} - "gulp-cssnano": "^2.1.2", - "gulp-imagemin": "^4.1.0", - "gulp-pixrem": "^1.0.0", - "gulp-plumber": "^1.1.0", - "gulp-rename": "^1.2.2", - "gulp-sass": "^3.1.0", - "gulp-uglify": "^3.0.0", - "gulp-util": "^3.0.7", - {% if cookiecutter.custom_bootstrap_compilation == 'y' -%} "jquery": "3.3.1", "popper.js": "1.14.3", {% endif -%} - "run-sequence": "^2.1.1" + "autoprefixer": "^9.4.7", + "browser-sync": "^2.14.0", + "cssnano": "^4.1.10", + "gulp": "^4.0.0", + "gulp-imagemin": "^5.0.3", + "gulp-plumber": "^1.2.1", + "gulp-postcss": "^8.0.0", + "gulp-rename": "^1.2.2", + "gulp-sass": "^4.0.2", + "gulp-uglify-es": "^1.0.4", + "pixrem": "^5.0.0" {%- endif %} }, "engines": { - "node": ">=0.8.0" + "node": ">=8" }, + "browserslist": [ + "last 2 versions" + ], "scripts": { {% if cookiecutter.js_task_runner == 'Gulp' -%} "dev": "gulp" From 17a9632031d55ca5bd464f9c8ef79480f99ab48c Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sat, 23 Feb 2019 18:57:42 +1100 Subject: [PATCH 6/9] Add my name to contributors --- CONTRIBUTORS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index e3569e78..e6111cd1 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -57,6 +57,7 @@ Listed in alphabetical order. Andrew Mikhnevich `@zcho`_ Andy Rose Anna Callahan `@jazztpt`_ + Anna Sidwell `@takkaria`_ Antonia Blair `@antoniablair`_ @antoniablairart Anuj Bansal `@ahhda`_ Arcuri Davide `@dadokkio`_ @@ -271,6 +272,7 @@ Listed in alphabetical order. .. _@ssteinerX: https://github.com/ssteinerx .. _@stepmr: https://github.com/stepmr .. _@suledev: https://github.com/suledev +.. _@takkaria: https://github.com/takkaria .. _@timfreund: https://github.com/timfreund .. _@Travistock: https://github.com/Tavistock .. _@trungdong: https://github.com/trungdong From b6b7176d02fc95e03b6bd29b9ec8dcad63f6dd2e Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Wed, 27 Feb 2019 10:11:20 +1100 Subject: [PATCH 7/9] Make requested changes: * Reorder meta tasks to the bottom * Fix JS compilation issue * Replace strings concatenation with templates --- {{cookiecutter.project_slug}}/gulpfile.js | 66 ++++++++++++----------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/{{cookiecutter.project_slug}}/gulpfile.js b/{{cookiecutter.project_slug}}/gulpfile.js index 1f65b30c..d92678ed 100644 --- a/{{cookiecutter.project_slug}}/gulpfile.js +++ b/{{cookiecutter.project_slug}}/gulpfile.js @@ -25,25 +25,25 @@ const uglify = require('gulp-uglify-es').default // Relative paths function function pathsConfig(appName) { - this.app = "./" + (appName || pjson.name) - var vendorsRoot = 'node_modules/' + this.app = `./${pjson.name}` + const vendorsRoot = 'node_modules' return { {% if cookiecutter.custom_bootstrap_compilation == 'y' %} - bootstrapSass: vendorsRoot + '/bootstrap/scss', + bootstrapSass: `${vendorsRoot}/bootstrap/scss`, vendorsJs: [ - vendorsRoot + 'jquery/dist/jquery.slim.js', - vendorsRoot + 'popper.js/dist/umd/popper.js', - vendorsRoot + 'bootstrap/dist/js/bootstrap.js' + `${vendorsRoot}/jquery/dist/jquery.slim.js`, + `${vendorsRoot}/popper.js/dist/umd/popper.js`, + `${vendorsRoot}/bootstrap/dist/js/bootstrap.js`, ], {% endif %} app: this.app, - templates: this.app + '/templates', - css: this.app + '/static/css', - sass: this.app + '/static/sass', - fonts: this.app + '/static/fonts', - images: this.app + '/static/images', - js: this.app + '/static/js' + templates: `${this.app}/templates`, + css: `${this.app}/static/css`, + sass: `${this.app}/static/sass`, + fonts: `${this.app}/static/fonts`, + images: `${this.app}/static/images`, + js: `${this.app}/static/js`, } } @@ -64,7 +64,7 @@ function styles() { cssnano({ preset: 'default' }) // minify result ] - return src(paths.sass + '/project.scss') + return src(`${paths.sass}/project.scss`) .pipe(sass({ includePaths: [ {% if cookiecutter.custom_bootstrap_compilation == 'y' %} @@ -83,7 +83,7 @@ function styles() { // Javascript minification function scripts() { - return src(paths.js + '/project.js') + return src(`${paths.js}/project.js`) .pipe(plumber()) // Checks for errors .pipe(uglify()) // Minifies the js .pipe(rename({ suffix: '.min' })) @@ -105,19 +105,11 @@ function vendorScripts() { // Image compression function imgCompression() { - return src(paths.images + '/*') + return src(`${paths.images}/*`) .pipe(imagemin()) // Compresses PNG, JPEG, GIF and SVG images .pipe(dest(paths.images)) } -// Generate all assets -const generateAssets = parallel( - styles, - scripts, - {% if cookiecutter.custom_bootstrap_compilation == 'y' %}vendorScripts,{% endif %} - imgCompression -) - // Run django server function runServer(cb) { var cmd = spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'}) @@ -130,19 +122,31 @@ function runServer(cb) { // Browser sync server for live reload function initBrowserSync() { browserSync.init( - [paths.css + "/*.css", paths.js + "*.js", paths.templates + '*.html'], { - proxy: "localhost:8000" - }) + [ + `${paths.css}/*.css`, + `${paths.js}/*.js`, + `${paths.templates}/*.html` + ], { + proxy: "localhost:8000" + } + ) } // Watch function watchPaths() { - watch(paths.sass + '/*.scss', styles) - watch(paths.js + '/*.js', scripts).on("change", reload) - watch(paths.images + '/*', imgCompression) - watch(paths.templates + '/**/*.html').on("change", reload) + watch(`${paths.sass}/*.scss`, styles) + watch(`${paths.templates}/**/*.html`).on("change", reload) + watch([`${paths.js}/*.js`, `!${paths.js}/*.min.js`], scripts).on("change", reload) } +// Generate all assets +const generateAssets = parallel( + styles, + scripts, + {% if cookiecutter.custom_bootstrap_compilation == 'y' %}vendorScripts,{% endif %} + imgCompression +) + // Set up dev environment const dev = parallel( runServer, @@ -151,3 +155,5 @@ const dev = parallel( ) exports.default = series(generateAssets, dev) +exports["generate-assets"] = generateAssets +exports["dev"] = dev From aea5c807f6c3d123b5d8dbe7e0ceaa2791abcbee Mon Sep 17 00:00:00 2001 From: keithjeb Date: Sat, 2 Mar 2019 14:51:30 +0100 Subject: [PATCH 8/9] Change eager celery setting in local Docker (#1945) [//]: # (Thank you for helping us out: your efforts mean great deal to the project and the community as a whole!) [//]: # (Before you proceed:) [//]: # (1. Make sure to add yourself to `CONTRIBUTORS.rst` through this PR provided you're contributing here for the first time) [//]: # (2. Don't forget to update the `docs/` presuming others would benefit from a concise description of whatever that you're proposing) ## Description [//]: # (What's it you're proposing?) Added a note around CELERY_TASK_ALWAYS_EAGER = True in docker config for local development. This causes tasks to be executed on the 'main' thread rather than by the workers. I understand why that might be desirable, but thought it worth calling out incase (like me) it makes people think something is broken. ## Rationale [//]: # (Why does the project need that?) Ease of use/troubleshooting ## Use case(s) / visualization(s) [//]: # ("Better to see something once than to hear about it a thousand times.") --- CONTRIBUTORS.rst | 2 ++ docs/developing-locally-docker.rst | 10 ++++++++++ docs/developing-locally.rst | 10 ++++++++++ {{cookiecutter.project_slug}}/config/settings/local.py | 2 ++ 4 files changed, 24 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index e6111cd1..0de1077e 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -180,6 +180,7 @@ Listed in alphabetical order. Denis Bobrov `@delneg`_ Philipp Matthies `@canonnervio`_ Vadim Iskuchekov `@Egregors`_ @egregors + Keith Bailey `@keithjeb`_ ========================== ============================ ============== .. _@a7p: https://github.com/a7p @@ -297,6 +298,7 @@ Listed in alphabetical order. .. _@purplediane: https://github.com/purplediane .. _@umrashrf: https://github.com/umrashrf .. _@ahhda: https://github.com/ahhda +.. _@keithjeb: https://github.com/keithjeb Special Thanks ~~~~~~~~~~~~~~ diff --git a/docs/developing-locally-docker.rst b/docs/developing-locally-docker.rst index 08b25f3b..895140f9 100644 --- a/docs/developing-locally-docker.rst +++ b/docs/developing-locally-docker.rst @@ -171,6 +171,16 @@ When developing locally you can go with MailHog_ for email testing provided ``us .. _Mailhog: https://github.com/mailhog/MailHog/ +.. _`CeleryTasks`: + +Celery tasks in local development +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When not using docker Celery tasks are set to run in Eager mode, so that a full stack is not needed. When using docker the task +scheduler will be used by default. + +If you need tasks to be executed on the main thread during development set CELERY_TASK_ALWAYS_EAGER = True in config/settings/local.py. + +Possible uses could be for testing, or ease of profiling with DJDT. .. _`CeleryFlower`: diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index 09c5db39..3434f68b 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -118,6 +118,16 @@ In production, we have Mailgun_ configured to have your back! .. _Mailgun: https://www.mailgun.com/ +Celery +------ +If the project is configured to use Celery as a task scheduler then by default tasks are set to run on the main thread +when developing locally. If you have the appropriate setup on your local machine then set + +CELERY_TASK_ALWAYS_EAGER = False + +in /config/settings/local.py + + Sass Compilation & Live Reloading --------------------------------- diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py index 741f324a..6667a265 100644 --- a/{{cookiecutter.project_slug}}/config/settings/local.py +++ b/{{cookiecutter.project_slug}}/config/settings/local.py @@ -76,8 +76,10 @@ INSTALLED_APPS += ['django_extensions'] # noqa F405 # Celery # ------------------------------------------------------------------------------ +{% if cookiecutter.use_docker == 'n' -%} # http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-always-eager CELERY_TASK_ALWAYS_EAGER = True +{%- endif %} # http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-eager-propagates CELERY_TASK_EAGER_PROPAGATES = True From 6e72169ffe3022b54db3d44297226226cf86c1e8 Mon Sep 17 00:00:00 2001 From: btknu <48227652+btknu@users.noreply.github.com> Date: Wed, 6 Mar 2019 02:10:45 +0100 Subject: [PATCH 9/9] Add missing `script` key to Travis CI config (#1950) * Add failing test for travis.yml I see three options to test travis.yml : 1. Testing that the YAML contains relevant value. Least useful and least reliable, but simplest to implement. 2. Testing that the YAML is valid TravisCI YAML. Unfortunately this is difficult / impossible. Doing 'travis lint' would succeed, this command does not check for 'script' key presence and wouldn't be useful for us. We could use 'travis-build' to verify that the YAML can be converted to a worker config, but as of now 'travis-build' doesn't work out of the box. There is a new tool for validating travis YAML files 'travis-yml', but as of now it's a ruby-only library and it's still a work in progress. 3. Running Travis CI task based on the generated YAML. This seems the best approach, however since cookiecutter-django itself uses Travis CI, that would require running Travis CI from within Travis CI. Scheduling Travis CI job without a github push still requires a public github repo, which is something that we can't generate on demand. Given that I'm opting to use approach 1. * Adds missing config to generated .travis.yml The keys added are as follows: 1. 'script' Required by Travis, cookiecutter-django used to provide it until it has been removed together with hitch. I'm assuming hitch has been replaced with pytest, I'm setting pytest as the new value for the 'script' key. 2. 'install' Not required by Travis, but necessary in our case; installs test libraries, mostly pytest. As of now this points to 'local.txt' requirements file. There used to be a separate 'test.txt' requirements file but it has been decided to merge it with 'local.txt', see discussion in https://github.com/pydanny/cookiecutter-django/pull/1557 . * Update CONTRIBUTORS.rst --- CONTRIBUTORS.rst | 2 ++ requirements.txt | 1 + tests/test_cookiecutter_generation.py | 17 +++++++++++++++++ {{cookiecutter.project_slug}}/.travis.yml | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 0de1077e..dc41463f 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -71,6 +71,7 @@ Listed in alphabetical order. Bo Lopker `@blopker`_ Bouke Haarsma Brent Payne `@brentpayne`_ @brentpayne + Bartek `@btknu` Burhan Khalid            `@burhan`_                   @burhan Carl Johnson `@carlmjohnson`_ @carlmjohnson Catherine Devlin `@catherinedevlin`_ @@ -299,6 +300,7 @@ Listed in alphabetical order. .. _@umrashrf: https://github.com/umrashrf .. _@ahhda: https://github.com/ahhda .. _@keithjeb: https://github.com/keithjeb +.. _@btknu: https://github.com/btknu Special Thanks ~~~~~~~~~~~~~~ diff --git a/requirements.txt b/requirements.txt index dabb5dd9..37a96913 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ flake8==3.7.6 tox==3.6.1 pytest==4.3.0 pytest-cookies==0.3.0 +pyyaml==3.13 diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index cf173576..b2c235a8 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -1,6 +1,7 @@ import os import re import sh +import yaml import pytest from binaryornot.check import is_binary @@ -85,3 +86,19 @@ def test_flake8_compliance(cookies): sh.flake8(str(result.project)) except sh.ErrorReturnCode as e: pytest.fail(e) + + +def test_travis_invokes_pytest(cookies, context): + context.update({"use_travisci": "y"}) + result = cookies.bake(extra_context=context) + + assert result.exit_code == 0 + assert result.exception is None + assert result.project.basename == context["project_slug"] + assert result.project.isdir() + + with open(f'{result.project}/.travis.yml', 'r') as travis_yml: + try: + assert yaml.load(travis_yml)['script'] == ['pytest'] + except yaml.YAMLError as e: + pytest.fail(e) diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index 5ca54d00..3072f75f 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -9,3 +9,7 @@ before_install: language: python python: - "3.6" +install: + - pip install -r requirements/local.txt +script: + - "pytest"