Giter VIP home page Giter VIP logo

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

Stargazers

 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

nx-orb's Issues

Bug: Does not work in esm projects

Orb version:

1.6.2

What happened:

Got an error, that it can not run a common js script in a type: module package:

file:///tmp/storybook/index.js:2
const { execSync } = require('child_process');
                     ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/tmp/storybook/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///tmp/storybook/index.js:2:22
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)

Node.js v18.19.1

Expected behavior:

Should work also in an ESM environment. Changing the name to index.cjs would fix this. Allthough it is kind of weird that this script is added to the package.

Additional Information:

Orb using with other orbs

Describe Request:

I want use the nx orb with the cypress orb in one pipeline file. This is a frequently used usecase.

Examples:

According to the CircleCi documentation, you can specify several orbs and refer to them with the executor command.

orbs:
cypress: cypress-io/cypress@3
nx: nrwl/[email protected]

jobs:
install:
c
<<: *defaults
steps:
- checkout
...
- nx/set-shas
...

but the nx/default excutor was not found:

circleci config validate
Error: config compilation contains errors: config compilation contains errors:
- Error calling workflow: 'em_check'
- Error calling job: 'install'
- Cannot find a definition for executor named nx/default

Supporting Documentation Links:

https://circleci.com/blog/multiple-orbs-pipeline-config/

Methodology for determining last successful pipeline run doesn't work if there are multiple kinds of pipelines

Orb version: 1.1.2

What happened:

We have a setup for our CD system where we run a particular pipeline when new code is merged to main. That pipeline uses the nx affected commands for building and testing.

When that pipeline is finished, our code is deployed. The deployment event triggers a second pipeline to run which executes e2e tests. That pipeline does not include any Nx commands.

The orb currently interprets a successful completion of either one of these pipelines as the "last successful" run on the main branch. However, only the first "build & test" pipeline is the one that should be considered as a "run". This causes commands that use nx affected to receive the wrong sha.

Expected behavior:

Ideally, the orb would handle for this case by filtering the set of pipelines its getting from the CircleCI API using the name of the pipeline that it's currently running in (if that's possible). Or provide a parameter that can specify the name of the pipeline to watch for.

Wrong query string parameter call results in same page of pipelines

Orb version: 1.6.0

What happened:

We noticed that in some cases the step fails due to a timeout error(10 min in our cases).
When inspecting the logs we noticed that the the set-sha commands seem to "hangs".

Expected behavior:

The set-sha command should alwayes results in FROM and TO commits.

Additional Information:

After some checks and debugging we identify that the error is a result of wrong api call.
The find successful script calls the pipeline api with "page" as a query param, but looking on circleci api here
it expects a "page-token" query param, so the pipeline list always return the same list and if the last successful pipeline is not on the first page the circleci step will hangs.

Add parameter to include not-run as successful workflow

Describe Request:

We are using this orb and we are publishing packages from the ci and updating the repo, with no-ci commit, that does trigger cci but with not-run status.
we want to have a parameter that will include this state as successful workflow.

Calculating BASE SHA on master branch

Orb version:

nrwl/[email protected]

What happened:

I used nx/set-shas in my circleci deployment but by default by main branch is master and in circleci I always get Base SHA as null and the below error.

undefined:1
{:message "Project not found"}
 ^

SyntaxError: Unexpected token : in JSON at position 1
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/home/circleci/project/index.js:138:35)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

Expected behavior:

Ideally it should return the Base SHA and Head SHA

Additional Information:

Here is the output of the Circleci

undefined:1
{:message "Project not found"}
 ^

SyntaxError: Unexpected token : in JSON at position 1
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/home/circleci/project/index.js:138:35)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

Base SHA


Head SHA
4d59078a4a8c8e82c4a47a1258fa74064a1be522


NX_BASE and NX_HEAD environment variables have been set for the current Job
CircleCI received exit code 0

Any assistance you can provide is much appreciated. Thanks!

CircleCI set-shas: Project not found

Orb version: nrwl/[email protected]

What happened:

{:message "Project not found"}
 ^

SyntaxError: Unexpected token : in JSON at position 1
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/home/circleci/project/index.js:110:22)
    at IncomingMessage.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

`main-branch-name: $CIRCLE_BRANCH` always returns the same value for both the `Base SHA` and `Head SHA`

Orb version:

nrwl/[email protected]

What happened:

I pass $CIRCLE_BRANCH to the nx/set-shas command, but I always receive the same value for both the Base SHA and the Head SHA.

