From a77aa3cc39544e279471691cc57117ad125b8ea8 Mon Sep 17 00:00:00 2001 From: Hugo Renard Date: Mon, 18 Sep 2023 15:42:19 +0200 Subject: [PATCH] feat: bump to v6.3.6 & update patch --- .ci/build | 2 +- .gitlab-ci.yml | 2 +- Dockerfile | 12 +-- no-upgrade.patch | 209 ++++++++++++++++++----------------------- test-scalability.patch | 122 ++++++++++++++++++++++++ 5 files changed, 220 insertions(+), 127 deletions(-) create mode 100644 test-scalability.patch diff --git a/.ci/build b/.ci/build index cc5cb6e..a035a0b 100755 --- a/.ci/build +++ b/.ci/build @@ -6,4 +6,4 @@ if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then DESTINATION="$DESTINATION --destination ${DOCKER_HUB_REPO}:${VERSION} --destination ${DOCKER_HUB_REPO}:latest" fi -/kaniko/executor --context . ${DESTINATION} --build-arg VERSION=$VERSION \ No newline at end of file +/kaniko/executor --cache --cache-repo=${DOCKER_HUB_REPO}-cache --cache-copy-layers --context . ${DESTINATION} --build-arg VERSION=$VERSION \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 000cb96..b3f0145 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ variables: DOCKER_HUB_REPO: libresh/rocketchat - VERSION: 5.4.10 + VERSION: 6.3.6 test: stage: test diff --git a/Dockerfile b/Dockerfile index 4199d73..4d2b16a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM node:14.19.3-buster-slim AS build +FROM node:14.21.3-buster AS build RUN set -eux \ && apt-get update \ - && apt-get install -y --no-install-recommends git ca-certificates curl wget gnupg dirmngr xz-utils \ + && apt-get install -y --no-install-recommends curl \ && apt-get clean RUN curl https://install.meteor.com | /bin/sh @@ -18,13 +18,13 @@ RUN YARN_CHECKSUM_BEHAVIOR=update yarn COPY no-upgrade.patch no-upgrade.patch RUN git apply no-upgrade.patch -RUN yarn lint -RUN yarn turbo run translation-check -RUN yarn turbo run typecheck +COPY test-scalability.patch test-scalability.patch +RUN git apply test-scalability.patch + RUN GENERATE_SOURCEMAP=false TOOL_NODE_FLAGS="--max_old_space_size=8192" yarn build:ci -- --directory /build -FROM node:14.19.3-buster-slim as patched +FROM node:14.21.3-buster-slim as patched RUN groupadd -r rocketchat \ && useradd -r -g rocketchat rocketchat \ diff --git a/no-upgrade.patch b/no-upgrade.patch index 387d20f..426412e 100644 --- a/no-upgrade.patch +++ b/no-upgrade.patch @@ -1,149 +1,120 @@ -diff --git a/apps/meteor/client/components/AdministrationList/AdministrationList.tsx b/apps/meteor/client/components/AdministrationList/AdministrationList.tsx -index 468a78f6d9..10aac6e424 100644 ---- a/apps/meteor/client/components/AdministrationList/AdministrationList.tsx -+++ b/apps/meteor/client/components/AdministrationList/AdministrationList.tsx -@@ -3,7 +3,6 @@ import React, { FC, Fragment } from 'react'; - - import { AccountBoxItem, IAppAccountBoxItem, isAppAccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox'; - import AdministrationModelList from './AdministrationModelList'; --import AppsModelList from './AppsModelList'; - import AuditModelList from './AuditModelList'; - - type AdministrationListProps = { -@@ -20,19 +19,15 @@ const AdministrationList: FC = ({ - accountBoxItems, - hasAuditPermission, - hasAuditLogPermission, -- hasManageApps, - hasAdminPermission, - closeList, - }) => { -- const appBoxItems = accountBoxItems.filter((item): item is IAppAccountBoxItem => isAppAccountBoxItem(item)); - const adminBoxItems = accountBoxItems.filter((item): item is AccountBoxItem => !isAppAccountBoxItem(item)); - const showAudit = hasAuditPermission || hasAuditLogPermission; -- const showManageApps = hasManageApps || !!appBoxItems.length; - const showAdmin = hasAdminPermission || !!adminBoxItems.length; - - const list = [ - showAdmin && , -- showManageApps && , - showAudit && , - ]; - -diff --git a/apps/meteor/client/components/AdministrationList/AdministrationModelList.tsx b/apps/meteor/client/components/AdministrationList/AdministrationModelList.tsx -index b2f03fd394..0173b01529 100644 ---- a/apps/meteor/client/components/AdministrationList/AdministrationModelList.tsx -+++ b/apps/meteor/client/components/AdministrationList/AdministrationModelList.tsx -@@ -6,9 +6,6 @@ import React, { FC } from 'react'; - import { userHasAllPermission } from '../../../app/authorization/client'; - import { SideNav } from '../../../app/ui-utils/client'; - import { AccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox'; --import { getUpgradeTabLabel, isFullyFeature } from '../../../lib/upgradeTab'; --import { useUpgradeTabParams } from '../../views/hooks/useUpgradeTabParams'; --import Emoji from '../Emoji'; - import ListItem from '../Sidebar/ListItem'; - - type AdministrationModelListProps = { -@@ -21,15 +18,10 @@ const INFO_PERMISSIONS = ['view-statistics']; - - const AdministrationModelList: FC = ({ accountBoxItems, showAdmin, closeList }) => { - const t = useTranslation(); -- const { tabType, trialEndDate, isLoading } = useUpgradeTabParams(); -- const shouldShowEmoji = isFullyFeature(tabType); -- const label = getUpgradeTabLabel(tabType); - const hasInfoPermission = userHasAllPermission(INFO_PERMISSIONS); - - const infoRoute = useRoute('admin-info'); - const adminRoute = useRoute('admin-index'); -- const upgradeRoute = useRoute('upgrade'); -- const showUpgradeItem = !isLoading && tabType; - - return ( - <> -@@ -37,20 +29,6 @@ const AdministrationModelList: FC = ({ accountBoxI -
    - {showAdmin && ( - <> -- {showUpgradeItem && ( -- -- {t(label)} {shouldShowEmoji && } -- -- } -- action={(): void => { -- upgradeRoute.push({ type: tabType }, trialEndDate ? { trialEndDate } : undefined); -- closeList(); -- }} -- /> -- )} - { - const sidebarFooterStyle = css` -@@ -29,7 +28,6 @@ const SidebarFooterDefault = (): ReactElement => { - className={sidebarFooterStyle} - dangerouslySetInnerHTML={{ __html: String(settings.get('Layout_Sidenav_Footer')).trim() }} + const [, , theme] = useThemeMode(); + const logo = String(useSetting(theme === 'dark' ? 'Layout_Sidenav_Footer_Dark' : 'Layout_Sidenav_Footer')).trim(); +@@ -36,7 +34,6 @@ const SidebarFooterDefault = (): ReactElement => { + __html: logo, + }} /> - ); }; +diff --git a/apps/meteor/client/sidebar/header/actions/Administration.tsx b/apps/meteor/client/sidebar/header/actions/Administration.tsx +index d2e51f1913..3a9f924302 100644 +--- a/apps/meteor/client/sidebar/header/actions/Administration.tsx ++++ b/apps/meteor/client/sidebar/header/actions/Administration.tsx +@@ -11,6 +11,10 @@ const Administration: VFC, 'is'>> = (props) => + + const sections = useAdministrationMenu(); + ++ if (sections.length === 0) { ++ return null; ++ } ++ + return ; + }; + +diff --git a/apps/meteor/client/sidebar/header/actions/hooks/useAdministrationMenu.tsx b/apps/meteor/client/sidebar/header/actions/hooks/useAdministrationMenu.tsx +index f6179bb93d..5487afd639 100644 +--- a/apps/meteor/client/sidebar/header/actions/hooks/useAdministrationMenu.tsx ++++ b/apps/meteor/client/sidebar/header/actions/hooks/useAdministrationMenu.tsx +@@ -45,7 +45,6 @@ export const useAdministrationMenu = () => { + + const hasAuditLicense = useHasLicenseModule('auditing') === true; + const hasManageAppsPermission = usePermission('manage-apps'); +- const hasAccessMarketplacePermission = usePermission('access-marketplace'); + const hasAdminPermission = useAtLeastOnePermission(ADMIN_PERMISSIONS); + const hasAuditPermission = usePermission('can-audit') && hasAuditLicense; + const hasAuditLogPermission = usePermission('can-audit-log') && hasAuditLicense; +@@ -56,13 +55,13 @@ export const useAdministrationMenu = () => { + const showAdmin = hasAdminPermission || !!adminBoxItems.length; + const showAudit = hasAuditPermission || hasAuditLogPermission; + const showWorkspace = hasAdminPermission; +- const showApps = hasAccessMarketplacePermission || hasManageAppsPermission || !!appBoxItems.length; ++ const showApps = hasManageAppsPermission || !!appBoxItems.length; + + const administrationItems = useAdministrationItems({ accountBoxItems: adminBoxItems, showWorkspace }); + const appItems = useAppsItems({ + appBoxItems, + appsManagementAllowed: hasManageAppsPermission, +- showMarketplace: hasAccessMarketplacePermission || hasManageAppsPermission, ++ showMarketplace: hasManageAppsPermission, + }); + const auditItems = useAuditItems({ showAudit: hasAuditPermission, showAuditLog: hasAuditLogPermission }); + diff --git a/apps/meteor/client/views/admin/AdministrationRouter.tsx b/apps/meteor/client/views/admin/AdministrationRouter.tsx -index 1d4050d852..3a6b646ee9 100644 +index 93ea650d0d..3ad2a4d920 100644 --- a/apps/meteor/client/views/admin/AdministrationRouter.tsx +++ b/apps/meteor/client/views/admin/AdministrationRouter.tsx -@@ -3,7 +3,6 @@ import React, { Suspense, ReactElement, useEffect, ReactNode } from 'react'; - - import PageSkeleton from '../../components/PageSkeleton'; +@@ -6,7 +6,6 @@ import PageSkeleton from '../../components/PageSkeleton'; + import type { Item, SidebarDivider, SidebarItem } from '../../lib/createSidebarItems'; + import { isGoRocketChatLink } from '../../lib/createSidebarItems'; import SettingsProvider from '../../providers/SettingsProvider'; -import { useUpgradeTabParams } from '../hooks/useUpgradeTabParams'; import AdministrationLayout from './AdministrationLayout'; + import { getAdminSidebarItems } from './sidebarItems'; - type AdministrationRouterProps = { -@@ -11,23 +10,16 @@ type AdministrationRouterProps = { - }; +@@ -28,7 +27,6 @@ type AdministrationRouterProps = { const AdministrationRouter = ({ children }: AdministrationRouterProps): ReactElement => { + const router = useRouter(); - const { tabType, trialEndDate, isLoading } = useUpgradeTabParams(); - const [routeName] = useCurrentRoute(); - const defaultRoute = useRoute('admin-info'); -- const upgradeRoute = useRoute('upgrade'); - - useEffect(() => { -- if (isLoading || routeName !== 'admin-index') { -- return; -- } + + useEffect( + () => +@@ -37,18 +35,6 @@ const AdministrationRouter = ({ children }: AdministrationRouterProps): ReactEle + return; + } + +- if (tabType && !isLoading) { +- router.navigate( +- { +- name: 'upgrade', +- params: { type: tabType }, +- search: trialEndDate ? { trialEndDate } : undefined, +- }, +- { replace: true }, +- ); +- return; +- } - -- if (tabType) { -- upgradeRoute.replace({ type: tabType }, trialEndDate ? { trialEndDate } : undefined); -+ if (routeName !== 'admin-index') { - return; - } + const defaultRoutePath = getAdminSidebarItems().find(firstSidebarPage)?.href ?? '/admin/info'; - defaultRoute.replace(); -- }, [defaultRoute, upgradeRoute, routeName, tabType, trialEndDate, isLoading]); -+ }, [defaultRoute, routeName]); + if (isGoRocketChatLink(defaultRoutePath)) { +@@ -58,7 +44,7 @@ const AdministrationRouter = ({ children }: AdministrationRouterProps): ReactEle + + router.navigate(defaultRoutePath, { replace: true }); + }), +- [tabType, trialEndDate, isLoading, router], ++ [router], + ); return ( - diff --git a/apps/meteor/client/views/admin/sidebar/AdminSidebarPages.tsx b/apps/meteor/client/views/admin/sidebar/AdminSidebarPages.tsx -index 664c18838c..a37e993e45 100644 +index cc670f83f7..d4dbf976a5 100644 --- a/apps/meteor/client/views/admin/sidebar/AdminSidebarPages.tsx +++ b/apps/meteor/client/views/admin/sidebar/AdminSidebarPages.tsx -@@ -3,9 +3,7 @@ import React, { memo, FC } from 'react'; +@@ -4,9 +4,7 @@ import React, { memo } from 'react'; import { useSyncExternalStore } from 'use-sync-external-store/shim'; import SidebarItemsAssembler from '../../../components/Sidebar/SidebarItemsAssembler'; @@ -153,7 +124,7 @@ index 664c18838c..a37e993e45 100644 type AdminSidebarPagesProps = { currentPath: string; -@@ -14,11 +12,8 @@ type AdminSidebarPagesProps = { +@@ -15,11 +13,8 @@ type AdminSidebarPagesProps = { const AdminSidebarPages: FC = ({ currentPath }) => { const items = useSyncExternalStore(subscribeToAdminSidebarItems, getAdminSidebarItems); diff --git a/test-scalability.patch b/test-scalability.patch new file mode 100644 index 0000000..677391a --- /dev/null +++ b/test-scalability.patch @@ -0,0 +1,122 @@ +diff --git a/apps/meteor/ee/server/lib/EnterpriseCheck.ts b/apps/meteor/ee/server/lib/EnterpriseCheck.ts +index 8bccfed590..29a7129166 100644 +--- a/apps/meteor/ee/server/lib/EnterpriseCheck.ts ++++ b/apps/meteor/ee/server/lib/EnterpriseCheck.ts +@@ -39,6 +39,9 @@ export const EnterpriseCheck: ServiceSchema = { + }, + }, + async started(): Promise { ++ if (process.env.TEST_SCALABILITY === 'true') { ++ return; ++ } + setInterval(async () => { + try { + const hasLicense = await this.broker.call('license.hasLicense', ['scalability']); +diff --git a/apps/meteor/ee/server/local-services/instance/service.ts b/apps/meteor/ee/server/local-services/instance/service.ts +index b8074d414f..e594f3c6a5 100644 +--- a/apps/meteor/ee/server/local-services/instance/service.ts ++++ b/apps/meteor/ee/server/local-services/instance/service.ts +@@ -51,11 +51,13 @@ export class InstanceService extends ServiceClassInternal implements IInstanceSe + }); + } + +- this.onEvent('license.module', async ({ module, valid }) => { +- if (module === 'scalability' && valid) { +- await this.startBroadcast(); +- } +- }); ++ if (process.env.TEST_SCALABILITY !== 'true') { ++ this.onEvent('license.module', async ({ module, valid }) => { ++ if (module === 'scalability' && valid) { ++ await this.startBroadcast(); ++ } ++ }); ++ } + + this.onEvent('watch.settings', async ({ clientAction, setting }): Promise => { + if (clientAction === 'removed') { +@@ -138,7 +140,7 @@ export class InstanceService extends ServiceClassInternal implements IInstanceSe + await InstanceStatus.registerInstance('rocket.chat', instance); + + const hasLicense = await License.hasLicense('scalability'); +- if (!hasLicense) { ++ if (!hasLicense && process.env.TEST_SCALABILITY !== 'true') { + return; + } + +diff --git a/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts b/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts +index 627e79066e..106c6ef74f 100644 +--- a/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts ++++ b/ee/packages/omnichannel-services/src/OmnichannelTranscript.ts +@@ -70,6 +70,11 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT + // eslint-disable-next-line new-cap + this.log = new loggerClass('OmnichannelTranscript'); + ++ if (process.env.TEST_SCALABILITY === 'true') { ++ this.shouldWork = true; ++ return; ++ } ++ + this.onEvent('license.module', ({ module, valid }) => { + if (module === 'scalability') { + this.shouldWork = valid; +@@ -78,6 +83,9 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT + } + + async started(): Promise { ++ if (process.env.TEST_SCALABILITY === 'true') { ++ return; ++ } + try { + this.shouldWork = await licenseService.hasLicense('scalability'); + } catch (e: unknown) { +diff --git a/ee/packages/omnichannel-services/src/QueueWorker.ts b/ee/packages/omnichannel-services/src/QueueWorker.ts +index 89c66fbc33..258b75eebf 100644 +--- a/ee/packages/omnichannel-services/src/QueueWorker.ts ++++ b/ee/packages/omnichannel-services/src/QueueWorker.ts +@@ -27,6 +27,9 @@ export class QueueWorker extends ServiceClass implements IQueueWorkerService { + this.logger = new loggerClass('QueueWorker'); + this.queue = new MessageQueue(); + ++ if (process.env.TEST_SCALABILITY === 'true') { ++ return; ++ } + this.onEvent('license.module', ({ module, valid }) => { + if (module === 'scalability') { + this.shouldWork = valid; +@@ -35,6 +38,9 @@ export class QueueWorker extends ServiceClass implements IQueueWorkerService { + } + + async started(): Promise { ++ if (process.env.TEST_SCALABILITY === 'true') { ++ return; ++ } + try { + this.shouldWork = await License.hasLicense('scalability'); + } catch (e: unknown) { +diff --git a/ee/packages/presence/src/Presence.ts b/ee/packages/presence/src/Presence.ts +index 9bb29b011c..0278e4b5a6 100755 +--- a/ee/packages/presence/src/Presence.ts ++++ b/ee/packages/presence/src/Presence.ts +@@ -39,6 +39,10 @@ export class Presence extends ServiceClass implements IPresence { + } + }); + ++ if (process.env.TEST_SCALABILITY === 'true') { ++ this.hasLicense = true; ++ return; ++ } + this.onEvent('license.module', ({ module, valid }) => { + if (module === 'scalability') { + this.hasLicense = valid; +@@ -58,7 +62,9 @@ export class Presence extends ServiceClass implements IPresence { + }, 10000); + + try { +- this.hasLicense = await License.hasLicense('scalability'); ++ if (process.env.TEST_SCALABILITY !== 'true') { ++ this.hasLicense = await License.hasLicense('scalability'); ++ } + + await Settings.updateValueById('Presence_broadcast_disabled', false); + } catch (e: unknown) { -- GitLab