From 992c3a890d7fe524a01b40d2cd2e60d6464115c0 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 7 Jun 2018 15:26:47 -0700 Subject: [PATCH] update to mastodon 2.4.0 in travis (#371) * update to mastodon 2.4.0 in travis * lint fix --- CONTRIBUTING.md | 15 ++++++++++++++- bin/run-mastodon.js | 31 +++++++++++++++++++++---------- bin/setup-mastodon-in-travis.sh | 4 ++-- package.json | 2 +- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cac4ab0..ad01706 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,4 +88,17 @@ The Webpack Bundle Analyzer `report.html` and `stats.json` are available publicl - [dev.pinafore.social/report.html](https://dev.pinafore.social/report.html) - [dev.pinafore.social/stats.json](https://dev.pinafore.social/stats.json) -This is also available locally after `npm run build` at `.sapper/client/report.html`. \ No newline at end of file +This is also available locally after `npm run build` at `.sapper/client/report.html`. + +## Updating Mastodon used for testing + +1. Run `rm -fr mastodon` to clear out all Mastodon data +1. Comment out `await restoreMastodonData()` in `run-mastodon.js` to avoid actually populating the database with statuses/favorites/etc. +2. Update the `GIT_TAG` in `run-mastodon.js` to whatever you want +3. Run `npm run run-mastodon` +4. Run `npm run backup-mastodon-data` to overwrite the data in `fixtures/` +5. Uncomment `await restoreMastodonData()` in `run-mastodon.js` +6. Commit all changed files +7. Run `rm -fr mastodon/` and `npm run run-mastodon` to confirm everything's working + +Check `mastodon.log` if you have any issues. \ No newline at end of file diff --git a/bin/run-mastodon.js b/bin/run-mastodon.js index 3fafe7f..5daada9 100644 --- a/bin/run-mastodon.js +++ b/bin/run-mastodon.js @@ -13,19 +13,21 @@ const stat = pify(fs.stat.bind(fs)) const writeFile = pify(fs.writeFile.bind(fs)) const dir = __dirname -const GIT_URL = 'https://github.com/nolanlawson/mastodon' -const GIT_BRANCH = 'for-pinafore' +const GIT_URL = 'https://github.com/tootsuite/mastodon.git' +const GIT_TAG = 'v2.4.0' const DB_NAME = 'pinafore_development' const DB_USER = 'pinafore' const DB_PASS = 'pinafore' +const DB_PORT = process.env.PGPORT || 5432 +const DB_HOST = '127.0.0.1' const envFile = ` PAPERCLIP_SECRET=foo SECRET_KEY_BASE=bar OTP_SECRET=foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar -DB_HOST=127.0.0.1 -DB_PORT=${process.env.PGPORT || 5432} +DB_HOST=${DB_HOST} +DB_PORT=${DB_PORT} DB_USER=${DB_USER} DB_NAME=${DB_NAME} DB_PASS=${DB_PASS} @@ -40,7 +42,8 @@ async function cloneMastodon () { await stat(mastodonDir) } catch (e) { console.log('Cloning mastodon...') - await exec(`git clone ${GIT_URL} --branch ${GIT_BRANCH} --single-branch --depth 1 "${mastodonDir}"`) + await exec(`git clone ${GIT_URL} "${mastodonDir}"`) + await exec(`git checkout ${GIT_TAG}`, { cwd: mastodonDir }) await writeFile(path.join(dir, '../mastodon/.env'), envFile, 'utf8') } } @@ -75,20 +78,28 @@ async function setupMastodonDatabase () { async function runMastodon () { console.log('Running mastodon...') + let env = Object.assign({}, process.env, { + RAILS_ENV: 'development', + NODE_ENV: 'development', + DB_NAME, + DB_USER, + DB_PASS, + DB_HOST, + DB_PORT + }) + let cwd = mastodonDir let cmds = [ 'gem install bundler foreman', 'bundle install', + 'bundle exec rails db:migrate', 'yarn --pure-lockfile' ] for (let cmd of cmds) { console.log(cmd) - await exec(cmd, {cwd: mastodonDir}) + await exec(cmd, {cwd, env}) } - const promise = spawn('foreman', ['start'], { - cwd: mastodonDir, - env: Object.assign({}, process.env, {RAILS_ENV: 'development', NODE_ENV: 'development'}) - }) + const promise = spawn('foreman', ['start'], {cwd, env}) const log = fs.createWriteStream('mastodon.log', {flags: 'a'}) childProc = promise.childProcess childProc.stdout.pipe(log) diff --git a/bin/setup-mastodon-in-travis.sh b/bin/setup-mastodon-in-travis.sh index 8693278..fdf46e6 100755 --- a/bin/setup-mastodon-in-travis.sh +++ b/bin/setup-mastodon-in-travis.sh @@ -8,8 +8,8 @@ if [[ "$COMMAND" = deploy-dev-travis ]]; then fi source "$HOME/.rvm/scripts/rvm" -rvm install 2.5.0 -rvm use 2.5.0 +rvm install 2.5.1 +rvm use 2.5.1 sudo -E add-apt-repository -y ppa:mc3man/trusty-media sudo -E apt-get update diff --git a/package.json b/package.json index 3711cc6..7905b7d 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "deploy-prod": "run-s stage-prod launch alias-prod cleanup", "deploy-dev": "run-s stage-dev launch alias-dev cleanup", "deploy-dev-travis": "if [ $TRAVIS_BRANCH = master -a $TRAVIS_PULL_REQUEST = false ]; then run-s stage-dev launch-travis alias-dev-travis cleanup-travis; fi", - "backup-mastodon-data": "pg_dump -Fc mastodon_development > fixtures/dump.sql && cd mastodon/public/system && tar -czf ../../../fixtures/system.tgz ." + "backup-mastodon-data": "PGPASSWORD=pinafore pg_dump -U pinafore -w mastodon_development > fixtures/dump.sql && cd mastodon/public/system && tar -czf ../../../fixtures/system.tgz ." }, "dependencies": { "@gamestdio/websocket": "^0.2.5",