Compare commits

...

37 Commits

Author SHA1 Message Date
Buck Doyle
db209f50b5 Parse index key from hostname
My goal is to use the branch name as the subdomain, this
is a step toward that.
2016-04-15 16:34:49 +02:00
Buck Doyle
6b53f583fd Change name of deploy target 2016-04-15 16:13:59 +02:00
Buck Doyle
1aeb2f9016 Add ember-cli-deploy-github
Thanks to @lukemelia for the suggestion.
2016-04-15 15:19:06 +02:00
Buck Doyle
2dff78b0ea Try to get current branch name 2016-04-15 15:05:23 +02:00
Buck Doyle
00be9c26bb Remove S3 prefix 2016-04-15 10:46:22 +02:00
Buck Doyle
1c59f0cf51 Add verbose deployment logging
The assets are seemingly missing from S3.
2016-04-15 10:38:28 +02:00
Buck Doyle
364fe16cfe Fix escaping 2016-04-15 10:07:46 +02:00
Buck Doyle
c2600f27c5 Add more escaping
ugh
2016-04-15 10:00:25 +02:00
Buck Doyle
e788de0acb Use double quotes for substitution 2016-04-15 09:48:57 +02:00
Buck Doyle
3ca1c216f5 Add call to status API
I would be surprised if this worked on the first try!

This uses a GitHub API token from my own account, stored
in an environment variable on Travis. Maybe we need a bot
account of some sort.
2016-04-15 09:38:49 +02:00
Buck Doyle
ab9f89f42b Add filter for deployment of PRs only 2016-04-15 09:27:57 +02:00
Buck Doyle
f9b1b7601e Change domain for asset host 2016-04-14 18:14:20 +02:00
Buck Doyle
dfb80470f6 Add index key option for Redis front-end 2016-04-14 18:10:01 +02:00
Buck Doyle
84ac5f2abf Test 2016-04-14 16:42:40 +02:00
Buck Doyle
067a19a264 Add logging 2016-04-14 16:32:28 +02:00
Buck Doyle
7ed9b4357b Remove tiny Sinatra server 2016-04-14 15:59:32 +02:00
Buck Doyle
a9bd47502d Restore original Ruby server 2016-04-14 15:54:38 +02:00
Buck Doyle
0403884224 Add Redis front-end to existing Ruby server 2016-04-14 15:54:05 +02:00
Buck Doyle
45f90c5ed2 Try other S3 credentials 2016-04-14 14:56:06 +02:00
Buck Doyle
ef73b927e8 Disable some builds for now 2016-04-14 14:47:32 +02:00
Buck Doyle
34444246fd Further refine logging 2016-04-14 14:46:58 +02:00
Buck Doyle
f8ccf9d8d8 Add more logging 2016-04-14 14:24:27 +02:00
Buck Doyle
4e1b2cd140 Add logging 2016-04-14 12:54:13 +02:00
Buck Doyle
0887bf9cde Add deployment link to log
My eventual goal is to use the GitHub Status API to add
this link to the pull request page, but I’m not currently
sure how to accomplish that.
2016-04-14 12:45:07 +02:00
Buck Doyle
770e708552 Disable activation of deployment 2016-04-14 12:22:47 +02:00
Buck Doyle
02e653576a Reduce verbosity of deployment 2016-04-14 12:21:53 +02:00
Buck Doyle
d8446a596c Restrict deployment to only default build 2016-04-14 12:20:28 +02:00
Buck Doyle
ce413fb8fc Convert deploy to after_script 2016-04-14 11:14:06 +02:00
Buck Doyle
fb0e7e16f4 Use existing environment variables 2016-04-14 10:47:23 +02:00
Buck Doyle
a672891b7e Update fingerprint prepended URL 2016-04-14 10:22:17 +02:00
Buck Doyle
8028b694e6 Add preliminary deployment script
I don’t yet know how the `on` option works…?
2016-04-14 10:21:40 +02:00
Buck Doyle
6325fa2e8d Add preliminary deployment configuration
This assumes that, for instance, the S3 credentials are
available as environment variables. There are some decisions
about where to store configuration that need discussion,
this is just to get things going for now.
2016-04-14 10:10:06 +02:00
Buck Doyle
167bd114c5 Add Redis gem 2016-04-13 18:00:29 +02:00
Buck Doyle
95da771778 Fix path to server 2016-04-13 17:55:10 +02:00
Buck Doyle
b921ab5191 Remove Ember CLI buildpack 2016-04-13 17:51:13 +02:00
Buck Doyle
1a84955bd0 Add experimental Redis front-end 2016-04-13 17:45:17 +02:00
Buck Doyle
2b878d8628 Add ember-cli-deploy and lightning pack 2016-04-13 16:08:38 +02:00
8 changed files with 126 additions and 40 deletions

