Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #485 from Financial-Times/deploy-to-both-regions
Browse files Browse the repository at this point in the history
Deploy hashed assets to EU and US
  • Loading branch information
adgad authored Nov 21, 2017
2 parents 0d944a2 + ca8e3a0 commit ba6f91b
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 111 deletions.
198 changes: 99 additions & 99 deletions config/nightwatch.json
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
{
"src_folders": ["test/browser/tests"],
"output_folder": "./test/browser/reports",
"globals_path": "./node_modules/@financial-times/n-heroku-tools/config/nightwatch-globals.js",
"custom_commands_path": "./node_modules/@financial-times/n-heroku-tools/config/nightwatch-commands",
"test_workers": true,
"test_settings": {
"default": {
"end_session_on_fail": false,
"launch_url": "${TEST_URL}",
"selenium_port": 80,
"selenium_host": "ondemand.saucelabs.com",
"screenshots": {
"enabled": true,
"on_failure" : true,
"path": "./test/browser/screenshots"
},
"username": "${SAUCE_USER}",
"access_key": "${SAUCE_KEY}",
"desiredCapabilities": {
"browserName": "chrome",
"version": "latest",
"platform": "Windows 10"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"version": "latest",
"platform": "Windows 10"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox",
"version": "latest",
"platform": "Windows 10"
}
},
"edge": {
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"version": "13.10586",
"platform": "Windows 10"
}
},
"ie11": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": "11.0",
"platform": "Windows 8.1"
}
},
"ie10": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": "10.0",
"platform": "Windows 8"
}
},
"ie9": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": "9.0",
"platform": "Windows 7"
}
},
"ie8": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": "8.0",
"platform": "Windows 7"
}
},
"safari": {
"desiredCapabilities": {
"browserName": "safari",
"version": "latest",
"platform": "OS X 10.11"
}
},
"iphone6_plus": {
"desiredCapabilities": {
"browserName": "Safari",
"deviceName": "iPhone 6 Plus",
"platformVersion": "9.3",
"platformName": "iOS",
"deviceOrientation": "portrait"
}
},
"Android_Nexus7HD": {
"desiredCapabilities": {
"browserName": "Browser",
"deviceName": "Google Nexus 7 HD Emulator",
"platformVersion": "4.4",
"platformName": "Android",
"deviceOrientation": "portrait"
}
}
}
"src_folders": ["test/browser/tests"],
"output_folder": "./test/browser/reports",
"globals_path": "./node_modules/@financial-times/n-heroku-tools/config/nightwatch-globals.js",
"custom_commands_path": "./node_modules/@financial-times/n-heroku-tools/config/nightwatch-commands",
"test_workers": true,
"test_settings": {
"default": {
"end_session_on_fail": false,
"launch_url": "${TEST_URL}",
"selenium_port": 80,
"selenium_host": "ondemand.saucelabs.com",
"screenshots": {
"enabled": true,
"on_failure" : true,
"path": "./test/browser/screenshots"
},
"username": "${SAUCE_USER}",
"access_key": "${SAUCE_KEY}",
"desiredCapabilities": {
"browserName": "chrome",
"version": "latest",
"platform": "Windows 10"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"version": "latest",
"platform": "Windows 10"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox",
"version": "latest",
"platform": "Windows 10"
}
},
"edge": {
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"version": "13.10586",
"platform": "Windows 10"
}
},
"ie11": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": "11.0",
"platform": "Windows 8.1"
}
},
"ie10": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": "10.0",
"platform": "Windows 8"
}
},
"ie9": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": "9.0",
"platform": "Windows 7"
}
},
"ie8": {
"desiredCapabilities": {
"browserName": "internet explorer",
"version": "8.0",
"platform": "Windows 7"
}
},
"safari": {
"desiredCapabilities": {
"browserName": "safari",
"version": "latest",
"platform": "OS X 10.11"
}
},
"iphone6_plus": {
"desiredCapabilities": {
"browserName": "Safari",
"deviceName": "iPhone 6 Plus",
"platformVersion": "9.3",
"platformName": "iOS",
"deviceOrientation": "portrait"
}
},
"Android_Nexus7HD": {
"desiredCapabilities": {
"browserName": "Browser",
"deviceName": "Google Nexus 7 HD Emulator",
"platformVersion": "4.4",
"platformName": "Android",
"deviceOrientation": "portrait"
}
}
}
}
4 changes: 2 additions & 2 deletions ft.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
owner:
github: wheresrhys
email: [email protected]
github: wheresrhys
email: [email protected]
23 changes: 13 additions & 10 deletions tasks/deploy-hashed-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const Metrics = require('next-metrics').Metrics;
const AWS_ACCESS_HASHED_ASSETS = process.env.AWS_ACCESS_HASHED_ASSETS || process.env.aws_access_hashed_assets;
const AWS_SECRET_HASHED_ASSETS = process.env.AWS_SECRET_HASHED_ASSETS || process.env.aws_secret_hashed_assets;

const bucket = 'ft-next-hashed-assets-prod';
const euBucket = 'ft-next-hashed-assets-prod';
const usBucket = 'ft-next-hashed-assets-prod-us';
const region = 'eu-west-1';
const euRegion = 'eu-west-1';
const usRegion = 'us-east-1';
const gzip = denodeify(require('zlib').gzip);

Expand All @@ -24,19 +24,19 @@ function task (opts) {
aws.config.update({
accessKeyId: AWS_ACCESS_HASHED_ASSETS,
secretAccessKey: AWS_SECRET_HASHED_ASSETS,
region
euRegion
});

const s3bucket = new aws.S3({ params: { Bucket: bucket } });
function upload (bucket, params) {

function upload (params) {
const s3Bucket = new aws.S3({ params: { Bucket: bucket } });
return new Promise((resolve, reject) => {
return s3bucket.upload(params, (err, data) => {
return s3Bucket.upload(params, (err, data) => {
if (err) {
console.error('Upload failed', err); // eslint-disable-line no-console
console.error(`Upload failed to ${bucket}`, err); // eslint-disable-line no-console
reject(err);
} else {
console.log('Upload success', data); // eslint-disable-line no-console
console.log(`Upload success to ${bucket}`, data); // eslint-disable-line no-console
resolve();
}
});
Expand Down Expand Up @@ -105,9 +105,12 @@ function task (opts) {
params.ContentType = 'text/css; charset=utf-8';
break;
}
return upload(params)
return Promise.all([
upload(euBucket, params),
upload(usBucket, params)
])
.then(() => Promise.all([
waitForOk(`http://${bucket}.s3-website-${region}.amazonaws.com/${key}`),
waitForOk(`http://${euBucket}.s3-website-${euRegion}.amazonaws.com/${key}`),
waitForOk(`http://${usBucket}.s3-website-${usRegion}.amazonaws.com/${key}`),
isMonitoringAsset ? gzip(content) : Promise.resolve()
]))
Expand Down

0 comments on commit ba6f91b

Please sign in to comment.