Skip to content

Commit

Permalink
chore: migrating electrode repo to use rush mono-repo tooling (#1946)
Browse files Browse the repository at this point in the history
* [WIP] Use rush + pnpm for managing monorepo (#1907)

* Add rush config files

* Add few projects for testing install and build

 Author:    Ashu Verma <ashuverma@outlook.com>

* Update Github Workflow to use rush

* Add all the packages and fix dependencies

Include All the packages in the repo into rush.
Fix missing build scripts.
Add missing dependencies.

* Enabling tests. All of them still don't work

* add node 16 in ci (#1901)

* add node 16 in ci

* [fix]: upgrade xarc-opt-sass to pass node 16 build (#1902)

Co-authored-by: Srinath Muthyala <Srinath.reddy.muthyala@walmart.com>
Co-authored-by: mristic505 <mateja.ristic@gmail.com>

* Update github action and fix tests (#1910)

* Update github action and adding in several test fixes with rush

Co-authored-by: Arun Vishnu <arunnampoothiri.vish@walmart.com>

* feat: merge changes from master and fix poc-subapp (#1919)

* add two options for improving webpack performance (#1904)

Co-authored-by: Steve Herzog <vn54bh8@m-c02xf19ujgh7.homeoffice.wal-mart.com>

* feature: open browser when proxy is ready (#1905)

Co-authored-by: Steve Herzog <vn54bh8@m-c02xf19ujgh7.homeoffice.wal-mart.com>

* Fix broken reporter link (#1908)

* Update changelog

* [Publish]

 - @xarc/app@11.0.1
 - @xarc/app-dev@11.0.1
 - @xarc/webpack@11.1.3

* Upgrade poc-subapp and poc-subapp-redux to react18 with rr6 (#1913)

* Upgrade POC-SUBAPP-REDUX to React 18 and RR6

* Upgrade poc-subapp to react 16 and RR6

* fix types issues in multiple packages (#1918)

* fix types issues in multiple packages

Co-authored-by: Arun Vishnu <arunnampoothiri.vish@walmart.com>

* fix: poc-subapp and merge changes from master

* fix: update devtool to use eval-cheap-module-source-map

* chore: remove debug statement

Co-authored-by: Steve Herzog <srherzog@gmail.com>
Co-authored-by: Steve Herzog <vn54bh8@m-c02xf19ujgh7.homeoffice.wal-mart.com>
Co-authored-by: Ashu Verma <ashuverma@outlook.com>
Co-authored-by: smuthya <srinath.reddy.muthyala@walmart.com>
Co-authored-by: mristic505 <mateja.ristic@gmail.com>
Co-authored-by: Arun Vishnu <arunnampoothiri.vish@walmart.com>

* fix poc subapp redux when running with rushx (#1920)

* Upgrade poc-subapp and poc-subapp-redux to react18 with rr6 (#1913)

* Upgrade POC-SUBAPP-REDUX to React 18 and RR6

* Upgrade poc-subapp to react 16 and RR6

* fix types issues in multiple packages (#1918)

* fix types issues in multiple packages

Co-authored-by: Arun Vishnu <arunnampoothiri.vish@walmart.com>

* fix: sample app - poc-subapp-redux

* chore: pnpm-lock updated

* fix: incorrect filename reference in the import statement

* fix: incorrect filename reference in the import statement

Co-authored-by: mristic505 <mateja.ristic@gmail.com>
Co-authored-by: Arun Vishnu <arunnampoothiri.vish@walmart.com>

* feat: add commitlint configs (#1921)

* docs: documentation updates (#1922)

* docs: update readme and contribution guidelines

* docs: documentation and contribution guidelines updated

* docs: update release guidelines

* docs: update release guidelines

* chore: testing package publish flow (#1925)

* fix: update message log

* fix: update message log

* fix: update message log

* cleanup (#1927)

* fix: publish flow

* fix: clean up

* rush test publish package (#1928)

* feat: message update - test rush publish

* feat: message update - test rush publish

* chore: bump versions [skip ci] (#1929)

* developer flow - change file creation - test (#1930)

* feat: message update - test rush publish

* chore: rush change commit

* chore: delete test packages created to test publish flow with rush (#1931)

* docs: update package publishing process with rush (#1933)

* Publishtest (#7)

* feat: add a new test package for publish test

* chore: new package to test publish operation - commiting change files

* chore: bump versions [skip ci]

* docs: update package publishing process with rush

* chore: remove unused files

* chore: remove unused files

* chore: update shrinkwrap file

* docs: update documentation with commitlint details (#1934)

* docs: update documentation with commitlint details

* feat: rebase rush changes with master

* docs: update documentations

* fix: webpack version inconsistency issues

* chore: enable temporarly commented lines in rush branch

* chore: uncommenting a test case  and un necessary console.log

* chore: use rever to use clap keep minimal changes against master branch

* chore: use mocha config same as master branch

* chore: changelog jsons from rush change

* fix: types error in xarc-app-dev package (#8)

* fix: types error in xarc-app-dev package

* docs: update to contribution guidelines

* docs: update to contribution guidelines

* fix: eslint issues in sample apps (#9)

* fix: test issues in sample apps (#10)

* fix: test issues in sample apps

* fix: test issues in sample apps

* chore: allow warnings in successful builds (#11)

* fix: test issues in sample apps

* fix: test issues in sample apps

* chore: allow warnings in successful builds

* chore: allow warnings in successful builds

* fix: tests for node 12 (#12)

* fix: test issues in sample apps

* fix: test issues in sample apps

* fix: tests for node 12

* test: fix unit test failing in subapp-web@2

* chore: update pnpm lock file

* chore: add ci step to verify changelogs available

* chore: add ci step to verify changelogs available

* chore: add ci step to verify changelogs available

---------

Co-authored-by: Ashu Verma <ashuverma@outlook.com>
Co-authored-by: Srinath Muthyala <59977748+smuthya@users.noreply.github.com>
Co-authored-by: Srinath Muthyala <Srinath.reddy.muthyala@walmart.com>
Co-authored-by: mristic505 <mateja.ristic@gmail.com>
Co-authored-by: Arun Vishnu <arunnampoothiri.vish@walmart.com>
Co-authored-by: Steve Herzog <srherzog@gmail.com>
Co-authored-by: Steve Herzog <vn54bh8@m-c02xf19ujgh7.homeoffice.wal-mart.com>
  • Loading branch information
8 people authored Mar 28, 2023
1 parent 29ee5c8 commit 711d5c3
Show file tree
Hide file tree
Showing 213 changed files with 36,344 additions and 29,373 deletions.
14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Don't allow people to merge changes to these generated files, because the result
# may be invalid. You need to run "rush update" again.
pnpm-lock.yaml merge=text
shrinkwrap.yaml merge=binary
npm-shrinkwrap.json merge=binary
yarn.lock merge=binary

# Rush's JSON config files use JavaScript-style code comments. The rule below prevents pedantic
# syntax highlighters such as GitHub's from highlighting these comments as errors. Your text editor
# may also require a special configuration to allow comments in JSON.
#
# For more information, see this issue: https://github.com/microsoft/rushstack/issues/1088
#
*.json linguist-language=JSON-with-Comments
38 changes: 28 additions & 10 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node.
# It then publish a packages to npm registry when PR against a given target branch is merged.
# For more information on github actions see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# For more information on publishing packages see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js CI

on:
push:
branches: [master, next-webpack-5]
branches: [ "master" ]
pull_request:
branches: [master, next-webpack-5]
branches: [ "master" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x]
node-version: [12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm i -g @xarc/run-cli xclap-cli fyn@0.4.37
- run: fyn --pg none install
- run: npm test

# TODO: enable `rush change -v` after rush migration is completed.
# - name: Verify Change Logs
# run: node common/scripts/install-run-rush.js change --verify --target-branch upstream/master

- name: Install
run: node common/scripts/install-run-rush.js install

- name: Build
run: node common/scripts/install-run-rush.js rebuild --verbose

- name: Test
run: node common/scripts/install-run-rush.js test --verbose


10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -521,4 +521,12 @@ yarn-error.log*

# Sample apps
samples/**/dist
samples/**/lib
samples/**/lib
# Rush temporary files
common/deploy/
common/temp/
common/autoinstallers/*/.npmrc
**/.rush/temp/

# Heft temporary files
.heft
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

140 changes: 95 additions & 45 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,43 @@ There are [few guidelines](#contributing-guidelines) that we request contributor

## Getting Started

This repo uses a custom [Lerna] mono-repo setup with [fyn] as package manager to install and local linking node modules.
This is a mono-repo and we use [rushjs] for mono-repo management. Also, we use [pnpm] as the package manager along with [rushjs].
To read more about [rushjs with pnpm]

### Setup

This is a mono-repo and we use [fyn] to install and local linking packages when doing development. You can use `npm run`, but never use `npm install` in our repo else things will break. Below, `fun` is an alias for `npm run` that [fyn] provides.

Install some CLI tools globally for convenience:

```bash
$ npm install -g xclap-cli @xarc/run-cli fyn
```

Fork and clone the repo at <https://github.com/electrode-io/electrode.git> and bootstrap all the packages.

```bash
$ git clone https://github.com/<your-github-id>/electrode.git
$ cd electrode
$ fyn # install node_modules
$ fun bootstrap # run npm script bootstrap
$ npm install -g @microsoft/rush # install rush
$ rush install # installs package dependencies for all packages, based on the shrinkwrap file (pnpm-lock) that got created/updated using rush update.
$ rush build # Run build command on all projects whose source files have changed since the last successful build
```

### Useful Commands

`rush install` - Installs package dependencies for all
packages, based on the shrinkwrap file that is created/updated using "rush update".
It is recommended to use this if you do not want to make changes to *lock files. CI jobs use this command for the same reason.

`rush update` - Installs the dependencies described in the package.
json files, and updates the shrinkwrap file as needed.

`rush build` - Run this command after install step to perform build on all packages. These are incremental builds. In other words, it only builds projects whose source files have changed since the last successful build.

`rush test` - Runs test on all packages. A `test` script is required in package.json for all packages.

`rushx <command>` - Executes `scripts` mentioned in individual packages. This command should be ran within a package directory.

### Try a sample

Now you can go to the `samples` folder and try the `create-app-demo` sample app, develop and test your changes over there. This is the exact same app that our create-app package generates.

```bash
$ cd samples/create-app-demo
$ fyn
$ fun dev
$ rushx dev
```

You should see some output in the console with `[DEV ADMIN]`. You can press `M` for the dev menu.
Expand All @@ -43,19 +51,20 @@ And when you open the browser at `http://localhost:3000`, you should see the dem

### **Useful** Notes

- You should bootstrap the entire repo at the top dir at least once with `fun bootstrap`
- After you make changes to any module under packages, if you want to test them in one of the samples, just run [fyn] in that sample and it will ensure all changed local packages are properly rebuilt and installed.
- You should bootstrap the entire repo at the top dir at least once with `rush install`
- After you make changes to any module under packages, if you want to test them in one of the samples, just run `` rushx <command>`` in that sample and it will ensure all changed local packages are properly rebuilt and installed.


#### Test with `@xarc/create-app`

You can quickly use the `xarc-create-app` package to create an app for testing.

```bash
$ cd samples
$ node ../packages/xarc-create-app/src my-test-app
$ cd my-test-app
$ fyn
$ fun dev
$ cd samples && node ../packages/xarc-create-app/src my-test-app
$ cd ../ && rush update
$ cd samples/my-test-app
$
$ rushx dev
```

## Contributing Guidelines
Expand All @@ -72,25 +81,21 @@ We are using [prettier] to format all our code with only one custom setting: `--
#### PR and Commit messages

Since we use independent lerna mode, to help keep the changelog clear, please format all your commit message with the following guideline:

`[<semver>][feat|bug|chore] <message>`
Since we use commitlint, keep the changelog clear, please format all your commit message with the following guideline:

- `<semver>` can be:
- `major` - `maj` or `major`
- `minor` - `min` or `minor`
- `patch` - `pat` or `patch`
- Only include `[feat|bug|chore]` if it's applicable.
- Only include `feat|bug|chore` if it's applicable.
- Please format your PR's title with the same format.

> **_Please do everything you can to keep commits for a PR to a single package in `packages`._**
A sample commit and PR message should look like:

```text
[minor][feat] implement support for react-query
feat: implement support for react-query
```

Read more about commitlint - https://github.com/conventional-changelog/commitlint/#what-is-commitlint

### Filing Issues

If you need help or found an issue, please [submit a github issue](https://github.com/electrode-io/electrode/issues/new/choose).
Expand All @@ -99,34 +104,79 @@ If you need help or found an issue, please [submit a github issue](https://githu

Our docs use [docusaurus]. The source is in the directory `/docusaurus`. It's generated to `/docs` and published as github docs at <https://www.electrode.io/electrode>.

To edit the docs:
### To run the docs locally:

```bash
$ cd docusaurus
$ fyn
$ fun start
$ pnpm install
$ pnpm start
```

And open your browser to `http://localhost:4000` to view the docs locally.

## Releasing
### To generate documentations to `/docs`:

The versioning of modules in the this repo are all automatically controlled by the commit message.
```bash
$ cd docusaurus
$ pnpm run deploy
```

## Process to publish packages

### Developer flow
- Developers commit all code changes.
- Run `rush change --target-branch <targetBranchWhichIsUsualyMaster>`
- This generates *change files*
- Commit *change files*
- Push the PR, get it reviewd and merged.


### Publish flow

It's important that commits are isolated for the package they affected only and contains the version tags `[major]`, `[minor]`, or `[patch]`. `[patch]` is the default if tag is not found in commit message.
Publishing is a three step process. When its time to publish packages (as per release schedule), make sure below pre-requisites are followed and the latest is pulled from `master` branch

To release, follow these steps:
#### **Pre-requisites for publishing**

- Make sure you have account created at https://www.npmjs.com/ and setup 2FA
- Get access to all packages which you need to publish, you can verify it from here: https://www.npmjs.com/settings/{npm-userid}/packages
- Make sure you have below lines in .npmrc file

```bash
registry=https://registry.npmjs.com/
strict-ssl=false
//registry.npmjs.com/:_authToken={token will be generated}
```

- Use below command to login to npm from commandline
- `npm login`
#### **1. Increase the package versions**
- Run `rush version --bump`
- This is [dry run mode].
- Changes are added to the changelog files for each package.
- The `package.json` files are updated with new version numbers and written to disk. Nothing is actually committed to the source repository or published at this point
- Review the CHANGELOG.md updates at this point

#### **2. Publish Packages**
- Run `rush publish --include-all --publish`
- This will publish all the public packages that have version increased.
- Push the changes as PR to get the `CHANGELOG.md` updated to `master`.

#### **3. Create Tag**
- Add release tag, where <#> is the major archetype version, and <date> as YYYYMMDD (ie: rel-v11-20230327)
- `git tag -a rel-v<#>-date`
- Push the tag created
- `git push origin rel-v<#>-date`


Read more about [rush publishing] and [best practices]

1. Use `xrun update-changelog` to detect packages that changed and their version bumps.
1. Verify and check the file `CHANGELOG.md`, add a summary of key changes under the date.
1. Amend the commit for `CHANGELOG.md` with summary changes.
1. Run `npx fynpo prepare --no-tag` to prepare packages for release.
1. Run `git tag -a rel-v<#>-<date>` where `<#>` is the major archetype version, and `<date>` as `YYYYMMDD`. (ie: `rel-v9-20210301`)
1. Publish the packages that has version bumps.
1. Push the release commits.

[prettier]: https://www.npmjs.com/package/prettier
[lerna]: https://lernajs.io/

[xclap-cli]: https://www.npmjs.com/package/xclap-cli
[fyn]: https://www.npmjs.com/package/fyn
[docusaurus]: https://docusaurus.io/
[rushjs]: https://rushjs.io/pages/intro/welcome/
[rushjs with pnpm]: https://rushjs.io/pages/maintainer/package_managers/
[best practices]: https://rushjs.io/pages/best_practices/change_logs/#recommended-practices
[pnpm]: https://pnpm.io/
[rush publishing]: https://rushjs.io/pages/maintainer/publishing/#dry-run-mode
5 changes: 5 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: [
'@commitlint/config-conventional'
]
}
9 changes: 9 additions & 0 deletions common/autoinstallers/commitlint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "commitlint",
"version": "1.0.0",
"private": true,
"dependencies": {
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0"
}
}
Loading

0 comments on commit 711d5c3

Please sign in to comment.