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

Remove generated files & Misc fixes #763

Merged
merged 21 commits into from
Nov 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
24919db
Remove all of the generated dist files from our repository
dstufft Nov 19, 2015
b61468a
Build the static files as part of the build process of Warehouse
dstufft Nov 19, 2015
7634953
Remove the bower installed items from the source tree
dstufft Nov 19, 2015
6a0c3ec
Pin to exact versions in bower.json
dstufft Nov 19, 2015
9604dfc
Install items with bower during the build process
dstufft Nov 19, 2015
ad63ea8
Ensure that the deploy requirements get installed in docker
dstufft Nov 20, 2015
8234ea0
Move the theme into it's own requirements file
dstufft Nov 20, 2015
4af5c79
Build our static files inside of docker
dstufft Nov 20, 2015
7deb5fc
Add make targets to clean and purge
dstufft Nov 20, 2015
cfe65fb
Run our gulp dist task on a Heroku deploy
dstufft Nov 20, 2015
13fb991
We no longer need this post_compile task
dstufft Nov 20, 2015
983d196
Install gulp and bower
dstufft Nov 20, 2015
4310060
Install our npm development dependencies
dstufft Nov 20, 2015
0b9d7fb
Switch to a different plugin for handling sequences
dstufft Nov 20, 2015
bdf45d3
Clean up some of our files in our compiled slug
dstufft Nov 20, 2015
16afc44
Remove more files form our compiled slug
dstufft Nov 20, 2015
36c8755
Build the dist files on Travis
dstufft Nov 20, 2015
fe26f8a
Install the locales so click can run inside of Docker
dstufft Nov 20, 2015
1875582
Use the correct requirements file
dstufft Nov 20, 2015
83907ff
Fix ``gulp watch``
dstufft Nov 20, 2015
35ae1ed
Allow passing in the encoding to use
dstufft Nov 20, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ dev/example.sql
./data/

warehouse/.commit
warehouse/static/components
warehouse/static/dist

requirements.txt
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ cache:
install:
- pip install -U pip setuptools wheel codecov
- pip install -r requirements/docs.txt -r requirements/lint.txt -r requirements/main.txt -r requirements/tests.txt
- npm install bower gulp
- npm install

script: bin/tests --dbfixtures-config tests/dbfixtures.travis.conf
script:
- gulp dist
- bin/tests --dbfixtures-config tests/dbfixtures.travis.conf

matrix:
include:
Expand Down
24 changes: 19 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ FROM python:3.5.0-slim
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /app/

# Setup the locales in the Dockerfile
RUN set -x \
&& apt-get update \
&& apt-get install locales -y \
&& locale-gen en_US.UTF-8

# Install Warehouse's Dependencies
RUN set -x \
&& apt-get update \
&& apt-get install libpq5 libffi6 postgresql-client --no-install-recommends -y \
&& apt-get install curl -y \
&& curl -sL https://deb.nodesource.com/setup_4.x | bash - \
&& apt-get install git libpq5 libffi6 postgresql-client --no-install-recommends nodejs -y \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Expand All @@ -24,17 +32,23 @@ WORKDIR /app/
# Install Warehouse
RUN set -x \
&& apt-get update \
&& apt-get install gcc libpq-dev libffi-dev --no-install-recommends -y \
&& apt-get install gcc make libpq-dev libffi-dev --no-install-recommends -y \
&& rm -rf node_modules \
&& npm install -g npm \
&& npm install -g bower node-gyp gulp-cli \
&& npm install \
&& pip install -U pip setuptools \
&& pip install -r requirements/main.txt -r requirements/dev.txt \
&& pip install -r requirements/dev.txt \
-r requirements/deploy.txt \
-r requirements/main.txt \
-r requirements/tests.txt \
# Uncomment the below line if you're working on the PyPI theme, this is a
# private repository due to the fact that other people's IP is contained
# in it.
# && pip install -c requirements/main.txt -r requirements/deploy.txt \
# && pip install -c requirements/main.txt -r requirements/theme.txt \
&& find /usr/local -type f -name '*.pyc' -name '*.pyo' -delete \
&& rm -rf ~/.cache/ \
&& apt-get purge gcc libpq-dev libffi-dev -y \
&& apt-get purge gcc make libpq-dev libffi-dev -y \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
52 changes: 30 additions & 22 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
var del = require("del"),
gulp = require("gulp"),
gulpSequence = require("gulp-sequence"),
imagemin = require("gulp-imagemin"),
imageminOptipng = require("imagemin-optipng"),
install = require("gulp-install"),
mainBowerFiles = require("main-bower-files"),
minifyCSS = require("gulp-minify-css"),
modernizr = require("gulp-modernizr"),
path = require("path"),
rename = require("gulp-rename"),
revAll = require("gulp-rev-all"),
runSequence = require("run-sequence"),
sass = require("gulp-sass"),
sassLint = require("gulp-sass-lint"),
uglify = require("gulp-uglify");
Expand All @@ -21,12 +22,13 @@ var srcPaths = {
sass: "warehouse/static/sass/"
}


