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

Drop lerna #4258

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
50 changes: 4 additions & 46 deletions .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,54 +49,12 @@ jobs:
echo "::set-output name=version::$VERSION"
echo PACKAGE_VERSION $PACKAGE_VERSION GITHUB_SHA $GITHUB_SHA VERSION $VERSION

- name: Change and commit version
# Write version before publishing so it's picked up by `lerna publish from-package`.
# It must also be committed to ensure a clean git tree, otherwise `lerna publish` errors.
# This "temp" commit doesn't change the actually release commit which is captured above.
# git-data is also correct, since it's generated at build time, before `lerna version` run.
run: |
node_modules/.bin/lerna version ${{ steps.version.outputs.version }} \
--force-publish \
--exact \
--yes \
--no-git-tag-version

git config user.name 'temp'
git config user.email '[email protected]'
git commit -am "${{ steps.version.outputs.version }}"
- name: Set dev version
# Set all mono-repo packages to the same new version. Update their dependency versions too
run: node scripts/release/set_version.mjs ${{ steps.version.outputs.version }} exact

- name: Publish to npm registry
# Note: before https://github.com/ChainSafe/lodestar/commit/28e2c74cf0f1bede8b09c8c9fec26f54b367e3fd
# We used `lerna publish --canary` option. However, since we now publish must version on branches,
# i.e. v0.35.x branch, lerna fails to detect the latest version and publishes canary versions as
# `0.34.0-dev.173+28e2c74cf0` instead of `0.36.0-dev.4+28e2c74cf0`, which creates confusion.
#
# --no-git-reset:
# Do not delete code version artifacts so the next step can pick the version
#
# --dist-tag next:
# Make this dev version installable with `@next`
#
# --preid dev:
# Tag version with `dev` instead of `alpha`
#
# --force-publish:
# lerna doesn't want to publish anything otherwise - "lerna success No changed packages
# to publish"
# --exact
# lerna will link the dependencies of monorepo packages without ^ operator as npm
# is apparently bad at resolving ^ dependencies of the canary versions. For e.g
# @chainsafe/lodestar@^0.34.0-dev.4 resolves to => 0.34.0
#
# NOTE: Using --preid dev.$(git rev-parse --short=7 HEAD) results in `0.24.3-dev.3ddb91d.0+3ddb91d`
run: |
node_modules/.bin/lerna publish from-package \
--yes \
--no-verify-access \
--dist-tag next \
--no-git-reset \
--force-publish \
--exact
run: node scripts/release/publish.mjs next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
outputs:
Expand Down
25 changes: 4 additions & 21 deletions .github/workflows/publish-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,12 @@ jobs:
release_name: Release ${{ needs.tag.outputs.tag }}
prerelease: true

- name: Change and commit version
# Write version before publishing so it's picked up by `lerna publish from-package`.
# It must also be committed to ensure a clean git tree, otherwise `lerna publish` errors.
# This "temp" commit doesn't change the actually release commit which is captured above.
# git-data is also correct, since it's generated at build time, before `lerna version` run.
run: |
node_modules/.bin/lerna version ${{ needs.tag.outputs.version }} \
--force-publish \
--exact \
--yes \
--no-git-tag-version

git config user.name 'temp'
git config user.email '[email protected]'
git commit -am "${{ needs.tag.outputs.version }}"

# From https://github.com/lerna/lerna/issues/2404
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set rc version
# Set all mono-repo packages to the same new version. Update their dependency versions too
run: node scripts/release/set_version.mjs ${{ steps.version.outputs.version }} exact

- name: Publish to npm registry
run: yarn run release:publish --dist-tag rc
run: node scripts/release/publish.mjs rc
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/publish-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,9 @@ jobs:
release_name: Release ${{ needs.tag.outputs.tag }}
prerelease: false

# From https://github.com/lerna/lerna/issues/2404
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Version is already set in source, and checked in "Assert tag == package.json version"
- name: Publish to npm registry (release)
run: yarn run release:publish
run: node scripts/release/publish.mjs latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/assert-same-package-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# If that's not the case, no version will be published to NPM and a faulty image will be published to dockerhub

LOCAL_VERSION=$(jq -r .version lerna.json)
LOCAL_VERSION=$(jq -r .version packages/cli/package.json)

if [ -z "$TAG" ]; then
echo "ENV TAG is empty"
Expand Down
15 changes: 7 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ Thanks for your contribution to Lodestar. It's people like you that push the Eth
## Prerequisites