Output of Derives SHAs for base and head for use in nx affected commands:

Commit: 3f835dfe18a35cfc74bf4a2773d366f09c298f8b
Base SHA
3f835dfe18a35cfc74bf4a2773d366f09c298f8b

Head SHA
3f835dfe18a35cfc74bf4a2773d366f09c298f8b


NX_BASE and NX_HEAD environment variables have been set for the current Job

Expected behavior:

The Base SHA should represent the last successful workflow run on 'origin/feature-branch'.

Additional Information:

.circleci/config.yml:

version: 2.1

orbs:
  node: circleci/[email protected]
  nx: nrwl/[email protected]

jobs:
  affected_test:
    executor:
      name: node/default
      tag: '18.16.0'
    steps:
      - checkout
      - node/install-packages
      - nx/set-shas:
          main-branch-name: $CIRCLE_BRANCH # <- Use $CIRCLE_BRANCH built-in environment variables
      - run: npx nx affected -t test --base=$NX_BASE --head=$NX_HEAD

workflows:
  lint_and_test_build:
    jobs:
      - affected_test:
          context:
            - circleci # <- Access CircleCI Context to get $CIRCLE_API_TOKEN

Unexpected error with non-existing successfull builds

Orb version:

1.1.2

What happened:

I set up the circleci configuration file for the first time using the guidelines in the documentation but it is not working as expected. It looks like the step nx/set-shas has an error and the rest of the workflow does not proceed the way it was supposed to be.

Expected behavior:

The build should finish with success

Additional Information:

Here is my circleci configuration file:

version: 2.1

# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
# See: https://circleci.com/docs/2.0/orb-intro/
orbs:
  nx: nrwl/[email protected]

jobs:
  build:
    docker:
      - image: cimg/node:14.17-browsers
    steps:
      # ...CI steps like checkout, install...
      - checkout
      - run:
          command: yarn install --frozen-lockfile
          name: Install dependencies
      - nx/set-shas
      - run:
          command: yarn nx affected --target=build --base=$NX_BASE --parallel --max-parallel=3
          name: Run Builds
      - run:
          command: yarn nx affected --target=test --base=$NX_BASE
          name: Run Unit Tests

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows: 
  version: 2
  build:
    jobs:
      - build

Here is the output from circleci:
image

Project Not Found issue with separate workflows

Orb version: 1.1.0

What happened:

We have two workflows: one for opened PRs, and one for post-merge. For the PR workflow, the SHAs get set with no issues. However, post-merge and in the main workflow, the Base SHA never gets set, and instead we get this error:

{:message "Project not found"}

