Giter Club home page Giter Club logo

orb-starter-kit's Introduction

Deprecation Notice

This starter kit has been deprecated in favour of the orb init command included in the CircleCI CLI, which pairs with the new Orb Project Template to make it easier to start up an orb.

Read more about the new process

Orb Starter Kit CircleCI Build Status CircleCI Community

The Orb Starter Kit is a bash utility that makes creating your first orb a breeze!

What are orbs? Orbs are reusable commands, executors, and jobs (as well as usage examples)—snippets of CircleCI configuration—that can be shared across teams and projects. See CircleCI Orbs, Explore Orbs, Creating Orbs, and Using Orbs for further information.

What is in this kit?

This kit includes three main components:

  • Orb init script.
    • The Orb init script will auytomatically generate for you a new GitHub repository with all of the source code needed to get started developing your own orb, complete with automation pipeline
  • Hello World template.
    • Within the /src folder you can find find the destructured source of a simple "Hello World" orb. You can simply copy this code and begin hacking, or initialize it with our orb init script.
  • Automated CI/CD Pipeline.
    • After you run the init script you will also be automatically given a development pipeline to test and update your orb on CircleCI.
    • Automated Semver release process
    • Automated Integration Testing
    • No need to use CLI commands.

Prerequisites

Before getting started you will need the the following things:

  1. A CircleCI account.
  2. Git installed and configured locally.
  3. A CircleCI Personal API Token (Must be Org admin to claim a namespace and publish production Orbs)

Usage

Getting started

1. Clone this repo into a new directory with the name of your orb:

git clone [email protected]:CircleCI-Public/orb-starter-kit.git My-Orb-Name

2. Create a new repository on GitHub with the same name. https://github.com/new

3. Run the orb-init.sh script to begin.

asciicast

The Orb Init script will automate the following tasks:

  • Install and update the CircleCI CLI
  • Request a CircleCI API token if none is currently set.
  • Check to ensure git is installed and authenticated with GitHub.
  • Connect your repository with the blank repo created in step 2.
  • Create and switch to an "Alpha" branch
  • Walk through creating a new orb via the CircleCI CLI
  • Allow you to optionally enable advanced features.
  • Create your customized config file
  • Clean up - The script will remove itself from the repo for the next commit.
  • Commit alpha branch with changes to GitHub.

Your orb will now be available at <your namespace>/<your orb>@dev:Alpha

The script will end by giving you a link to the running automated pipeline on your CircleCI account which will be building a "Hello World" orb.

4. Begin editing.

You may now edit the contents of the /src folder and commit your changes to the Alpha branch or any non-master branch.

5. Build and test!

All commits to non-master branches will automatically result in the creation of a development orb under that branch. The automated pipeline will then run your integration tests against that newly created dev orb.

6. Publish!

Once ready to produce a new production version of your orb, you may merge your branch into the master branch to trigger the automated release process.

Recommended: If you have enabled the fail-if-semver-not-indicated option, your commit message when merging to master MUST include [semver:patch|minor|major|skip] to designate the release type.

You will need to manually publish the production version of your Orb for the initial version before the automated pipeline can update your production version later on. This is not needed on subsequent pushes.

Once the orb is complete, you will have two new Green workflows in your CircleCI account. The first one is for the initial setup and the second one will have produced a development version of your orb which contains a sample Command, Executor, and Job.

Writing your orb

This orb provides a basic directory/file structure for a decomposed orb (where commands, jobs, examples, and executors each live in their own YAML file). Create each of your commands, jobs, examples, and executors within the requisite folders in the src directory.

Following are some resources to help you build and test your orb:

Permissions

Explanation of all permissions required for the script.

  • sudo - The CircleCI CLI Update command will request sudo permissions to update.

Preview

Preview "Hello-World" Orb produced by this repo by default.
commands:
  greet:
    description: |
      Replace this text with a description for this command. # What will this command do? # Descriptions should be short, simple, and clear.
    parameters:
      greeting:
        default: Hello
        description: Select a proper greeting
        type: string
    steps:
    - run:
        command: echo << parameters.greeting >> world
        name: Hello World
description: |
  Sample orb description # What will your orb allow users to do? # Descriptions should be short, simple, and clear.
examples:
  example:
    description: |
      Sample example description. # What will this example document? # Descriptions should be short, simple, and clear.
    usage:
      jobs:
        build:
          machine: true
          steps:
          - foo/hello:
              username: Anna
      orbs:
        foo: bar/[email protected]
      version: 2.1
