Common scripts for testing our Discourse plugins on Travis CI
Перейти к файлу
Leo McArdle 9712ebb538
reflect upgrade to postgres 12
2020-06-23 11:54:59 +01:00
.travis.yml initial scripts 2018-08-07 19:36:40 +01:00
CODE_OF_CONDUCT.md Add COC and update README with bug reports section 2019-05-29 14:18:19 +01:00
LICENSE Initial commit 2018-08-07 17:24:40 +01:00
README.md Add COC and update README with bug reports section 2019-05-29 14:18:19 +01:00
before_script.sh initial scripts 2018-08-07 19:36:40 +01:00
entrypoint.sh reflect upgrade to postgres 12 2020-06-23 11:54:59 +01:00
plugin_helper.rb initial scripts 2018-08-07 19:36:40 +01:00
script.sh initial scripts 2018-08-07 19:36:40 +01:00

README.md

discourse-mozilla-travis

Inspired by https://meta.discourse.org/t/setting-up-plugin-continuous-integration-tests-on-travis-ci/59612

This repo holds the scripts we use across our Discourse plugins to run tests in Travis CI and check coverage on Coveralls.

Incorporating these scripts into a plugin is a multi-step process:

Set up Travis CI

Enable Travis CI for the repo of the plugin in question.

.travis.yml is a travis config file which runs these scripts, it should be placed in the root of a plugin repo.

A Travis cron job should be set up to run every day to test the plugin against the latest upstream code.

Set up Coveralls

Enable Coveralls for the repo of the plugin in question.

This code must be run at the very top of every spec:

if ENV["COVERALLS"] || ENV["SIMPLECOV"]
  require "simplecov"

  if ENV["COVERALLS"]
    require "coveralls"
    SimpleCov.formatter = Coveralls::SimpleCov::Formatter
  end

  SimpleCov.start do
    root File.expand_path("../..", __FILE__)
    add_filter "spec/"
    add_filter "db/migrate"
    add_filter "gems/"
  end
end

require "rails_helper"

For inconvenience plugin_helper.rb contains this code, and if placed in the plugin's spec/ folder, it can be included in specs with:

require_relative "plugin_helper"

(which must also go at the very top of every spec)

This won't test coverage of code in a plugin's plugin.rb file, so all testable code should be moved into a separate file which can be included with require_relative.

When run locally it'll also place output in the coverage/ folder, so this should be added to the repo's .gitignore.

Checklist

  • Enable Travis CI
  • Include .travis.yml
  • Set up Travis cron job
  • Enable Coveralls
  • Include plugin_helper.rb
  • Move testable code out of plugin.rb
  • Add coverage to .gitignore
  • Add build status and coverage status badges to README.md

Bug reports

Bug reports should be filed by following the process described here.

Licence

GPL-2.0

.travis.yml and plugin_helper.rb also licensed under MPL-2.0