We see an issue from August related to private repos (#2), but it seems to be a different issue given it works for one of our jobs/workflows but not the other.

Expected behavior:

The orb is able to set the Base SHA for all of our jobs/workflows.

Additional Information:

For now, both workflows use the exact same steps, as seen below. Note that I've redacted our tokens, but they are the same value in both jobs.

main:
    docker:
      - image: circleci/node:12
        environment:
          CIRCLE_TOKEN: <redacted>
          NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
    steps:
      - checkout
      - aws-cli/setup:
          profile-name: default
          aws-access-key-id: AWS_ACCESS_KEY_ID
          aws-secret-access-key: AWS_SECRET_ACCESS_KEY
          aws-region: AWS_DEFAULT_REGION
      - run:
          name: token placement
          command: 'echo "//registry.npmjs.org/:_authToken=<redacted> > ~/.npmrc'
      - run: cd 1eq && npm ci
      - nx/set-shas
      - run: cd 1eq && npx nx affected --target=deps --parallel --max-parallel=3
      - run: cd 1eq && npx nx affected --target=build --parallel --max-parallel=3
  pr:
    docker:
      - image: circleci/node:12
        environment:
          CIRCLE_TOKEN:<redacted>
          NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
    steps:
      - checkout
      - aws-cli/setup:
          profile-name: default
          aws-access-key-id: AWS_ACCESS_KEY_ID
          aws-secret-access-key: AWS_SECRET_ACCESS_KEY
          aws-region: AWS_DEFAULT_REGION
      - run:
          name: token placement
          command: 'echo "//registry.npmjs.org/:_authToken=<redacted>" > ~/.npmrc'
      - run: cd 1eq && npm ci
      - nx/set-shas
      - run: cd 1eq && npx nx affected --target=deps --parallel --max-parallel=3
      - run: cd 1eq && npx nx affected --target=build --parallel --max-parallel=3

Our workflows are defined as:

workflows:
  build:
    jobs:
      - main:
          context: AWS
          filters:
            branches:
              only: main
      - pr:
          context: AWS
          filters:
            branches:
              ignore: main

I've joined the @nrwl/community on Slack, so please feel free to reach out.

Pipeline times out when looking for workflow on branches with plenty of pipelines

Orb version:

1.6.0

What happened:

Pipeline times out when Nx tries to resolve the BASE_SHA by Workflow Name from a long-running branches with lots of pipelines executions

image

Expected behavior:

Pipeline is able to resolve BASE_SHA on long-running branches

Additional Information:

Steps to reproduce

  1. Create a repository
  2. Create a Circle CI config.yml file
  3. Trigger a lot of pipeline executions for a single branch
  4. Configure set-shas to look for a workflow-name that does not exist so it runs through all pipelines
    • The problem also applies if the successful workflow was completed in a pipeline that's behind many executions

Support CircleCI Enterprise setups

Describe Request:

I'm looking at using this orb in a self-hosted CircleCI instance, which has a different instance URL. However, it looks like this orb has the public CircleCI Cloud API url hardcoded, meaning this orb is currently not usable for me 😕 .

However, after looking through the codebase, I believe this can be solved with some simple changes (I'm willing to contribute said changes - just wanted to open an issue first to make sure there aren't any additional things I need to consider 😄).

A couple different approaches I think would work:

  • Allow specifying the CircleCI base url via an environment variable, e.g. CIRCLE_BASE_URL, or
  • Modifying the regular expression here to extract the CircleCI instance URL as well as the project url.

I think the second approach makes more sense from a UX perspective, as it requires no changes for users of this orb; however, there could be edge cases with that approach that I'm not seeing.

Examples:

Ideally, this would require no changes from a user perspective beyond (potentially) specifying the CircleCI instance URL as an environment variable.

Supporting Documentation Links:

`Command failed: git merge-base origin/0 HEAD` when running tagged builds

Orb version:

1.6.0

What happened:

When running tagged jobs, the set-shas functionality isn't able to properly resolve the latest successful job and outputs the following:

fatal: Not a valid object name origin/0
node:internal/errors:856
  const err = new Error(message);
              ^

Error: Command failed: git merge-base origin/0 HEAD
fatal: Not a valid object name origin/0

    at checkExecSyncError (node:child_process:841:11)
    at execSync (node:child_process:912:15)
    at /home/circleci/project/index.js:19:16
    at Object.<anonymous> (/home/circleci/project/index.js:53:3)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  status: 128,
  signal: null,
  output: [ null, '', 'fatal: Not a valid object name origin/0\n' ],
  pid: 354,
  stdout: '',
  stderr: 'fatal: Not a valid object name origin/0\n'
}

Base SHA


Head SHA
a2fba2d819a99575b9b3ef5c13e5ec8b5d92fed2


NX_BASE and NX_HEAD environment variables have been set for the current Job
CircleCI received exit code 0

Expected behavior:

  • Base SHA is resolved to the latest passing build

Additional Information:

Repro config.yml

version: 2.1

commands:
  install-packages:
    steps:
      - restore_cache:
          name: Restore Yarn Package Cache
          keys:
            - yarn-packages-{{ checksum "yarn.lock" }}
      - run:
          name: Install Dependencies
          command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn

      - save_cache:
          name: Save Yarn Package Cache
          key: yarn-packages-{{ checksum "yarn.lock" }}
          paths:
            - ~/.cache/yarn

orbs:
  # Official NX Orb: https://github.com/nrwl/nx-orb
  nx: nrwl/[email protected]

jobs:
  workflow-experiment:
    docker:
      - image: cimg/node:16.17

    steps:
      - checkout
      - install-packages

      - nx/set-shas:
          skip-branch-filter: true
          workflow-name: prod-deployment

      - run:
          name: Echo SHAs
          command: echo "base=$NX_BASE   head=$NX_HEAD"

# Tag filtering anchor
filters: &tagFilter
  tags:
    only:  /^v[0-9]+(\.[0-9]+)*$/ # only act on version tags

workflows:
  version: 2

  prod-deployment:
    jobs:
      - workflow-experiment:
          filters: *tagFilter

Build environment variables

