Logo

dev-resources.site

for different kinds of informations.

Rush configuration

Published at
9/15/2024
Categories
azure
devops
rush
bicep
Author
kkazala
Categories
4 categories in total
azure
open
devops
open
rush
open
bicep
open
Author
7 person written this
kkazala
open
Rush configuration

This post outlines the configuration needed to implement rush orchestration for the following purposes:

  • Ensuring developers may document changes before submitting a Pull Request
  • Incrementing the version number of each Azure template according to the type of change
  • Automatically generating change logs based on the descriptions provided by developers

Image description

Getting started

โ„น๏ธ If you want to tag along, you will find the repo I'm using in this sample here: Rush-for-IaC-Before.

The initial configuration follows the usual process of setting up a new repo:

  • install rush: npm install -g @microsoft/rush
  • clone or initialize your repo
  • generate rush configuration files; inside your project directory run rush init --overwrite-existing.


npm install -g @microsoft/rush
cd c:\\REPO_ROOT
rush init  --overwrite-existing


Enter fullscreen mode Exit fullscreen mode

You only need --overwrite-existing if you are adding rush to an existing project. It won't override your Bicep templates. See Use "rush init" to initialize your repo for a summary of files that will be created

You will now see a new rush.json file and a common folder in the root directory of your project.

New file and folder created

Rush configuration

Using rush in the IaC project will require few extra changes compared to the usual setup of Node projects.

Add package.json files

Add a package.json file to each folder containing Bicep template.

package.json files added

This is because rush operates within the Node.js and JavaScript/TypeScript ecosystem, where package.json files define project metadata, dependencies, etc. Rush is using this files to find projects is managed, and to increase versions.

Define the template name (used later in rush.json) and an initial version number:

AzureTemplates/FunctionApp/package.json



{
    "name": "function-app",
    "version": "0.0.1"
}


Enter fullscreen mode Exit fullscreen mode

AzureTemplates/ApplicationInsights/package.json



{
    "name": "application-insights",
    "version": "0.0.1"
}


Enter fullscreen mode Exit fullscreen mode

Configure rush

I keep my config really simple, focusing on basics: repository URL, email validation and most importantly, the projects references.

Depending on your repo, you may want to update the gitPolicy with a domain of your company. If the repo will be public, consider using your commit email address.

โš ๏ธ Replace the rushVersion, pnpmVersion and nodeSupportedVersionRange with the currently installed versions.

Update the projects element with references to folders that contain your Bicep templates. This part is important, because Rush does not automatically scan for projects using wildcards.

rush.json



{
  "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json",
  "rushVersion": "5.134.0",
  "pnpmVersion": "9.10.0",
  "nodeSupportedVersionRange": ">=18.20.3 <19.0.0 || >=20.14.0 <21.0.0",
  "projectFolderMaxDepth": 3,
  "gitPolicy": {
    "versionBumpCommitMessage": "chore: Bump versions [skip ci]",
    "changeLogUpdateCommitMessage": "chore: Update changelogs [skip ci]",
    "allowedEmailRegExps": [
      "[^@]+@users\\.noreply\\.github\\.com"
    ],
    "sampleEmail": "[email protected]"
  },
  "repository": {
    "url": "https://github.com/kkazala/Rush-for-IaC-Before.git",
    "defaultBranch": "main",
    "defaultRemote": "origin"
  },

  "projects": [
    {
      "packageName": "function-app",
      "projectFolder": "AzureTemplates/FunctionApp",
      "versionPolicyName": "AzTemplateSpecs"
    },
    {
      "packageName": "application-insights",
      "projectFolder": "AzureTemplates/ApplicationInsights",
      "versionPolicyName": "AzTemplateSpecs"
    }
  ]
}


Enter fullscreen mode Exit fullscreen mode

You will find the default rush.json file here: rush.json.

Configure version policies

