Git Product home page Git Product logo

environment-example-sifive's Introduction

Overview

This package can be used to create a wake runner that will set environment variables for jobs from JSON values based on the resources they request. A default runner is also included with this package.

Resources

Resources describe a tool that is requested by a job. They are strings. This package expects resources to have the format {vendor}/{tool}/{version}. If there is no vendor then the format is {tool}/{version}.

Usage

To use this you need to create a JSON file that maps resources to a JSON object representing the environment variables you want to set when that resource is requested. The JSON should be a series of nested objects where the keys correspond to the {vendor}/{tool}/{version} or {tool}/{version} format above. version keys should be exact versions, not version match expressions.

{
  "google": {
    "protobuf": {
      "3.5.1": {
        "PATH": "/protobuf/bin"
      }
    }
  },
  "verilator": {
    "4.008": {
      "PATH": "/verilator/bin",
      "VERILATOR_ROOT": "/verilator"
    }
  }
}

Then you need to publish a list of Paths to your JSON files to environmentJSONs.

publish environmentJSONs = source "path/to/environment.json", Nil

Now when a wake job requests the resource google/protobuf/>=3.5.0, /protobuf/bin will be added to the PATH environment variable for that job.

The version portion of the resource string can be an exact version or version match expression. A version match is determined by the semverMatches wake function. semverMatches uses the python semver (see link for match expression documentation) package to check whether the version matches.

Making your own runner

This package defines the global function makeJSONEnvironmentRunner that takes a JSONEnvironmentRunnerPlan and returns a Runner. You can use this to make your own runner if you would like to use a different version matching function or a different set of JSONs. This also defines semverMatches, which is the python semver matching function described above.

Example:

publish runner = (
  def name = "myRunner"
  def scoreFn baseScore = baseScore +. 2.0
  def semverMatchFn = semverMatches
  def jvalues = subscribe myRunnerJValues
  def baseRunner = defaultRunner
  makeJSONEnvironmentRunnerPlan name scoreFn semverMatchFn jvalues baseRunner
  | makeJSONEnvironmentRunner
), Nil

environment-example-sifive's People

Contributors

albertchen-sifive avatar jackkoenig avatar mmjconolly avatar richardxia avatar terpstra 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.