From c5612a39814b6a41d0bfd71bfe25fa25b93e8f7c Mon Sep 17 00:00:00 2001 From: CJ Bryan Date: Sat, 29 Feb 2020 20:13:29 -0800 Subject: [PATCH] Switch from Travis CI to GitHub Actions (#27) * Try installing a few deps * Install Node, Ruby, and attach a Postgres instance * Match the installed version of ruby with the one in ruby-version * Use a clever method for finding the current ruby version https://github.com/actions/setup-ruby/issues/31#issuecomment-561144368 * Oops, gotta checkout the code before reading the version * Bump to the latest patch version of Ruby * Bump the Gemfile too * Health check the Postgres instance and split out the bundle step * use the latest Postgres, reformat the heallth check * Point Rails at the service container * Switch back to port mapping postgres to the local machine * Manually set up the postgres instance and use DATABASE_URL for telling Rails where to look * Deploy using GitHub workflows * Use secrets store * Setup both api. and git. for Heroku * Specify the Heroku app to deploy to * Double check current config * debug heroku auth * Work that netrc * try and preserve newlines when writing netrc * Be extra specific with the GH branch we want to push * Only deploy on master * I read the docs * Install specific node versions * Cache Node Modules runs * Cache Ruby dependencies * Ditch Travis Switch the build badge from Travis to GH Actions ayy wow Clobber the remote ref Fix a Gemfile Ruby version issue Fetch the whole repository because Heroku wants it Keep the Heroku app names secret and Deploy to Production --- .github/workflows/test.yml | 106 +++++++++++++++++++++++++++++++++++++ .ruby-version | 2 +- .travis.yml | 25 --------- Gemfile | 2 +- Gemfile.lock | 2 +- README.md | 2 +- 6 files changed, 110 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..658980e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,106 @@ +on: [push] +jobs: + build: + name: Test + runs-on: ubuntu-latest + + services: + postgres: + image: postgres + ports: ['5432:5432'] + env: + POSTGRES_USER: test-a-bot + POSTGRES_PASSWORD: toot + POSTGRES_DATABASE: rubbish-heap + + steps: + - name: Get Code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install Dependencies + run: | + sudo apt-get install ffmpeg -y + sudo apt-get install youtube-dl + + - name: Fetch Ruby Version + id: ruby_version + run: echo "::set-output name=RUBY_VERSION::$(cat .ruby-version)" + + - name: Install Ruby + uses: actions/setup-ruby/@v1 + with: + ruby-version: ${{ steps.ruby_version.outputs.RUBY_VERSION }} + + - name: Fetch Node Version + id: node_version + run: echo "::set-output name=NODE_VERSION::$(cat .nvmrc)" + + - name: Install Node + uses: actions/setup-node@v1 + with: + node-version: ${{ steps.node_version.outputs.NODE_VERSION }} + + - name: Fetch Yarn Cache Directory + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: Configure Yarn Cache + uses: actions/cache@v1 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install Node Packages + run: yarn + + - name: Configure Ruby Cache + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + + - name: Install Ruby Packages + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + - name: Build and Test with Rake + env: + DATABASE_URL: postgres://test-a-bot:toot@localhost/rubbish-heap + RAILS_ENV: test + run: | + bundle exec rails db:setup + bundle exec rails test + + - name: Write Heroku Credentials + env: + NETRC: | + machine api.heroku.com + login ${{ secrets.HEROKU_USER }} + password ${{ secrets.HEROKU_API_KEY }} + + machine git.heroku.com + login ${{ secrets.HEROKU_USER }} + password ${{ secrets.HEROKU_API_KEY }} + + run: echo $NETRC > ~/.netrc + + - name: Push to Heroku, Staging + if: github.ref == 'refs/heads/master' + run: | + heroku git:remote --app ${{ secrets.STAGING_APP_NAME }} + git push --force heroku HEAD:master + + - name: Push to Heroku, Production + if: github.ref == 'refs/heads/production' + run: | + heroku git:remote --app ${{ secrets.PRODUCTION_APP_NAME }} + git push --force heroku HEAD:master diff --git a/.ruby-version b/.ruby-version index ec1cf33..57cf282 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.3 +2.6.5 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f99c71a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: ruby -services: - - postgresql -before_install: - - sudo apt-get update -q - - sudo apt-get install ffmpeg -y - - sudo apt-get install youtube-dl - - sudo apt-get install imagemagick - - nvm install 10 - - nvm use 10 -before_script: - - psql -c 'create database imploder_test;' -U postgres - - bundle exec rails db:schema:load - - yarn install -script: - - bundle exec rails assets:precompile - - bundle exec rspec -deploy: - provider: heroku - api_key: - secure: "x4t9eOKPi5iO//Cl9uzlYpiuvhG+VMpIWKk67QdCXbWGQ0wjUFwldqbxsge741qdo4OCXi1gCPTyYD7mfqpJXW2ODArqoFnvKNl87gabIO9HTEeVyrHuvE5TzilR1JhMWpM4n+MVfv3pLW7702luUxnvR6ijL0BfzzHhzNndJJab0iM8+HKJaxyiS/XLjTIKoLYhtRgImyj4C93z8f3En8h6IC+RQstsurTLAgL+YO5XLXcM9nxNQU+7HPWd05YkUd2eIH8+qbDQBU1xyOYmsQ+zZ94fD30h5t1XpqMbqjBX/ulqlVXi/vLWMan+ZOHx+TjXsbCCfyCIMmhFLzv0lnnD0vYr9zAfmacanr2Xs9x+99dtHhtL2sdgYv/lTZ/CcmMBFt3+Qmh3zilKL7UX8C/zoQA+kNeUzbr2WBgYU9il00AN86IeODnmkLSWf1YF+crJ3/5VwMYSHPofAN3VUbJdQ4eqm+QztLABU0xYxxs63ucUoV+Q4RjZAR2EaZ+F1UYWumiDvfrmc8bE4QMIzSH22uAWDcDGyLb+O1xJtiyyTLWeHzl5x0IzwNyKC71uma095fXHGwGn7c4VVOqtaJuDBLfuyH7qnH/OF9ekCzBcmQQPuqmm5hldxpE8tYRhPctHdXducVG5XxzGAKbqgpnynzHZrnA2S8+Y6fVVPjI=" - app: - master: imploder-staging - run: - - "bundle exec rails db:migrate" diff --git a/Gemfile b/Gemfile index 030175c..8a4791e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -ruby '2.6.3' +ruby '2.6.5' gem 'rails', '5.2.3' diff --git a/Gemfile.lock b/Gemfile.lock index 7c8bb21..87a963a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -289,7 +289,7 @@ DEPENDENCIES webpacker (~> 3.5) RUBY VERSION - ruby 2.6.3p62 + ruby 2.6.5p114 BUNDLED WITH 1.17.2 diff --git a/README.md b/README.md index 2f2c3f0..ddf21d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [Imploder](http://imploder.xyz) -[![Build Status](https://travis-ci.org/waltz/imploder.svg?branch=master)](https://travis-ci.org/waltz/imploder) +![.github/workflows/test.yml](https://github.com/waltz/imploder/workflows/.github/workflows/test.yml/badge.svg) Take your favorite GIF, mix in some audio from a YouTube track, and turn it in to a short video.