In Rush, version policies are a way to define how the versions of different packages in a monorepo should be managed and incremented. These policies help maintain consistency in versioning, automate version bumps, and control how packages are released. They are especially useful when you have many interdependent packages in a monorepo, and you want to establish clear rules for versioning and publishing them.

common\config\rush\version-policies.json



[
  {
    "definitionName": "individualVersion",
    "policyName": "AzTemplateSpecs"
  }
]


Enter fullscreen mode Exit fullscreen mode

Quick test

Typically you would run rush update to install packages required by your projects. We are not building a Node project here, so let's jump right into the test.

Run rush change -v to ensure everything is configured correctly.



rush change -v


Enter fullscreen mode Exit fullscreen mode

Since I'm still in main branch and didn't make any changes to the templates, it returns "No changes were detected to relevant packages on this branch. Nothing to do."

Rush change versify

Branch policy

You may use the rush change -v command to ensure that Pull Request is only accepted if change files have been generated. Use it in a pipeline defined in a build validation policy on main branch.

If changes to the code were made but no change files can be found for the project, you will see an error: "ERROR: The following projects have been changed and require change descriptions, but change descriptions were not detected for them: [...]"

Release management

Release managers execute rush version --bump to increase package version based on version policies. The version is saved in the package.json files. At the same time, the change files created by rush change command (common/changes folder) are used to generate/update changelog.js and changelog.md files.



rush version --bump


Enter fullscreen mode Exit fullscreen mode

If needed, release managers may update the changelog.js file and regenerate the changelog.md using rush publish --regenerate-changelogs.



rush publish --regenerate-changelogs


Enter fullscreen mode Exit fullscreen mode

โ„น๏ธ You will find the results of the above changes in the rush branch of the Rush-for-IaC-Before repo.

Next step: Set version numbers in Bicep templates.

bicep Article's
30 articles in total
Favicon
Deploying and Configuring a Hybrid Identity Lab Using Bicep - Part 1: Active Directory Setup and Sync
Favicon
How to setup an Azure Machine Learning Workspace securely๐Ÿ›ก๏ธ๐Ÿ”’๐Ÿ”‘
Favicon
Creating a Custom Role for Secure Bicep Deployments in Azure
Favicon
Create a GitHub pipeline to test, review, and deploy a Bicep template.
Favicon
A KeyVault for the Power Platform
Favicon
Kickstart projects with azd Templates
Favicon
Conditional deployment in Azure Bicep
Favicon
Rush configuration
Favicon
user-defined type in Azure Bicep, an introduction
Favicon
Set version numbers in Bicep templates
Favicon
Securing your Azure deployments with PSRule
Favicon
Versioned Bicep templates- Deployment
Favicon
Change Management in Infrastructure as a Code (IaC)
Favicon
Azure Verified Modules: Consolidated Standards for a Good IaC
Favicon
Getting Started with Azure Bicep
Favicon
Using Azure Bicep to deploy MS Graph resources
Favicon
Deploying static webs apps with the Azure cli and bicep
Favicon
Azure API Management: Harnessing Bicep for Effortless User and Subscription Creation
Favicon
User-defined function in Azure Bicep
Favicon
Expose your Open API specs with Azure API management
Favicon
Deploy multiple APIs in Azure API management, hosted in the same App service.
Favicon
Add Azure Developer CLI deployment ID and UTC timestamp to Bicep files
Favicon
๐Ÿฆพ Top 5 Azure Bicep tips & tricks to get started ๐Ÿš€
Favicon
Exploring the awesome Bicep Test Framework ๐Ÿงช
Favicon
The issue of recursive module calls in declarative infrastructure-as-code
Favicon
Azure Bicep - Finally functions to manipulate CIDRs
Favicon
Multi Scopes Deployment with Azure Bicep
Favicon
Azure Deployment Stacks, deploy and manage a landing zone with Bicep
Favicon
Azure Open AI: handling capacity and quota limits with Bicep
Favicon
Learn bicep based on the GUI of Azure Portal

Featured ones: