GithubHelp home page GithubHelp logo

eladhaim22 / nx-orb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nrwl/nx-orb

0.0 1.0 0.0 169 KB

✨ A CircleCI Orb which includes helpful commands for running Nx commands in the CI

Home Page: https://github.com/nrwl/nx-orb

License: MIT License

Shell 11.59% JavaScript 88.41%

nx-orb's Introduction

Nx - Smart, Extensible Build Framework

NX Orb

CircleCI Build Status CircleCI Orb Version GitHub License CircleCI Community

✨ A CircleCI Orb which includes helpful commands for running Nx commands in the CI

Usage

version: 2.1

orbs:
  nx: nrwl/[email protected]

jobs:
  checks:
    docker:
      - image: cimg/node:lts-browsers
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: yarn install --frozen-lockfile
      - nx/set-shas
      - run:
          name: Run Builds
          command: yarn nx affected --target=build --base=$NX_BASE --parallel
      - run:
          name: Run Unit Tests
          command: yarn nx affected --target=test --base=$NX_BASE --parallel

Background

When we run affected command on Nx, we can specify 2 git history positions - base and head, and it calculates which projects in your repository changed between those 2 commits. We can then run a set of tasks (like building or linting) only on those affected projects.

This makes it easy to set-up a CI system that scales well with the continous growth of your repository, as you add more and more projects.

Problem

Figuring out what these two git commits are might not be as simple as it seems.

On a CI system that runs on submitted PRs, we determine what commits to include in the affected calculation by comparing our HEAD-commit-of-PR-branch to the commit in main branch (master or main usually) from which the PR branch originated. This will ensure the entirety of our PR is always being tested.

But what if we want to set up a continuous deployment system that, as changes get pushed to master, it builds and deploys only the affected projects?

What are the FROM and TO commits in that case?

Conceptually, what we want is to use the absolute latest commit on the master branch as the HEAD, and the previous successful commit on master as the BASE. Note, we want the previous successful one because it is still possible for commits on the master branch to fail for a variety of reasons.

The commits therefore can't just be HEAD and HEAD~1. If a few deployments fail one after another, that means that we're accumulating a list of affected projects that are not getting deployed. Anytime we retry the deployment, we want to include every commit since the last time we deployed successfully. That way we ensure we don't accidentally skip deploying a project that has changed.

This action enables you to find:

  • Commit SHA from which PR originated (in the case of pull_request)
  • Commit SHA of the last successful CI run

Private repositories

To use this orb with a private repository on your main branch, you need to grant the orb access to your CircleCI API. You can do this by creating an environment variable called CIRCLE_API_TOKEN in the context or the project.

Note: It should be a user token, not project token.

License

MIT

Copyright (c) 2021-present Narwhal Technologies Inc.

nx-orb's People

Contributors

meeroslav avatar vsavkin avatar kyletryon avatar abaran30 avatar acburdine avatar jksaunders avatar mandos avatar mattlewis92 avatar wrenzi avatar kenleytomlin avatar

Watchers

James Cloos 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.