View File

@ -1,2 +1 @@
https://github.com/heroku/heroku-buildpack-ruby.git
https://github.com/travis-ci/travis-web-ember-cli-buildpack.git

View File

@ -4,15 +4,15 @@ node_js: stable
env:
- EMBER_VERSION=default
- EMBER_VERSION=release
- EMBER_VERSION=beta
- EMBER_VERSION=canary
# - EMBER_VERSION=release
# - EMBER_VERSION=beta
# - EMBER_VERSION=canary
matrix:
allow_failures:
- env: EMBER_VERSION=release
- env: EMBER_VERSION=beta
- env: EMBER_VERSION=canary
# - env: EMBER_VERSION=release
# - env: EMBER_VERSION=beta
# - env: EMBER_VERSION=canary
fast_finish: true
@ -46,21 +46,6 @@ notifications:
campfire:
secure: "JJezWGD9KJY/LC2aznI3Zyohy31VTIhcTKX7RWR4C/C8YKbW9kZv3xV6Vn11\nSHxJTeZo6st2Bpv6tjlWZ+HCR09kyCNavIChedla3+oHOiuL0D4gSo+gkTNW\nUKYZz9mcQUd9RoQpTeyxvdvX+l7z62/7JwFA7txHOqxbTS8jrjc="
before_deploy:
- ASSETS_HOST=https://s3.amazonaws.com/travis-error-pages ember build --env production
# delete some of the stuff that's useless for maintenance page
- rm -fr dist/assets/*.js dist/images/emoji dist/index.html dist/images/sponsors
- cp dist/maintenance.html dist/index.html
deploy:
provider: s3
access_key_id: $MAINTENANCE_S3_ACCESS_KEY_ID
secret_access_key: $MAINTENANCE_S3_SECRET_ACCESS_KEY
bucket: travis-error-pages
skip_cleanup: true
acl: public_read
local_dir: dist
region: us-east-1
on:
branch: master
condition: "$EMBER_VERSION = default"
# FIXME this needs refinement, obvs
after_success:
- "test $EMBER_VERSION == 'default' && test $TRAVIS_PULL_REQUEST && ember deploy pull-request --verbose"

View File

@ -8,6 +8,7 @@ gem 'rack-protection', '~> 1.3'
gem 'rack-mobile-detect'
gem 'sinatra'
gem 'hashr'
gem 'redis'
group :development, :test do
gem 'rake'

View File

@ -28,6 +28,7 @@ GEM
rack-test (0.6.2)
rack (>= 1.0)
rake (10.1.1)
redis (3.2.2)
rspec (2.99.0)
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
@ -61,10 +62,11 @@ DEPENDENCIES
rack-protection (~> 1.3)
rack-ssl (~> 1.3)
rake
redis
rspec (~> 2.11)
sinatra
sinatra-contrib
travis-web!
BUNDLED WITH
1.10.1
1.11.2

74
config/deploy.js Normal file
View File

@ -0,0 +1,74 @@
var VALID_DEPLOY_TARGETS = [ //update these to match what you call your deployment targets
'dev',
'qa',
'pull-request'
];
module.exports = function(deployTarget) {
var ENV = {
build: {},
redis: {
allowOverwrite: true,
keyPrefix: 'travis:index'
},
s3: {
bucket: 'travis-web-production-next',
region: 'eu-west-1'
}
};
if (VALID_DEPLOY_TARGETS.indexOf(deployTarget) === -1) {
throw new Error('Invalid deployTarget ' + deployTarget);
}
if (deployTarget === 'dev') {
ENV.build.environment = 'development';
ENV.redis.url = process.env.REDIS_URL;
ENV.plugins = ['build', 'redis']; // only care about deploying index.html into redis in dev
}
if (deployTarget === 'qa' || deployTarget === 'pull-request') {
ENV.build.environment = 'production';
ENV.s3.accessKeyId = process.env.AWS_KEY;
ENV.s3.secretAccessKey = process.env.AWS_SECRET;
}
if (deployTarget === 'qa') {
ENV.redis.url = process.env.QA_REDIS_URL;
}
if (deployTarget === 'pull-request') {
ENV.redis.url = process.env.REDIS_URL;
ENV.github = {
token: process.env.GITHUB_TOKEN,
userOrOrganization: 'travis-ci',
repo: 'travis-web',
publicURL: 'https://travis-web-production-next.herokuapp.com/?index_key={{versionSha}}',
// FIXME is there an environment variable for this?
commitUser: 'backspace',
commitSha: process.env.TRAVIS_COMMIT
};
}
return ENV;
/* Note: a synchronous return is shown above, but ember-cli-deploy
* does support returning a promise, in case you need to get any of
* your configuration asynchronously. e.g.
*
* var Promise = require('ember-cli/lib/ext/promise');
* return new Promise(function(resolve, reject){
* var exec = require('child_process').exec;
* var command = 'heroku config:get REDISTOGO_URL --app my-app-' + deployTarget;
* exec(command, function (error, stdout, stderr) {
* ENV.redis.url = stdout.replace(/\n/, '').replace(/\/\/redistogo:/, '//:');
* if (error) {
* reject(error);
* } else {
* resolve(ENV);
* }
* });
* });
*
*/
}

