Coder Social home page Coder Social logo

hoarder's Introduction

Hoarder - don't repeat yourself when compiling!

Build Status Gitter room

Hoarder is the set of sbt plugins (for sbt 1.0.x and 0.13.x) that allows you to reuse compilation data from other workspaces (aka. Cached compilation).

Hoarder is based on zinc (from this PR).

The idea is simple: your code is compiled many times (e.g. during CI builds) and results are usually trashed. Instead, it's better to distribute classfiles (together with the cached compilation metadata) and don't repeat this work again and again.

Using caches will not make your local workspace read-only. Once a cache is imported, it will work exactly as locally compiled one (all following compilations will be normal, incremental ones).

Getting started

In order to use Hoarder in your project just add it as a standard sbt plugin (for a given project or globally):

addSbtPlugin("com.github.romanowski" % "hoarder" % "1.0.2")

Hoarder does not have any stable release so far, and you can track progress for sbt 0.13.x and 1.0.x

Integration with your project

Hoarder can be used in your project in multiple ways (workflows) described below. For now onlt few are supported but there's more to come (feel free to create issues with your own ideas).

Stash workflow

Stash workflow allows you to stash compilation results similarly to changes in git. Running stash task will store your current compilation data in a global directory for your project and later you can import that compilation using stashApply command. More can be found in docs.

The stash workflow can be useful to avoid recompilation in a gitlab-ci pipeline.

Cached PR verfication builds (e.g. Travis ones)

This workflow main goal is speed up of PR verification builds incrementally recompiling changes in PR.

There are 2 parts of this workflow: PR verification build (that use generated cached to speed up compilation) and build after PR is merged (that performs full compilaiton to be super safe and generate caches for future PR verification builds).

Hoarder allows anyone to define custom PR integration by providing new CachedCI.Setup instance.

Hoarder also provides predefine integrations e.g. for Travis. In order to use it (Travis one) all you need to do is:

  • create custom autoplugin with configuration in project that extends one of predefined flows e.g.
// project/CachedCi.scala
import org.romanowski.hoarder.actions.ci.TravisPRValidation

object CachedCi extends TravisPRValidation.PluginBase 
  • add cache definition to your build definition (usually.travis.yml file)
cache:
  directories:
  - .hoarder-cache
  • add hoarder sbt preBuild and sbt postBuild tasks around your build commands, e.g.
- sbt preBuild 
- sbt <your-original-build-command>
- sbt postBuild

Minimal example configuration for ensime-server can be found in this PR.

More can be found in docs.

From release

Not implemented yet. See #2 for more details.

Cached compilation. How does it work?

Zinc incremental compiler (previously part of sbt) beside classfiles generates incremental compilation metadata that allows it later to recompile only the subset of classfiles. In this PR zinc was able to export that metadata in format that can be reused.

hoarder's People

Contributors

2m avatar mpociecha avatar pdolega avatar pmpfr avatar romanowski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.