Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrating electrode repo to use rush mono-repo tooling #1946

Merged
merged 33 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
55d26c6
[WIP] Use rush + pnpm for managing monorepo (#1907)
ashuverma Oct 20, 2022
ef8391f
add node 16 in ci (#1901)
smuthya Oct 21, 2022
fb0eaff
Update github action and fix tests (#1910)
arunvishnun Dec 2, 2022
c05a970
feat: merge changes from master and fix poc-subapp (#1919)
arunvishnun Dec 28, 2022
9e07f1b
fix poc subapp redux when running with rushx (#1920)
arunvishnun Dec 29, 2022
776374f
feat: add commitlint configs (#1921)
arunvishnun Jan 4, 2023
0891ab3
docs: documentation updates (#1922)
arunvishnun Jan 10, 2023
5c01867
chore: testing package publish flow (#1925)
arunvishnun Jan 12, 2023
fef001f
cleanup (#1927)
arunvishnun Jan 12, 2023
10ec000
rush test publish package (#1928)
arunvishnun Jan 13, 2023
7f8daf7
chore: bump versions [skip ci] (#1929)
arunvishnun Jan 13, 2023
cfd5414
developer flow - change file creation - test (#1930)
arunvishnun Jan 13, 2023
bf6741f
chore: delete test packages created to test publish flow with rush (#…
arunvishnun Jan 13, 2023
2848dfc
docs: update package publishing process with rush (#1933)
arunvishnun Jan 16, 2023
4b42459
docs: update documentation with commitlint details (#1934)
arunvishnun Jan 16, 2023
669fcc4
feat: rebase rush changes with master
arunvishnun Jan 20, 2023
7ff130a
docs: update documentations
arunvishnun Jan 20, 2023
c10b580
fix: webpack version inconsistency issues
arunvishnun Jan 20, 2023
90386e8
chore: enable temporarly commented lines in rush branch
arunvishnun Jan 20, 2023
149da01
chore: uncommenting a test case and un necessary console.log
arunvishnun Jan 20, 2023
84d6537
chore: use rever to use clap keep minimal changes against master branch
arunvishnun Jan 24, 2023
eee2178
chore: use mocha config same as master branch
arunvishnun Jan 24, 2023
91c3ae8
chore: changelog jsons from rush change
arunvishnun Jan 24, 2023
1984be5
fix: types error in xarc-app-dev package (#8)
arunvishnun Feb 23, 2023
68de0cb
fix: eslint issues in sample apps (#9)
arunvishnun Feb 24, 2023
3493396
fix: test issues in sample apps (#10)
arunvishnun Feb 27, 2023
6ec5ce7
chore: allow warnings in successful builds (#11)
arunvishnun Feb 27, 2023
45f4e9d
fix: tests for node 12 (#12)
arunvishnun Feb 27, 2023
13638f0
test: fix unit test failing in subapp-web@2
arunvishnun Mar 24, 2023
c21424d
chore: update pnpm lock file
arunvishnun Mar 27, 2023
203ca6d
chore: add ci step to verify changelogs available
arunvishnun Mar 27, 2023
270a89b
chore: add ci step to verify changelogs available
arunvishnun Mar 27, 2023
becf994
chore: add ci step to verify changelogs available
arunvishnun Mar 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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