executors:
  default:
    description: |
      This is a sample executor using Docker and Node. # What is this executor? # Descriptions should be short, simple, and clear.
    docker:
    - image: circleci/node:<<parameters.tag>>
    parameters:
      tag:
        default: latest
        description: |
          Pick a specific circleci/node image variant: https://hub.docker.com/r/circleci/node/tags
        type: string
jobs:
  hello:
    description: |
      # What will this job do? # Descriptions should be short, simple, and clear.
    executor: default
    parameters:
      greeting:
        default: Hello
        description: Select a proper greeting
        type: string
    steps:
    - greet:
        greeting: << parameters.greeting >>
orbs:
  hello: circleci/[email protected]
version: 2.1

orb-starter-kit's People

Contributors

aaronstillwell avatar amithkk avatar ashishpatelcs avatar glenjarvis avatar iynere avatar jrnail23 avatar kyletryon avatar lokst avatar orangegrove1955 avatar parammittal16 avatar sashman avatar scwheele avatar strikerrus avatar topia47 avatar vzvu3k6k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orb-starter-kit's Issues

Create script "Orb init"

What does this do?

The Orb init script will walk you through creating your first Orb via a CLI application. The script will use this project as a template to help the user create an automatic build-test-deploy workflow for Orb development with minimal startup time.

Branch

https://github.com/CircleCI-Public/orb-starter-kit/tree/initScript

Script

https://github.com/CircleCI-Public/orb-starter-kit/blob/initScript/orb-init.sh

Expected behavior

Running the CLI should result in the user publishing their first dev version of their orb with a hello-world command.

Considerations

  • This script is currently not VCS agnostic and will only assist GitHub users.

Handling of expired dev versions?

Is your feature request related to a problem? Please describe.
I really only work on my orbs sporadically, often several months apart. So of course every time I go 90 days between publishing a dev version, that first build fails because the dev:alpha version it depends on has expired.
It's frustrating, and I'm not sure what the best way is to deal with it.

Describe the solution you'd like
I'm all open to whatever solutions or suggestions people may have. I'm curious to find out what others are doing when/if they encounter this.

Describe alternatives you've considered
n/a

Additional context
n/a

Migrate existing orbs to use `orb-starter-kit`

Tried to an existing orbs to use orb-starter-kit.
./orb-init.sh fails because of orb name already exist.

Use case: Separate monorepo into their own respective repositories.

Foreseeable difficulties:

  • handle exist orb names
  • make the new git repo aware of old releases

Questions:
Any workround to migrate existing orbs to use orb-starter-kit?

If using new orb name is the recommanded way, any way to rename an existing circleci orb?

Running the orb-init.sh script failed to build with CircleCI, API token& Personal access token created.

Describe the bug
This happens after I've created a CircleCI account. Git installed and configured locally.
A CircleCI Personal API Token was created, A GitHub Personal Access Token was created.
however, built fail when running the orb-init.sh script.

To Reproduce
Steps to reproduce the behavior:

  1. install circleCI
  2. run command ./orb-init.sh
    errors out:
circleci cli already installed
Error: Failed to query the GitHub API for updates.

This is most likely due to GitHub rate-limiting on unauthenticated requests.

To have the circleci-cli make authenticated requests please:

  1. Generate a token at https://github.com/settings/tokens
  2. Set the token by either adding it to your ~/.gitconfig or
     setting the GITHUB_TOKEN environment variable.

Instructions for generating a token can be found at:
https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

We call the GitHub releases API to look for new releases.
More information about that API can be found here: https://developer.github.com/v3/repos/releases/

: GET https://api.github.com/repos/CircleCI-Public/circleci-cli/releases: 401 Bad credentials []
setting token internally
Error: Failed to query the GitHub API for updates.

This is most likely due to GitHub rate-limiting on unauthenticated requests.

To have the circleci-cli make authenticated requests please:

  1. Generate a token at https://github.com/settings/tokens
  2. Set the token by either adding it to your ~/.gitconfig or
     setting the GITHUB_TOKEN environment variable.

Instructions for generating a token can be found at:
https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

We call the GitHub releases API to look for new releases.
More information about that API can be found here: https://developer.github.com/v3/repos/releases/

: GET https://api.github.com/repos/CircleCI-Public/circleci-cli/releases: 401 Bad credentials []

Testing authentication to GitHub.com
Enter passphrase for key '/Users/vicky/.ssh/id_rsa': 

Expected behavior
running successfully build my first orbs

