Skip to main content

Git Workflows

This package provides each developer with a dedicated local copy of the project, creating an isolated environment for them to work in independently of any changes made by other team members. By adding commits to their local repository, developers can operate autonomously and only need to synchronize with upstream developments when it suits their workflow.

Directory Structure

This is a command line interface (CLI) to enable users to create and configure commit hooks for their repository. This creates a directory structure like this:

  • .github
    • workflows
      • nx-affected-apps.yaml
      • nx-affected-master.yaml
      • nx-affected-pull-request.yaml
      • nx-build-app.yaml

This folder structure is important it demonstrates that the generator works. It is well suited to the needs of the majority of our projects which benefit from libraries and features being shared across multiple applications.

The Genesisx CLI uses the git workflows command line interface to setup using post commit hooks.

Usage

To create Git Workflows, you can follow the steps outlined below:

Pre-requisites

  • Make sure you are on correct version of Nodejs 18.x and Nx Version 16.6
    node --version
    nx --version
  • To start with, create a new GenesisX workspace in an empty directory, run below command, of if you already have the workspace ready , please skip this step.
    npx @genesisx/create-workspace
    • Provide the requested parameters
    • Provide name to your workspace like test-workspace
    • Move to the created workspace - cd test-workspace
    • Install the packages
      yarn install
  • Install Git Workflows package
    yarn add @genesisx/git-workflows
  • Now follow either of the two modes(mentioned below) to use this generator - either the Nx Console or CLI

Via Nx Console

Generate app using Nx console

  • Goto Generate > search for @genesisx/git-workflows:application
  • Fill in the form
    • name: name of the workflow
    • directory: location of the workflow
    • tags: workflow tags

Via Command Line

To integrate this package in your application, use below command:

nx generate @genesisx/git-workflows:git-workflows --no-interactive 

How it works

Following workflows are added to the Nx workspace when you execute this generator plugin.

Nx Affected Apps

  • This workflow has to be manually triggered as required.
  • Takes "Feature branch" and "Base Branch" as input as input.
  • Compare "Feature Branch" with the "Base Branch" to list out the apps that are affected with the changes made in the - - - "Feature Branch"

Nx Affected Apps - Pull Request

  • This workflow gets triggered when a pull request is opened for any feature branch.
  • Provides the following output
  • List of apps that are affected with the changes made in the feature branch
  • A template to unit test the apps that are affected with the changes
  • Provided dummy templates for workflow stages viz., Build Image, Publish Image

Nx Affected Apps - Master(Base Branch)

  • This workflow gets triggered when a commit is pushed to base branch(When a PR is merged to the base branch).
  • Provides the following output
  • List of apps that are affected with the changes made in the latest commit
  • A template to unit test the apps that are affected with the changes
  • Provided dummy templates for workflow stages viz., Build Image, Publish Image

Generators & Plugins

Nx provides a large number of generators and executors that can be used by installing plugins. There are a huge number of community maintained plugins which can be found in the Nx Plugin Directory and officially supported plugins for all major frameworks:

GenesisX Plugins

The goal of the Genesis project is to accelerate development and increase quality by providing templates that encapsulate best practices through generators that can be run against your project. Genesis plugins are installed into the node_modules directory and can be run from the command line or from the Nx console in Visual Studio Code. You can also "eject" a plugin which will convert it into a workspace generator which you can customize as required.

Testing the app

To execute unit test cases run:

nx run git-workflows:test

Running build and lints

To build the CLI, execute the following command in your terminal:

nx run git-workflows:build

To execute lint checks run:

nx run git-workflows:lint

More details & Troubleshooting

Visit the troubleshooting guide for common issues or refer to the readme.md file located within the package folder

<workspace-folder>/node_modules/@genesisx/git-workflows/README.md