var dstPaths = {
base: "warehouse/static/dist/",
components: "warehouse/static/dist/components/",
css: "warehouse/static/dist/css/",
images: "warehouse/static/dist/images/",
js: "warehouse/static/dist/js/"
base: "warehouse/static/dist",
components: "warehouse/static/dist/components",
css: "warehouse/static/dist/css",
images: "warehouse/static/dist/images",
js: "warehouse/static/dist/js",
}


Expand All @@ -39,7 +41,11 @@ gulp.task("lint:sass", function() {

gulp.task("lint", ["lint:sass"]);

gulp.task("dist:components:collect", ["clean:components"], function() {
gulp.task("dist:components:install", function() {
return gulp.src(["bower.json"]).pipe(install({ allowRoot: true }));
})

gulp.task("dist:components:collect", function() {
return gulp.src(mainBowerFiles(), { base: srcPaths.components })
.pipe(gulp.dest(dstPaths.components));
});
Expand All @@ -57,21 +63,22 @@ gulp.task("dist:components:css", function() {
});


gulp.task("dist:components", function() {
return runSequence(
gulp.task("dist:components", function(cb) {
return gulpSequence(
"dist:components:install",
"dist:components:collect",
["dist:components:js", "dist:components:css"]
);
)(cb);
});

gulp.task("dist:css", ["clean:css"], function() {
gulp.task("dist:css", function() {
return gulp.src(path.join(srcPaths.sass, "*.scss"))
.pipe(sass({ includePaths: [srcPaths.sass] }))
.pipe(minifyCSS({ keepBreaks: true }))
.pipe(gulp.dest(dstPaths.css));
});

gulp.task("dist:images", ["clean:images"], function() {
gulp.task("dist:images", function() {
return gulp.src(path.join(srcPaths.images, "**", "*"))
.pipe(
imagemin({
Expand All @@ -84,7 +91,7 @@ gulp.task("dist:images", ["clean:images"], function() {
.pipe(gulp.dest(dstPaths.images));
});

gulp.task("dist:js", ["clean:js"], function() {
gulp.task("dist:js", function() {
return gulp.src(path.join(srcPaths.js, "**", "*"))
.pipe(uglify({ preserveComments: "license" }))
.pipe(gulp.dest(dstPaths.js));
Expand All @@ -97,7 +104,7 @@ gulp.task("dist:modernizr", function() {
.pipe(gulp.dest(dstPaths.components));
});

gulp.task("dist:manifest", ["clean:manifest"], function() {
gulp.task("dist:manifest", function() {
var revision = new revAll({ fileNameManifest: "manifest.json" });

return gulp.src(path.join(dstPaths.base, "**"))
Expand All @@ -107,12 +114,13 @@ gulp.task("dist:manifest", ["clean:manifest"], function() {
.pipe(gulp.dest(dstPaths.base));
});

gulp.task("dist", function() {
return runSequence(
["dist:components", "dist:css", "dist:images", "dist:js"],
"dist:modernizr",
"dist:manifest"
);
gulp.task("dist", function(cb) {
return gulpSequence(
"clean",
["dist:components", "dist:css", "dist:images", "dist:js"],
"dist:modernizr",
"dist:manifest"
)(cb);
});

gulp.task("clean:components", function() {
Expand All @@ -137,8 +145,8 @@ gulp.task("clean", [
"clean:manifest"
]);

gulp.task("watch", function() {
gulp.watch(path.join(srcPaths.sass, "*.scss"), ["default"]);
gulp.task("watch", ["dist"], function() {
return gulp.watch(path.join(srcPaths.sass, "*.scss"), ["dist"]);
});

gulp.task("default", ["dist"]);
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ default:
requirements/deploy.txt: .state/env/pyvenv.cfg requirements/deploy.in
.state/env/bin/pip-compile requirements/deploy.in > requirements/deploy.txt

grep '# pypi-theme' requirements/deploy.in | sed 's/# //' >> requirements/deploy.txt

echo "" >> requirements/deploy.txt
echo "# Add additional search locations" >> requirements/deploy.txt
echo "-f https://github.com/benoitc/gunicorn/archive/master.zip#egg=gunicorn-19.4.dev" >> requirements/deploy.txt

requirements/main.txt: .state/env/pyvenv.cfg requirements/main.in
.state/env/bin/pip-compile requirements/main.in > requirements/main.txt

.state/docker-build: Dockerfile requirements/main.txt requirements/deploy.txt
.state/docker-build: Dockerfile package.json requirements/main.txt requirements/deploy.txt
# Build our docker containers for this project.
docker-compose build

Expand All @@ -49,7 +47,7 @@ serve: .state/docker-build
docker-compose up

tests:
docker-compose run web env -i bin/tests --dbfixtures-config tests/dbfixtures.conf $(TESTARGS)
docker-compose run web env -i ENCODING="C.UTF-8" bin/tests --dbfixtures-config tests/dbfixtures.conf $(TESTARGS)

lint: .state/env/pyvenv.cfg
$(BINDIR)/flake8 .
Expand All @@ -70,4 +68,13 @@ initdb:
shell:
docker-compose run web python -m warehouse shell

.PHONY: default build serve initdb shell tests docs
clean:
rm -rf warehouse/static/components
rm -rf warehouse/static/dist

purge: clean
rm -rf .state
docker-compose rm --force


.PHONY: default build serve initdb shell tests docs clean purge
12 changes: 11 additions & 1 deletion bin/post_compile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@
set -e
set -x

pip install -c requirements/main.txt -r requirements/deploy.txt
# Clean up after ourselves
rm -rf node_modules .npm .cache .config .local

# Remove items which are not important for Heroku deploys
rm -rf dev docs requirements requirements.txt tests
rm -rf .bowerrc .coveragerc .dockerignore .gitignore .travis.yml babel.cfg
rm -rf bower.json CONTRIBUTING.rst docker-compose.yml Dockerfile Gulpfile.js
rm -rf package.json README.rst runtime.txt setup.cfg

# We don't need Node installed at runtime, so we'll remove it
rm -rf .heroku/node
10 changes: 10 additions & 0 deletions bin/pre_compile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@
set -e
set -x

# Write out what commit we were built from.
if [[ $SOURCE_VERSION ]]; then
echo "$SOURCE_VERSION" > warehouse/.commit
fi

# Create our requirements.txt file that Heroku will use to build.
echo "-r requirements/main.txt" > requirements.txt
echo "-r requirements/deploy.txt" >> requirements.txt
echo "-r requirements/theme.txt" >> requirements.txt

# We need to install gulp and bower
npm install -g gulp bower
npm install

# Build our Static files before doing anything else.
gulp dist
4 changes: 2 additions & 2 deletions bin/tests
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -x
# Click requires us to ensure we have a well configured environment to run
# our click commands. So we'll set our environment to ensure our locale is
# corrct.
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL="${ENCODING:-en_US.UTF-8}"
export LANG="${ENCODING:-en_US.UTF-8}"

# Actually run our tests.
python -m coverage run -m pytest --strict $@
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"tests"
],
"dependencies": {
"jquery": "~2.1.4",
"font-awesome": "~4.4.0"
"jquery": "2.1.4",
"font-awesome": "4.4.0"
},
"overrides": {
"font-awesome": {
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ app:
build: .
volumes:
- .:/app/
- /app/node_modules/
environment:
WAREHOUSE_ENV: development
WAREHOUSE_TOKEN: insecuretoken
Expand Down Expand Up @@ -61,3 +62,8 @@ worker:
- redis
- rabbitmq
- elasticsearch

static:
extends:
service: app
command: gulp watch
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
"del": "^2.1.0",
"gulp": "^3.9.0",
"gulp-imagemin": "^2.4.0",
"gulp-install": "^0.6.0",
"gulp-minify-css": "^1.2.1",
"gulp-modernizr": "0.0.0",
"gulp-rename": "^1.2.2",
"gulp-rev-all": "^0.8.22",
"gulp-sass": "^2.1.0",
"gulp-sass-lint": "^1.1.0",
"gulp-sequence": "^0.4.1",
"gulp-uglify": "^1.5.1",
"imagemin-optipng": "^4.3.0",
"main-bower-files": "^2.9.0",
"run-sequence": "^1.1.4"
"main-bower-files": "^2.9.0"
},
"private": true
}
4 changes: 0 additions & 4 deletions requirements/deploy.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
-f https://github.com/benoitc/gunicorn/archive/master.zip#egg=gunicorn-19.4.dev

# This is commented out so that pip-compile doesn't see it, if it did then it
# would try to resolve it, and that would fail.
# pypi-theme==1.8

gevent>=1.1a1
gunicorn>=19.4.dev
setproctitle
1 change: 0 additions & 1 deletion requirements/deploy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ gevent==1.1rc1
greenlet==0.4.9 # via gevent
gunicorn==19.4.dev0
setproctitle==1.1.9
pypi-theme==1.8

# Add additional search locations
-f https://github.com/benoitc/gunicorn/archive/master.zip#egg=gunicorn-19.4.dev
1 change: 1 addition & 0 deletions requirements/theme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pypi-theme==1.8
36 changes: 0 additions & 36 deletions warehouse/static/components/font-awesome/.bower.json

This file was deleted.

Loading