Using build environment variables:
  BASH_ENV=/tmp/.bash_env-6323bd61a4378057e83df117-0-build
  CI=true
  CIRCLECI=true
  CIRCLE_BRANCH=
  CIRCLE_BUILD_NUM=508
  CIRCLE_BUILD_URL=[REDACTED]
  CIRCLE_JOB=Deploying to Prod
  CIRCLE_NODE_INDEX=0
  CIRCLE_NODE_TOTAL=1
  CIRCLE_PROJECT_REPONAME=[REDACTED]
  CIRCLE_PROJECT_USERNAME=[REDACTED]
  CIRCLE_REPOSITORY_URL=[REDACTED]
  CIRCLE_SHA1=49244e3e111f667cf626c794a59efc05c7377eb6
  CIRCLE_SHELL_ENV=/tmp/.bash_env-6323bd61a4378057e83df117-0-build
  CIRCLE_TAG=v0.0.8
  CIRCLE_USERNAME=[REDACTED]
  CIRCLE_WORKFLOW_ID=9d7d5ff0-e8ee-4adc-950e-acbb3bfcca9d
  CIRCLE_WORKFLOW_JOB_ID=a781656d-18b7-4f6b-affc-c020cd46631f
  CIRCLE_WORKFLOW_WORKSPACE_ID=9d7d5ff0-e8ee-4adc-950e-acbb3bfcca9d
  CIRCLE_WORKING_DIRECTORY=~/project

Find last successful workflow for tag

Describe Request:

My team uses tags for releases, which currently doesn't work nicely with nx-orb/set-shas as the script always requires a branch name to find the last successful workflow, so it'll never be able to find a previously successful tagged workflow.

As a proposed solution, we would like to omit the branch name entirely and search exclusively by workflow name to find the base SHA.

Usage example:

    steps:
      - checkout
      - nx/set-shas:
          workflow-name: foo-service-production
          ignore-branch-name: true

This flag would essentially allow us to remove the branch name from the CircleCI API call, something like:

async function findSuccessfulCommit(branch, workflowName) {
  const url = `https://${host}/api/v2/project/${project}/pipeline${ignoreBranchName ? '' : `?branch=${branch}`}`;
  // ...

If this seems like a sensible way to go, I'd love to make a PR.

Partial output of our "Preparing Environment Variables" step

Using build environment variables:
  BASH_ENV=/tmp/.bash_env-628e3db1e9fb6411ff4e35e8-0-build
  CI=true
  CIRCLECI=true
  CIRCLE_BRANCH=
  CIRCLE_BUILD_NUM=3259
  CIRCLE_BUILD_URL=<REDACTED>
  CIRCLE_COMPARE_URL=
  CIRCLE_JOB=run-tests-production
  CIRCLE_NODE_INDEX=0
  CIRCLE_NODE_TOTAL=1
  CIRCLE_PREVIOUS_BUILD_NUM=3258
  CIRCLE_PROJECT_REPONAME=<REDACTED>
  CIRCLE_PROJECT_USERNAME=<REDACTED>
  CIRCLE_REPOSITORY_URL=<REDACTED>
  CIRCLE_SHA1=c3e017d5f1a96da934c502975ae047adb5b86b5e
  CIRCLE_SHELL_ENV=/tmp/.bash_env-628e3db1e9fb6411ff4e35e8-0-build
  CIRCLE_STAGE=run-tests-production
  CIRCLE_TAG=v0.0.29
  CIRCLE_USERNAME=denat
  CIRCLE_WORKFLOW_ID=c8d8aa24-dcff-4251-9867-7a0b77a93a71
  CIRCLE_WORKFLOW_JOB_ID=3f70c93c-7e3a-4e73-8dfa-21a2d8ca428c
  CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS=
  CIRCLE_WORKFLOW_WORKSPACE_ID=c8d8aa24-dcff-4251-9867-7a0b77a93a71
  CIRCLE_WORKING_DIRECTORY=~/project

CircleCI API permission issue when using orb in private pipeline

Orb version:

1.0.0

What happened:

I've utilised the orb in my private CircleCI 2.1 config and it works as expected when the base and head branches differ. But when for instance merging a feature branch into main branch where the branch is the same I'm encountering what appears to be a CircleCI permissions error. Here's the job output including the error:

#!/bin/bash
echo "$PARAM_SCRIPT" >> "index.js"
RESPONSE=$(node index.js $CIRCLE_BUILD_URL $CIRCLE_BRANCH $PARAM_MAIN_BRANCH $PARAM_ERROR_ON_NO_SUCCESSFUL_WORKFLOW)
echo "$RESPONSE"
BASE_SHA=$(echo "$RESPONSE" | grep 'Commit:' | sed 's/.*Commit: //')
HEAD_SHA=$(git rev-parse HEAD)
echo "Base SHA"
echo $BASE_SHA
echo ""
echo "Head SHA"
echo $HEAD_SHA
echo ""
echo "export NX_BASE=\"$BASE_SHA\";" >> $BASH_ENV
echo "export NX_HEAD=\"$HEAD_SHA\";" >> $BASH_ENV
echo ""
echo "NX_BASE and NX_HEAD environment variables have been set for the current Job"

undefined:1
{:message "Project not found"}
 ^

SyntaxError: Unexpected token : in JSON at position 1
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/home/circleci/project/index.js:110:22)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1331:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Base SHA