View File

@ -6,20 +6,17 @@ module.exports = function(defaults) {
var fingerprint,
assetsHost;
// FIXME: this should not have dev hardcoded
var s3Bucket = require('./config/deploy')('dev').s3.bucket;
if (process.env.DISABLE_FINGERPRINTS) {
fingerprint = false;
} else {
fingerprint = {
exclude: ['images/emoji'],
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map', 'svg']
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map', 'svg'],
prepend: '//' + s3Bucket + '.s3.amazonaws.com/',
};
if (assetsHost = process.env.ASSETS_HOST) {
if (assetsHost.substr(-1) !== '/') {
assetsHost = assetsHost + '/'
}
fingerprint.prepend = assetsHost
}
}
var app = new EmberApp({

View File

@ -28,6 +28,9 @@
"ember-cli-autoprefixer": "^0.5.0",
"ember-cli-babel": "^5.1.6",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-deploy": "0.6.0",
"ember-cli-deploy-github": "0.3.0",
"ember-cli-deploy-lightning-pack": "0.6.1",
"ember-cli-deprecation-workflow": "0.1.6",
"ember-cli-document-title": "0.2.0",
"ember-cli-htmlbars": "^1.0.3",

View File

@ -5,6 +5,7 @@ require 'delegate'
require 'time'
require 'json'
require 'travis/utils/deep_merge'
require 'redis'
class Travis::Web::App
autoload :AltVersions, 'travis/web/app/alt_versions'
@ -61,11 +62,21 @@ class Travis::Web::App
end
def call(env)
name = env['travis.alt'] || :default
routers[name] ||= create_router(alt: name)
route = routers[name].call(env)
route[1]["Date"] = Time.now.httpdate
route
# name = env['travis.alt'] || :default
# routers[name] ||= create_router(alt: name)
# route = routers[name].call(env)
# puts "routers"
# puts routers.inspect
# puts "env:"
# puts env
# puts "name: #{name}"
# puts "route!"
# puts route.inspect
# route[1]["Date"] = Time.now.httpdate
# route
req = Rack::Request.new(env)
response_for("index.html", {params: req.params, host: req.host})
end
private
@ -82,7 +93,7 @@ class Travis::Web::App
end
def response_for(file, options = {})
content = File.read(file)
content = content_for(file, options)
if fingerprinted?(file)
headers = {
'Content-Length' => content.bytesize.to_s,
@ -111,6 +122,20 @@ class Travis::Web::App
[ 200, headers, [content] ]
end
def content_for(file, options)
if index?(file)
redis = Redis.new
project = 'travis'
host = options[:host]
index_key = host.split('.')[0] || redis.get("#{project}:index:current")
redis.get("#{project}:index:#{index_key}")
else
content = File.read(file)
end
end
def each_file
Dir.glob(File.join(root, '**/*')) { |file| yield file if File.file?(file) }
end