- :gear: [NodeJS](https://nodejs.org/) (LTS/Gallium)
- :toolbox: [Yarn](https://yarnpkg.com/)/[Lerna](https://lerna.js.org/)
- :toolbox: [Yarn](https://yarnpkg.com/)

## Getting Started

- :gear: Run `lerna bootstrap` or `yarn install` to install dependencies.
- :gear: Run `yarn install` to install dependencies.
- :gear: Run `yarn build` to build lib from source.
- :package: A `lodestar` binary will be bundled in `./packages/cli/bin`.
- :computer: Run `./lodestar --help` to get a list of available commands and argurments.

## Tests

- :test_tube: Run `lerna run test:spec-min` for minimal spec tests.
- :test_tube: Run `lerna run test:spec-main` for mainnet spec tests.
- :test_tube: Run `lerna run test:unit` for unit tests.
- :test_tube: Run `lerna run test:e2e` for end-to-end tests.
- :test_tube: Run `lerna run test` to run all tests.
- :test_tube: Run `yarn test:spec-min` for minimal spec tests.
- :test_tube: Run `yarn test:spec-main` for mainnet spec tests.
- :test_tube: Run `yarn test:unit` for unit tests.
- :test_tube: Run `yarn test:e2e` for end-to-end tests.

### Debugging spec tests

Expand Down Expand Up @@ -103,7 +102,7 @@ For example:

## Lodestar Monorepo

We're currently experimenting with hosting the majority of lodestar packages and support packages in this repository as a [monorepo](https://en.wikipedia.org/wiki/Monorepo). We're using [Lerna](https://lerna.js.org/) to manage the packages. See [packages/](https://github.com/ChainSafe/lodestar/tree/unstable/packages) for a list of packages hosted in this repo.
We're currently experimenting with hosting the majority of lodestar packages and support packages in this repository as a [monorepo](https://en.wikipedia.org/wiki/Monorepo). See [packages/](https://github.com/ChainSafe/lodestar/tree/unstable/packages) for a list of packages hosted in this repo.

## Style Guide

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
## Prerequisites

- :gear: [NodeJS](https://nodejs.org/) (LTS/Gallium)
- :toolbox: [Yarn](https://yarnpkg.com/)/[Lerna](https://lerna.js.org/)
- :toolbox: [Yarn](https://yarnpkg.com/)

###### Developer Quickstart:

```bash
lerna bootstrap
yarn build
yarn && yarn build
./lodestar --help
```

Expand Down
6 changes: 5 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To start a new release, one of the Lodestar developers will communicate this via
- Create a new release branch `rc/v1.1.0` at commit `9fceb02`.
- `git checkout -b rc/v1.1.0 9fceb02`
- Set monorepo version to `v1.1.0`.
- `lerna version v1.1.0 --no-git-tag-version --force-publish --yes`
- `node scripts/release/set_version.mjs v1.1.0 tilde`
- Commit changes
- `git commit -am "v1.1.0"`
- `git push origin rc/v1.1.0`
Expand Down Expand Up @@ -92,6 +92,7 @@ Tagging a stable release will trigger CI to publish to NPM, dockerhub, and Githu
- `git checkout stable`
- `yarn release:tag-stable 1.1.0`
- Must be run locally from a write-access account capable of triggering CI.

#### Manual steps (for example version `v1.1.0`):

- Check out the new stable
Expand All @@ -110,6 +111,7 @@ Tagging a stable release will trigger CI to publish to NPM, dockerhub, and Githu
If a stable version requires an immediate hot-fix before the next release, a hot-fix release is started.

The same process for a stable release is used, with the two differences.

- The candidate commit must be chosen from the `stable` branch instead of the `unstable` branch.
- Depending on the severity of the bug being fixed, the testing window may be decreased.

Expand Down Expand Up @@ -191,7 +193,9 @@ The release should be announced on the following social channels:
- Reddit: TODO: get Lodestar account.

# Release Manager Checklist

This section is to guide the Release Manager tasked with the next version release to ensure all items have been completed.

- Start thread on communication channels for new release
- Confirm consensus on `unstable` release candidate commit
- Complete Step 1: Create release candidate
Expand Down
12 changes: 3 additions & 9 deletions docs/install/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Clone the repo locally.
git clone https://github.com/chainsafe/lodestar.git
```

Install across all packages. Lodestar follows a [monorepo](https://github.com/lerna/lerna) structure, so all commands below must be run in the project root. Use the `--ignore-optional` flag to prevent downloading the Ethereum Consensus spec tests.
Install across all packages. Lodestar follows a monorepo structure, so all commands below must be run in the project root.

```bash
yarn install --ignore-optional
yarn install
```

Build across all packages.
Expand All @@ -25,14 +25,8 @@ Build across all packages.
yarn run build
```

Or if you are using [Lerna](https://lerna.js.org/):

```bash
lerna bootstrap
```

Lodestar should now be ready for use.

```bash
./lodestar --help
```
```
46 changes: 26 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,40 @@
"node": ">=12.9.0"
},
"workspaces": [
"packages/params",
"packages/utils",
"packages/types",
"packages/spec-test-util",
"packages/config",
"packages/api",
"packages/db",
"packages/state-transition",
"packages/light-client",
"packages/validator",
"packages/flare",
"packages/fork-choice",
"packages/beacon-node",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hardcoded list is sorted topologically. Yarn v1 does not support topological inference out of the box, so this does the trick. Long term we can switch to newer versions of yarn that do this automatically.

"packages/*"
],
"scripts": {
"clean": "rm -rf ./packages/*/lib ./packages/*/*.tsbuildinfo",
"build": "yarn clean && lerna run build",
"build:docs": "lerna run build:typedocs && lerna run build:refdocs && ./scripts/prepare-docs.sh",
"build:lib:watch": "lerna run build:lib:watch --parallel",
"build:types:watch": "lerna run build:types:watch --parallel",
"build:watch": "run-p build:lib:watch build:types:watch",
"build:ifchanged": "lerna exec -- ../../scripts/build_if_changed.sh",
"lint": "lerna run lint --no-bail",
"check-build": "lerna run check-build",
"check-types": "lerna run check-types --no-bail",
"coverage": "lerna run coverage --no-bail",
"test:unit": "lerna run test:unit --no-bail --concurrency 1",
"test:e2e": "lerna run test:e2e --no-bail --concurrency 1",
"test:e2e:sim": "lerna run test:e2e:sim --no-bail",
"test:spec-min": "lerna run test:spec-min --no-bail",
"test:spec-fast": "lerna run test:spec-fast --no-bail",
"test:spec-main": "lerna run test:spec-main --no-bail",
"build": "yarn clean && yarn workspaces run build",
"build:docs": "scripts/build_docs.sh",
"build:ifchanged": "yarn workspaces exec -- ../../scripts/build_if_changed.sh",
"check-build": "yarn workspaces run check-build",
"check-types": "yarn workspaces run check-types",
"check-readme": "scripts/foreach.sh typescript-docs-verifier",
"coverage": "scripts/foreach.sh codecov -F $(basename $PWD)",
"lint": "yarn workspaces run lint",
"test:unit": "yarn workspaces run test:unit",
"test:e2e": "yarn workspaces run test:e2e",
"test:spec-min": "cd packages/beacon-node && yarn test:spec-min",
"test:spec-main": "cd packages/beacon-node && yarn test:spec-main",
"benchmark": "yarn benchmark:files 'packages/*/test/perf/**/*.test.ts'",
"benchmark:files": "LODESTAR_PRESET=mainnet NODE_OPTIONS='--max-old-space-size=4096 --loader=ts-node/esm' benchmark --config .benchrc.yaml",
"release:create-rc": "node scripts/release/create_rc.mjs",
"release:tag-rc": "node scripts/release/tag_rc.mjs",
"release:tag-stable": "node scripts/release/tag_stable.mjs",
"release:publish": "lerna publish from-package --yes --no-verify-access",
"check-readme": "lerna run check-readme"
"release:tag-stable": "node scripts/release/tag_stable.mjs"
},
"devDependencies": {
"@chainsafe/eslint-plugin-node": "^11.2.3",
Expand All @@ -50,7 +57,6 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-no-only-tests": "^2.6.0",
"eslint-plugin-prettier": "^4.0.0",
"lerna": "^4.0.0",
"mocha": "^9.2.2",
"node-gyp": "^9.0.0",
"npm-run-all": "^4.1.5",
Expand Down
5 changes: 1 addition & 4 deletions packages/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ Typescript REST client for the [Ethereum Consensus API spec](https://github.com/
import {getClient} from "@lodestar/api";
import {config} from "@lodestar/config/default";

const api = getClient({
baseUrl: "http://localhost:9596",
}, {config});
const api = getClient({baseUrl: "http://localhost:9596"}, {config});

api.beacon
.getStateValidator(
Expand All @@ -29,7 +27,6 @@ api.beacon

## Prerequisites

- [Lerna](https://github.com/lerna/lerna)
- [Yarn](https://yarnpkg.com/)

## What you need
Expand Down
8 changes: 1 addition & 7 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,11 @@
"scripts": {
"clean": "rm -rf lib && rm -f *.tsbuildinfo",
"build": "tsc -p tsconfig.build.json",
"build:typedocs": "typedoc --exclude src/index.ts --out typedocs src",
"build:release": "yarn clean && yarn run build && yarn run build:typedocs",
"check-build": "node -e \"(async function() { await import('./lib/index.js') })()\"",
"check-types": "tsc",
"coverage": "codecov -F lodestar-api",
"lint": "eslint --color --ext .ts src/ test/",
"lint:fix": "yarn run lint --fix",
"pretest": "yarn run check-types",
"test": "yarn test:unit && yarn test:e2e",
"test:unit": "nyc --cache-dir .nyc_output/.cache -e .ts mocha 'test/unit/**/*.test.ts'",
"check-readme": "typescript-docs-verifier"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI only items like check-readme, coverage and build:typedocs and handled by other scripts only meant for CI

"test:e2e": "echo 'n/a'"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn v1 workspace run util requires all packages to have the script declared

},
"dependencies": {
"@lodestar/config": "^0.39.0",
Expand Down
11 changes: 1 addition & 10 deletions packages/beacon-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,9 @@
"scripts": {
"clean": "rm -rf lib && rm -f *.tsbuildinfo",
"build": "tsc -p tsconfig.build.json",
"build:typedocs": "typedoc --exclude src/index.ts --out typedocs src",
"build:lib:watch": "yarn run build:lib --watch",
"build:release": "yarn clean && yarn run build && yarn run build:typedocs",
"build:types:watch": "yarn run build:types --watch",
"check-build": "node -e \"(async function() { await import('./lib/index.js') })()\"",
"check-types": "tsc",
"coverage": "codecov -F lodestar",
"lint": "eslint --color --ext .ts src/ test/",
"lint:fix": "yarn run lint --fix",
"pretest": "yarn run check-types",
"test": "yarn test:unit && yarn test:e2e",
"test:unit:minimal": "nyc --cache-dir .nyc_output/.cache -e .ts mocha 'test/unit/**/*.test.ts'",
"test:unit:mainnet": "LODESTAR_PRESET=mainnet nyc --cache-dir .nyc_output/.cache -e .ts mocha 'test/unit-mainnet/**/*.test.ts'",
"test:unit": "yarn test:unit:minimal && yarn test:unit:mainnet",
Expand All @@ -96,8 +88,7 @@
"test:spec-general": "mocha --config .mocharc.spec.cjs 'test/spec/general/**/*.test.ts'",
"test:spec-minimal": "LODESTAR_PRESET=minimal mocha --config .mocharc.spec.cjs 'test/spec/presets/**/*.test.ts'",
"test:spec-mainnet": "LODESTAR_PRESET=mainnet mocha --config .mocharc.spec.cjs 'test/spec/presets/**/*.test.ts'",
"test:spec": "yarn test:spec-general && yarn test:spec-minimal && yarn test:spec-mainnet",
"check-readme": "typescript-docs-verifier"
"test:spec": "yarn test:spec-general && yarn test:spec-minimal && yarn test:spec-mainnet"
},
"dependencies": {
"@chainsafe/as-sha256": "^0.3.1",
Expand Down
11 changes: 1 addition & 10 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,13 @@
"scripts": {
"clean": "rm -rf lib && rm -f *.tsbuildinfo",
"build": "tsc -p tsconfig.build.json && yarn write-git-data",
"build:release": "yarn clean && yarn run build && yarn run build:typedocs",
"build:lib:watch": "yarn run build:lib --watch",
"build:typedocs": "typedoc --exclude src/index.ts --out typedocs src",
"build:types:watch": "yarn run build:types --watch",
"build:refdocs": "ts-node --esm ./docsgen docs/cli.md",
"write-git-data": "node lib/util/gitData/writeGitData.js",
"check-build": "node -e \"(async function() { await import('./lib/index.js') })()\" lodestar --help",
"check-types": "tsc",
"lint": "eslint --color --ext .ts src/ test/",
"lint:fix": "yarn run lint --fix",
"pretest": "yarn run check-types",
"test:unit": "nyc --cache-dir .nyc_output/.cache -e .ts mocha 'test/unit/**/*.test.ts'",
"test:e2e": "mocha --timeout 30000 'test/e2e/**/*.test.ts'",
"test": "yarn test:unit && yarn test:e2e",
"coverage": "codecov -F lodestar",
"check-readme": "typescript-docs-verifier"
"test:e2e": "mocha --timeout 30000 'test/e2e/**/*.test.ts'"
},
"repository": {
"type": "git",
Expand Down
Loading