Code Monkey home page Code Monkey logo

circleci-matrix's Introduction

circleci-matrix

  • Linux: Linux Build
  • OSX: OSX Build

Small utility to mirror TravisCI's build matrix on CircleCI.

Installation

Simply download src/circleci-matrix.sh and make it executable:

curl -fsSL https://raw.githubusercontent.com/michaelcontento/circleci-matrix/master/src/circleci-matrix.sh \
    -o /usr/local/bin/circleci-matrix \
    && chmod +x /usr/local/bin/circleci-matrix

NOTE: The ubuntu user used by CircleCI machines has no permissions to write to /use/local/bin! A good alternative is ~/.local/bin!

As a alternative you could paste this into your circle.yml:

dependencies:
    pre:
    # Install circleci-matrix
    - mkdir -p ~/.local/bin
    - curl -fsSL https://raw.githubusercontent.com/michaelcontento/circleci-matrix/master/src/circleci-matrix.sh -o ~/.local/bin/circleci-matrix
    - chmod +x ~/.local/bin/circleci-matrix

Usage

Then add your build matrix to a new file .circleci-matrix.yml, which is the default name. If you wish to use another name you can set it via the command line option --config/-c ($ circleci-matrix --config my-config.yml).

env:
    - VERSION=5.0
    - VERSION=4.2
    - VERSION=4.1
    - VERSION=4.0

command:
    - echo 'hi!'
    - echo "Version is $VERSION"

Now you're ready to execute it with:

$ circleci-matrix
circleci-matrix version: 0.2.0
circleci node total: 1
circleci node index: 0

-----------------------------------------------------------------
Env: VERSION=5.0
-----------------------------------------------------------------
hi!
Version is 5.0

-----------------------------------------------------------------
Env: VERSION=4.2
-----------------------------------------------------------------
hi!
Version is 4.2

-----------------------------------------------------------------
Env: VERSION=4.1
-----------------------------------------------------------------
hi!
Version is 4.1

-----------------------------------------------------------------
Env: VERSION=4.0
-----------------------------------------------------------------
hi!
Version is 4.0

All commands have been executed with the right value in $VERSION.

Parallelism

CircleCI's parallelism is supported out of the box! Have a look at the following example where I set CIRCLE_NODE_TOTALand CIRCLE_NODE_INDEX manually first to 2 and 0, then to 2 and 1 to simulate two containers:

$ CIRCLE_NODE_TOTAL=2 CIRCLE_NODE_INDEX=0 circle-matrix
circleci-matrix version: 0.2.0
circleci node total: 2
circleci node index: 0

-----------------------------------------------------------------
Env: VERSION=5.0
-----------------------------------------------------------------
hi!
Version is 5.0

-----------------------------------------------------------------
Env: VERSION=4.1
-----------------------------------------------------------------
hi!
Version is 4.1

$ CIRCLE_NODE_TOTAL=2 CIRCLE_NODE_INDEX=1 circle-matrix
circleci-matrix version: 0.2.0
circleci node total: 2
circleci node index: 1

-----------------------------------------------------------------
Env: VERSION=4.2
-----------------------------------------------------------------
hi!
Version is 4.2

-----------------------------------------------------------------
Env: VERSION=4.0
-----------------------------------------------------------------
hi!
Version is 4.0

And here is the output when circleci runs our circle.yml file with 3 containers

Container 0 we see VERSION=5.0 and Version=4.0:

circleci-matrix version: 0.2.0
circleci node total: 3
circleci node index: 0

-----------------------------------------------------------------
Env: VERSION=5.0
-----------------------------------------------------------------
hi!
Version is 5.0

-----------------------------------------------------------------
Env: VERSION=4.0
-----------------------------------------------------------------
hi!
Version is 4.0

Container 1 we see VERSION=4.2:

circleci-matrix version: 0.2.0
circleci node total: 3
circleci node index: 1

-----------------------------------------------------------------
Env: VERSION=4.2
-----------------------------------------------------------------
hi!
Version is 4.2

Container 2 we see VERSION=4.1:

circleci-matrix version: 0.2.0
circleci node total: 3
circleci node index: 2

-----------------------------------------------------------------
Env: VERSION=4.1
-----------------------------------------------------------------
hi!
Version is 4.1

circleci-matrix's People

Contributors

winksaville 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.