Bug fix: Make CircleCI CLI update/install optional

The current CLI update method automatically installs the CircleCI CLI via the default method but does not account for Brew or Snap installs.

Check if the CLI is installed first with which, if so, grab the cli.yml file from the path given by the command circleci diagnostic

Linting git pre-commit hook

Is your feature request related to a problem? Please describe.

Linting errors is a relatively common cause of failed pipelines for Orbs.

Describe the solution you'd like

We should add a pre-commit hook for the git repository that automatically lints the project before allowing the commit.

Missing a License File

In order for this repo to properly receive contributions and/or be distributed, it needs an open source license file.

Update Issue Templates

Right now all orbs created using this starter kit are using the classic github style issue templates that pop up an infobox that asks to update to the new, modular issue templates.

This will let feature requests and bugs be separate entities that are automatically labeled

Grammatical mistake in readme

Orb version 2.1.0

What happened

Grammatical mistake in readme

Expected behavior

The grammatical mistake should be removed from readme

[BUG] Namespace and orb creation runs in a loop in orb-init.sh

Orb Version
N/A - Following instructions in README to initialize a new orb. Latest revision as of this writing is 679b1b6.

Describe the bug
Script runs in a perpetual loop asking user to create a namespace and then an orb in that namespace.

Branch 'master' set up to track remote branch 'master' from 'origin'.
Switching to Alpha branch
Switched to a new branch 'Alpha'

Select your Orb namespace.
Each organization/user may claim ONE UNIQUE namespace.

Ensure the name you choose is intended for the mvxt organization, this CAN NOT be changed later.

You may see an error if you have already previously claimed this namespace in the past. This can safely be ignored for now.

Enter Namespace:

Namespace missing. Try again
Select your Orb namespace.
Each organization/user may claim ONE UNIQUE namespace.

Ensure the name you choose is intended for the mvxt organization, this CAN NOT be changed later.

You may see an error if you have already previously claimed this namespace in the past. This can safely be ignored for now.

Enter Namespace: mvxt

You are creating a namespace called "mvxt".

This is the only namespace permitted for your github organization, mvxt.
To change the namespace, you will have to contact CircleCI customer support.

✔ Are you sure you wish to create the namespace: `mvxt`: y
Error: Organizations may only create one namespace. This organization owns the following namespace: "mvxt"

Select your Orb Name. Your Orb will live at mvxt/{ORB NAME}
Enter Orb Name: git-lfs-orb

Orb mvxt/git-lfs-orb selected
Creating Orb
You are creating an orb called "mvxt/git-lfs-orb".
You will not be able to change the name of this orb.
If you change your mind about the name, you will have to create a new orb with the new name.

✔ Are you sure you wish to create the orb: `mvxt/git-lfs-orb`: y
Orb `mvxt/git-lfs-orb` created.

Please note that any versions you publish of this orb are world-readable.

You can now register versions of `mvxt/git-lfs-orb` using `circleci orb publish`.
You are creating a namespace called "mvxt".

This is the only namespace permitted for your github organization, mvxt.
To change the namespace, you will have to contact CircleCI customer support.

✔ Are you sure you wish to create the namespace: `mvxt`: y
Error: Organizations may only create one namespace. This organization owns the following namespace: "mvxt"

Select your Orb Name. Your Orb will live at mvxt/{ORB NAME}
Enter Orb Name:

To Reproduce
Follow steps in README to clone this repo, create a new empty one for the orb, and then execute init.sh.

Expected behavior
Should only ask once.

Feature Request: YAML Anchors for required jobs for production

Create a YAML anchor containing the names of the integration tests triggered on the master branch. This makes it easier to reference in the promotion jobs further on when we need to ensure all tests have pasts before continuing the workflow.

Following this example from the slack orb: https://github.com/CircleCI-Public/slack-orb/blob/staging/.circleci/config.yml#L79

prod-deploy_requires: &prod-deploy_requires
  [
    job,
    names,
    here
  ]

..

# patch, minor, or major publishing
      - orb-tools/dev-promote-prod:
          name: dev-promote-patch
          context: orb-publishing
          orb-name: circleci/slack
          cleanup-tags: true
          ssh-fingerprints: xxx
          requires: *prod-deploy_requires
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /master-patch.*/

Feature Request: Update fingerprints in integration testing

Currently, the commented out integration testing portion of the config is not being automatically configured via the orb-init script as the rest fo the config is.

ssh-fingerprints on line 74, 88, and 102 should be updated automatically.

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.