From cfde7c3e58d7463f2131a920553ea387361990de Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 5 Sep 2023 11:07:18 +0100 Subject: [PATCH 1/3] Move bootstrap to account-portal --- .github/workflows/README.md | 75 +----------------------------- docs/DEV-SETUP-WINDOWS.md | 2 +- package.json | 6 +-- scripts/link-dependencies.sh | 89 ------------------------------------ 4 files changed, 4 insertions(+), 168 deletions(-) delete mode 100755 scripts/link-dependencies.sh diff --git a/.github/workflows/README.md b/.github/workflows/README.md index f77323d85a..7e4172e602 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -115,77 +115,4 @@ This job is responsible for deploying to our production, cloud kubernetes enviro ### Rollback A Bad Cloud Deployment - Kick off cloud deploy job - Ensure you are running off master -- Enter the version number of the last known good version of budibase. For example `1.0.0` - -## Pro - -| **NOTE**: When developing for both pro / budibase repositories, your branch names need to match, or else the correct pro doesn't get run within your CI job. - -### Installing Pro - -The pro package is always installed from source in our CI jobs. - -This is done to prevent pro needing to be published prior to CI runs in budiabse. This is required for two reasons: -- To reduce developer need to manually bump versions, i.e: - - release pro, bump pro dep in budibase, now ci can run successfully -- The cyclic dependency on backend-core, i.e: - - pro depends on backend-core - - server depends on pro - - backend-core lives in the monorepo, so it can't be released independently to be used in pro - - therefore the only option is to pull pro from source and release it as a part of the monorepo release, as if it were a mono package - -The install is performed using the same steps as local development, via the `yarn bootstrap` command, see the [Contributing Guide#Pro](../../docs/CONTRIBUTING.md#pro) - -The branch to install pro from can vary depending on ref of the commit that triggered the budibase CI job. This is done to enable branches which have changes in both the monorepo and the pro repo to have their CI pass successfully. - -This is done using the [pro/install.sh](../../scripts/pro/install.sh) script. The script will: -- Clone pro to it's default branch (`develop`) -- Check if the clone worked, on forked versions of budibase this will fail due to no access - - This is fine as the `yarn` command will install the version from NPM - - Community PRs should never touch pro so this will always work -- Checkout the `BRANCH` argument, if this fails fallback to `BASE_BRANCH` - - This enables the more complex case of a feature branch being merged to another feature branch, e.g. - - I am working on a branch `epic/stonks` which exists on budibase and pro. - - I want to merge a change to this branch in budibase from `feature/stonks-ui`, which only exists in budibase - - The base branch ensures that `epic/stonks` in pro will still be checked out for the CI run, rather than falling back to `develop` -- Run `yarn setup` to build and install dependencies - - `yarn` - - `yarn bootstrap` - - `yarn build` - - The will build .ts files, and also update the `main` and `types` of `package.json` to point to `dist` rather than src - - The build command will only ever work in CI, it is prevented in local dev - -#### `BRANCH` and `BASE_BRANCH` arguments -These arguments are supplied by the various budibase build and release pipelines -- `budibase_ci` - - `BRANCH: ${{ github.event.pull_request.head.ref }}` -> The branch being merged - - `BASE_BRANCH: ${{ github.event.pull_request.base.ref}}` -> The base branch -- `release-develop` - - `BRANCH: develop` -> always use the `develop` branch in pro -- `release` - - `BRANCH: master` -> always use the `master` branch in pro - - -### Releasing Pro -After budibase dependencies have been released we will release the new version of pro to match the release version of budibase dependencies. This is to ensure that we are always keeping the version of `backend-core` in sync in the pro package and in budibase packages. Without this we could run into scenarios where different versions are being used when installed via `yarn` inside the docker images, creating very difficult to debug cases. - -Pro is released using the [pro/release.sh](../../scripts/pro/release.sh) script. The script will: -- Inspect the `VERSION` from the `lerna.json` file in budibase -- Determine whether to use the `latest` or `develop` tag based on the command argument -- Go to pro directory - - install npm creds - - update the version of `backend-core` to be `VERSION`, the version just released by lerna - - publish to npm. Uses a `lerna publish` command, pro itself is a mono repo. - - force the version to be the same as `VERSION` to keep pro and budibase in sync - - reverts the changes to `main` and `types` in `package.json` that were made by the build step, to point back to source - - commit & push: `Prep next development iteration` -- Go to budibase - - Update to the new version of pro in `server` and `worker` so the latest pro version is used in the docker builds - - commit & push: `Update pro version to $VERSION` - - -#### `COMMAND` argument -This argument is supplied by the existing `release` and `release:develop` budibase commands, which invoke the pro release -- `release` will supply no command and default to use `latest` -- `release:develop` will supply `develop` - +- Enter the version number of the last known good version of budibase. For example `1.0.0` \ No newline at end of file diff --git a/docs/DEV-SETUP-WINDOWS.md b/docs/DEV-SETUP-WINDOWS.md index 176e0700d7..f26a5a0882 100644 --- a/docs/DEV-SETUP-WINDOWS.md +++ b/docs/DEV-SETUP-WINDOWS.md @@ -74,7 +74,7 @@ yarn setup The yarn setup command runs several build steps i.e. ``` -node ./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev +node ./hosting/scripts/setup.js && yarn && yarn build && yarn dev ``` So this command will actually run the application in dev mode. It creates .env files under `./packages/server` and `./packages/worker` and runs docker containers for each service via docker-compose. diff --git a/package.json b/package.json index 4e4befb5f2..82fdc73e05 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "scripts": { "preinstall": "node scripts/syncProPackage.js", "setup": "git config submodule.recurse true && git submodule update && node ./hosting/scripts/setup.js && yarn && yarn build && yarn dev", - "bootstrap": "./scripts/link-dependencies.sh && echo '***BOOTSTRAP ONLY REQUIRED FOR USE WITH ACCOUNT PORTAL***'", "build": "lerna run build --stream", "build:dev": "lerna run --stream prebuild && yarn nx run-many --target=build --output-style=dynamic --watch --preserveWatchOutput", "check:types": "lerna run check:types", @@ -43,11 +42,11 @@ "deps:circular": "madge packages/server/dist/index.js packages/worker/src/index.ts packages/backend-core/dist/src/index.js packages/cli/src/index.js --circular", "release": "lerna publish from-package --yes --force-publish --no-git-tag-version --no-push --no-git-reset", "release:develop": "yarn release --dist-tag develop", - "restore": "yarn run clean && yarn run bootstrap && yarn run build", + "restore": "yarn run dep:clean && yarn && yarn run build", "nuke": "yarn run nuke:packages && yarn run nuke:docker", "nuke:packages": "yarn run restore", "nuke:docker": "lerna run --stream dev:stack:nuke", - "clean": "lerna clean", + "clean": "lerna clean -y", "kill-builder": "kill-port 3000", "kill-server": "kill-port 4001 4002", "kill-all": "yarn run kill-builder && yarn run kill-server", @@ -93,7 +92,6 @@ "mode:account": "yarn mode:cloud && yarn env:account:enable", "security:audit": "node scripts/audit.js", "postinstall": "husky install", - "dep:clean": "yarn clean -y && yarn bootstrap", "submodules:load": "git submodule init && git submodule update && yarn && yarn bootstrap", "submodules:unload": "git submodule deinit --all && yarn && yarn bootstrap" }, diff --git a/scripts/link-dependencies.sh b/scripts/link-dependencies.sh deleted file mode 100755 index 921e3be8f3..0000000000 --- a/scripts/link-dependencies.sh +++ /dev/null @@ -1,89 +0,0 @@ -echo "Linking backend-core" -cd packages/backend-core -yarn unlink -yarn link -cd - - -echo "Linking string-templates" -cd packages/string-templates -yarn unlink -yarn link -cd - - -echo "Linking types" -cd packages/types -yarn unlink -yarn link -cd - - -echo "Linking bbui" -cd packages/bbui -yarn unlink -yarn link -cd - - -echo "Linking frontend-core" -cd packages/frontend-core -yarn unlink -yarn link -cd - - -echo "Linking shared-core" -cd packages/shared-core -yarn unlink -yarn link -cd - - -if [ -d packages/pro/src ]; then - pro_loaded_locally=true -else - pro_loaded_locally=false -fi - -if [ $pro_loaded_locally = true ]; then - echo "Linking pro" - cd packages/pro - yarn unlink - yarn link - cd - -fi - -if [ -d "../account-portal" ]; then - cd ../account-portal - echo "Bootstrapping account-portal" - yarn bootstrap - - cd packages/server - echo "Linking backend-core to account-portal (server)" - yarn link "@budibase/backend-core" - - echo "Linking string-templates to account-portal (server)" - yarn link "@budibase/string-templates" - - echo "Linking types to account-portal (server)" - yarn link "@budibase/types" - - echo "Linking shared-core to account-portal (server)" - yarn link "@budibase/shared-core" - - if [ $pro_loaded_locally = true ]; then - echo "Linking pro to account-portal (server)" - yarn link "@budibase/pro" - fi - - cd ../ui - echo "Linking bbui to account-portal (ui)" - yarn link "@budibase/bbui" - - echo "Linking shared-core to account-portal (ui)" - yarn link "@budibase/shared-core" - - echo "Linking string-templates to account-portal (ui)" - yarn link "@budibase/string-templates" - - echo "Linking types to account-portal (ui)" - yarn link "@budibase/types" - - echo "Linking frontend-core to account-portal (ui)" - yarn link "@budibase/frontend-core" -fi From 9ff9da02471ea699f9532f6577aec2038496e66b Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 5 Sep 2023 16:37:57 +0100 Subject: [PATCH 2/3] Remove remaining references to `yarn bootstrap` --- .github/workflows/release-selfhost.yml | 1 - docs/DEV-SETUP-DEBIAN.md | 2 +- docs/DEV-SETUP-MACOSX.md | 2 +- hosting/single/README.md | 1 - hosting/tests/README.md | 1 - package.json | 6 ++---- scripts/scopeBackend.sh | 16 ---------------- 7 files changed, 4 insertions(+), 25 deletions(-) delete mode 100755 scripts/scopeBackend.sh diff --git a/.github/workflows/release-selfhost.yml b/.github/workflows/release-selfhost.yml index 39ee812726..9e479c84d9 100644 --- a/.github/workflows/release-selfhost.yml +++ b/.github/workflows/release-selfhost.yml @@ -67,7 +67,6 @@ jobs: - name: Bootstrap and build (CLI) run: | yarn - yarn bootstrap yarn build - name: Build OpenAPI spec diff --git a/docs/DEV-SETUP-DEBIAN.md b/docs/DEV-SETUP-DEBIAN.md index a8b1e3dce4..e098862c64 100644 --- a/docs/DEV-SETUP-DEBIAN.md +++ b/docs/DEV-SETUP-DEBIAN.md @@ -55,7 +55,7 @@ yarn setup The yarn setup command runs several build steps i.e. ``` -node ./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev +node ./hosting/scripts/setup.js && yarn && yarn build && yarn dev ``` So this command will actually run the application in dev mode. It creates .env files under `./packages/server` and `./packages/worker` and runs docker containers for each service via docker-compose. diff --git a/docs/DEV-SETUP-MACOSX.md b/docs/DEV-SETUP-MACOSX.md index 94ed3fc1ee..0e13d540b3 100644 --- a/docs/DEV-SETUP-MACOSX.md +++ b/docs/DEV-SETUP-MACOSX.md @@ -55,7 +55,7 @@ yarn setup The yarn setup command runs several build steps i.e. ``` -node ./hosting/scripts/setup.js && yarn && yarn bootstrap && yarn build && yarn dev +node ./hosting/scripts/setup.js && yarn && yarn build && yarn dev ``` So this command will actually run the application in dev mode. It creates .env files under `./packages/server` and `./packages/worker` and runs docker containers for each service via docker-compose. diff --git a/hosting/single/README.md b/hosting/single/README.md index 1147d55c89..09010f5075 100644 --- a/hosting/single/README.md +++ b/hosting/single/README.md @@ -58,7 +58,6 @@ Node setup: ``` node ./hosting/scripts/setup.js yarn -yarn bootstrap yarn build ``` #### Build Image diff --git a/hosting/tests/README.md b/hosting/tests/README.md index 8586b31948..19b9ed5037 100644 --- a/hosting/tests/README.md +++ b/hosting/tests/README.md @@ -47,7 +47,6 @@ Node setup: ``` node ./hosting/scripts/setup.js yarn -yarn bootstrap yarn build ``` #### Build Image diff --git a/package.json b/package.json index 82fdc73e05..1432a146d5 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,6 @@ "build": "lerna run build --stream", "build:dev": "lerna run --stream prebuild && yarn nx run-many --target=build --output-style=dynamic --watch --preserveWatchOutput", "check:types": "lerna run check:types", - "backend:bootstrap": "./scripts/scopeBackend.sh && yarn run bootstrap", - "backend:build": "./scripts/scopeBackend.sh 'lerna run --stream build'", "build:sdk": "lerna run --stream build:sdk", "deps:circular": "madge packages/server/dist/index.js packages/worker/src/index.ts packages/backend-core/dist/src/index.js packages/cli/src/index.js --circular", "release": "lerna publish from-package --yes --force-publish --no-git-tag-version --no-push --no-git-reset", @@ -92,8 +90,8 @@ "mode:account": "yarn mode:cloud && yarn env:account:enable", "security:audit": "node scripts/audit.js", "postinstall": "husky install", - "submodules:load": "git submodule init && git submodule update && yarn && yarn bootstrap", - "submodules:unload": "git submodule deinit --all && yarn && yarn bootstrap" + "submodules:load": "git submodule init && git submodule update && yarn", + "submodules:unload": "git submodule deinit --all && yarn" }, "workspaces": { "packages": [ diff --git a/scripts/scopeBackend.sh b/scripts/scopeBackend.sh deleted file mode 100755 index c8903b7df9..0000000000 --- a/scripts/scopeBackend.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Define the packages -PACKAGES=("@budibase/backend-core" "@budibase/worker" "@budibase/server" "@budibase/string-templates" "@budibase/types" "@budibase/shared-core") - -# Generate the scope arguments -SCOPE_ARGS="" -for PACKAGE in "${PACKAGES[@]}"; do - SCOPE_ARGS+="--scope $PACKAGE " -done - -# Run the commands with the scope arguments -for COMMAND in "$@"; do - echo "Running: $COMMAND $SCOPE_ARGS" - yarn $COMMAND $SCOPE_ARGS -done From 792e108b79dd3ce86c8cff962b4aa3c457c2740c Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 5 Sep 2023 16:46:45 +0100 Subject: [PATCH 3/3] Fix dep:clean usage --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1432a146d5..b0c428fe70 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "deps:circular": "madge packages/server/dist/index.js packages/worker/src/index.ts packages/backend-core/dist/src/index.js packages/cli/src/index.js --circular", "release": "lerna publish from-package --yes --force-publish --no-git-tag-version --no-push --no-git-reset", "release:develop": "yarn release --dist-tag develop", - "restore": "yarn run dep:clean && yarn && yarn run build", + "restore": "yarn run clean && yarn && yarn run build", "nuke": "yarn run nuke:packages && yarn run nuke:docker", "nuke:packages": "yarn run restore", "nuke:docker": "lerna run --stream dev:stack:nuke",