Head SHA
c3f673b41859b03d5ef89724cb1902560ecd0c78


NX_BASE and NX_HEAD environment variables have been set for the current Job
CircleCI received exit code 0

Expected behavior:

As per the docs I expected the orb to retrieve from the CircleCI API a page of previous builds and identify the last successful one, using it's shasum as the value for NX_BASE.

Additional Information:

As seen in the above output NX_BASE environment variable hasn't been populated. Upon analysing the above output and after an initial look at how the orb works, my initial assumption is that the request to the CircleCI API to retrieve the page of successful builds doesn't have the correct permissions. The code doesn't include a CircleCI token header but I initially assumed it may not be necessary given the request originates from within the CircleCI ecosystem?

Something to think about: Is the orb designed and currently used in public CircleCI pipelines and perhaps not tested on private pipelines?

In any case, if I'm doing something daft then please point it out - assistance would be much appreciated.

[email protected] release to circleci orb repo

Orb version:

1.1.0

What happened:

nx: nrwl/[email protected] is not available in the circleci orb repository.

Expected behavior:

Can you publish the latest release to the circleci orb repository?
The current available version is 1.0.0. version 1.1.0 includes the CIRCLE_API_TOKEN change that is necessary to derive the correct SHAs from the circleci API.

Additional Information:

Allow "on_hold" workflows to be detected when deriving SHAs

Describe Request:

Currently, the Nx orb will look to find the last successful workflow when deriving SHAs for Nx affected. Successful, in this case, means the CircleCI workflow has a status of success. However, this does not support main workflows that require manual approvals (e.g. deploy), as those workflows will have a status of on_hold. Because those are not considered failing workflows, we're requesting support for adding an option for the Nx orb to also check for workflows that have a status on_hold in order to support approval-based workflows.

Proposal:

#19

Supporting Documentation Links:

Calculating SHAs on new release branches

Orb version:

nrwl/[email protected]

What happened:

We use master branch commits to drive development builds. We create release branches (release/0.0.x) when we promote to staging/production. When CircleCI runs, the orb returns the same SHAs for BASE/HEAD. As a result, the affected command yields no changes and no applications are built. This in turn requires that we create an additional commit which forces all the applications to rebuild.

Expected behavior:

Ideally all applications should be rebuilt when a new branch is created since there is no previous build on that branch.

Additional Information:

Here is an example of the output from a pipeline based on a new release branch:

#!/bin/bash
echo "$PARAM_SCRIPT" >> "index.js"
RESPONSE=$(node index.js $CIRCLE_BUILD_URL $CIRCLE_BRANCH $PARAM_MAIN_BRANCH $PARAM_ERROR_ON_NO_SUCCESSFUL_WORKFLOW $PARAM_ALLOW_ON_HOLD $PARAM_WORKFLOW_NAME)
echo "$RESPONSE"
BASE_SHA=$(echo "$RESPONSE" | grep 'Commit:' | sed 's/.*Commit: //')
HEAD_SHA=$(git rev-parse HEAD)
echo "Base SHA"
echo $BASE_SHA
echo ""
echo "Head SHA"
echo $HEAD_SHA
echo ""
echo "export NX_BASE=\"$BASE_SHA\";" >> $BASH_ENV
echo "export NX_HEAD=\"$HEAD_SHA\";" >> $BASH_ENV
echo ""
echo "NX_BASE and NX_HEAD environment variables have been set for the current Job"

Commit: 1a4e590311d1af213235f8c06de930675afab9e3
Base SHA
1a4e590311d1af213235f8c06de930675afab9e3

Head SHA
1a4e590311d1af213235f8c06de930675afab9e3


NX_BASE and NX_HEAD environment variables have been set for the current Job
CircleCI received exit code 0

Any assistance you can provide is much appreciated. Thanks!

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.