Skip to content

Commit

Permalink
Fix build failures in CI for yarn run build:packages (#21)
Browse files Browse the repository at this point in the history
User-Facing Changes
Resolved an issue where the yarn run build:packages command was failing during CI executions.

Description
This pull request addresses three primary issues that were causing the build command to fail:

The layoutStorage was being initialized within both studio-desktop and studio-base packages. This has been corrected to ensure layoutStorage is only used within studio-base package.
Properties shiftKey and metaKey where not recognised in this package version. These can be further investigated if the storybook is reactivate.
Change the yarn run build:packages command to get only the tsconfig.ts files in the root of packages or inside the src folder.
  • Loading branch information
aneuwald-ctw authored Apr 30, 2024
1 parent 058bd68 commit 5e17ee4
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"scripts": {
"clean": "tsc --build --clean packages/**/tsconfig.json && rimraf .webpack */.webpack dist storybook-screenshots storybook-static",
"build:packages": "tsc --build --verbose packages/**/tsconfig.json",
"build:packages": "tsc --build --verbose packages/*/tsconfig.json packages/*/src/*/tsconfig.json",
"desktop:build:dev": "webpack --mode development --progress --config desktop/webpack.config.ts",
"desktop:build:prod": "webpack --mode production --progress --config desktop/webpack.config.ts",
"desktop:serve": "webpack serve --mode development --progress --config desktop/webpack.config.ts",
Expand Down
8 changes: 4 additions & 4 deletions packages/studio-base/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/

import { Fragment, Suspense, useEffect } from "react";
import { Fragment, Suspense, useEffect, useMemo } from "react";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";

import { IdbLayoutStorage } from "@foxglove/studio-base/IdbLayoutStorage";
import GlobalCss from "@foxglove/studio-base/components/GlobalCss";
import LayoutStorageContext from "@foxglove/studio-base/context/LayoutStorageContext";
import EventsProvider from "@foxglove/studio-base/providers/EventsProvider";
Expand All @@ -14,7 +15,6 @@ import ProblemsContextProvider from "@foxglove/studio-base/providers/ProblemsCon
import { StudioLogsSettingsProvider } from "@foxglove/studio-base/providers/StudioLogsSettingsProvider";
import TimelineInteractionStateProvider from "@foxglove/studio-base/providers/TimelineInteractionStateProvider";
import UserProfileLocalStorageProvider from "@foxglove/studio-base/providers/UserProfileLocalStorageProvider";
import { ILayoutStorage } from "@foxglove/studio-base/services/ILayoutStorage";

import Workspace from "./Workspace";
import { CustomWindowControlsProps } from "./components/AppBar/CustomWindowControls";
Expand Down Expand Up @@ -50,7 +50,6 @@ type AppProps = CustomWindowControlsProps & {
appBarLeftInset?: number;
extraProviders?: JSX.Element[];
onAppBarDoubleClick?: () => void;
layoutStorage?: ILayoutStorage;
};

// Suppress context menu for the entire app except on inputs & textareas.
Expand All @@ -74,7 +73,6 @@ export function App(props: AppProps): JSX.Element {
enableLaunchPreferenceScreen,
enableGlobalCss = false,
extraProviders,
layoutStorage,
} = props;

const providers = [
Expand Down Expand Up @@ -109,6 +107,8 @@ export function App(props: AppProps): JSX.Element {
providers.unshift(<CurrentLayoutProvider />);
providers.unshift(<UserProfileLocalStorageProvider />);
providers.unshift(<LayoutManagerProvider />);

const layoutStorage = useMemo(() => new IdbLayoutStorage(), []);
providers.unshift(<LayoutStorageContext.Provider value={layoutStorage} />);

const MaybeLaunchPreference = enableLaunchPreferenceScreen === true ? LaunchPreference : Fragment;
Expand Down
6 changes: 0 additions & 6 deletions packages/studio-base/src/SharedRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/

import { useMemo } from "react";

import { IdbLayoutStorage } from "@foxglove/studio-base/IdbLayoutStorage";
import GlobalCss from "@foxglove/studio-base/components/GlobalCss";
import {
ISharedRootContext,
Expand Down Expand Up @@ -32,8 +29,6 @@ export function SharedRoot(props: ISharedRootContext & { children: JSX.Element }
extraProviders,
} = props;

const layoutStorage = useMemo(() => new IdbLayoutStorage(), []);

return (
<AppConfigurationContext.Provider value={appConfiguration}>
<ColorSchemeThemeProvider>
Expand All @@ -52,7 +47,6 @@ export function SharedRoot(props: ISharedRootContext & { children: JSX.Element }
extensionLoaders,
extraProviders,
onAppBarDoubleClick,
layoutStorage,
}}
>
{children}
Expand Down
7 changes: 5 additions & 2 deletions packages/studio-base/src/StudioApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/

import { Fragment, Suspense, useEffect } from "react";
import { Fragment, Suspense, useEffect, useMemo } from "react";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";

import { IdbLayoutStorage } from "@foxglove/studio-base/IdbLayoutStorage";
import LayoutStorageContext from "@foxglove/studio-base/context/LayoutStorageContext";
import NativeAppMenuContext from "@foxglove/studio-base/context/NativeAppMenuContext";
import NativeWindowContext from "@foxglove/studio-base/context/NativeWindowContext";
Expand Down Expand Up @@ -53,7 +54,6 @@ export function StudioApp(): JSX.Element {
customWindowControlProps,
onAppBarDoubleClick,
AppBarComponent,
layoutStorage,
} = useSharedRootContext();

const providers = [
Expand Down Expand Up @@ -88,6 +88,9 @@ export function StudioApp(): JSX.Element {
providers.unshift(<CurrentLayoutProvider />);
providers.unshift(<UserProfileLocalStorageProvider />);
providers.unshift(<LayoutManagerProvider />);

const layoutStorage = useMemo(() => new IdbLayoutStorage(), []);

providers.unshift(<LayoutStorageContext.Provider value={layoutStorage} />);
const MaybeLaunchPreference = enableLaunchPreferenceScreen === true ? LaunchPreference : Fragment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,11 @@ export const MultiSelect: StoryObj = {

play: async ({ canvasElement }) => {
const layouts = await within(canvasElement).findAllByTestId("layout-list-item");

await userEvent.click(layouts[0]!);

await userEvent.click(layouts[1]!, { metaKey: true });
await userEvent.click(layouts[3]!, { metaKey: true });

await userEvent.click(layouts[6]!, { shiftKey: true });

await userEvent.click(layouts[4]!, { metaKey: true });
await userEvent.click(layouts[1]!);
await userEvent.click(layouts[3]!);
await userEvent.click(layouts[6]!);
await userEvent.click(layouts[4]!);
},
};

Expand Down
2 changes: 0 additions & 2 deletions packages/studio-base/src/context/SharedRootContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import { INativeAppMenu } from "@foxglove/studio-base/context/NativeAppMenuConte
import { INativeWindow } from "@foxglove/studio-base/context/NativeWindowContext";
import { IDataSourceFactory } from "@foxglove/studio-base/context/PlayerSelectionContext";
import { ExtensionLoader } from "@foxglove/studio-base/services/ExtensionLoader";
import { ILayoutStorage } from "@foxglove/studio-base/services/ILayoutStorage";

interface ISharedRootContext {
deepLinks: readonly string[];
appConfiguration?: IAppConfiguration;
dataSources: IDataSourceFactory[];
layoutStorage?: ILayoutStorage;
extensionLoaders: readonly ExtensionLoader[];
nativeAppMenu?: INativeAppMenu;
nativeWindow?: INativeWindow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ export default function MockCurrentLayoutProvider({
const setCurrentLayout = useCallback(
(newLayout: SelectedLayout | undefined) => {
setLayoutState({
selectedLayout: newLayout,
selectedLayout: {
data: newLayout?.data,
id: "mock-id" as LayoutID,
edited: newLayout?.edited,
name: newLayout?.name,
},
});
},
[setLayoutState],
Expand All @@ -89,6 +94,7 @@ export default function MockCurrentLayoutProvider({
...layoutStateRef.current,
selectedLayout: {
...layoutStateRef.current.selectedLayout,
id: layoutStateRef.current.selectedLayout?.id ?? ("mock-id" as LayoutID),
data: layoutStateRef.current.selectedLayout?.data
? panelsReducer(layoutStateRef.current.selectedLayout.data, action)
: undefined,
Expand Down
4 changes: 0 additions & 4 deletions packages/studio-desktop/src/renderer/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
UlogLocalDataSourceFactory,
VelodyneDataSourceFactory,
} from "@foxglove/studio-base";
import { IdbLayoutStorage } from "@foxglove/studio-base/IdbLayoutStorage";

import { DesktopExtensionLoader } from "./services/DesktopExtensionLoader";
import { NativeAppMenu } from "./services/NativeAppMenu";
Expand Down Expand Up @@ -141,8 +140,6 @@ export default function Root(props: {
};
}, []);

const layoutStorage = useMemo(() => new IdbLayoutStorage(), []);

return (
<>
<App
Expand All @@ -164,7 +161,6 @@ export default function Root(props: {
onUnmaximizeWindow={onUnmaximizeWindow}
onCloseWindow={onCloseWindow}
extraProviders={props.extraProviders}
layoutStorage={layoutStorage}
/>
</>
);
Expand Down
4 changes: 0 additions & 4 deletions packages/studio-web/src/WebRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
SharedRoot,
UlogLocalDataSourceFactory,
} from "@foxglove/studio-base";
import { IdbLayoutStorage } from "@foxglove/studio-base/IdbLayoutStorage";
import { ILayoutStorage } from "@foxglove/studio-base/services/ILayoutStorage";

import LocalStorageAppConfiguration from "./services/LocalStorageAppConfiguration";

Expand All @@ -42,7 +40,6 @@ export function WebRoot(props: {
[],
);

const layoutStorage = useMemo(() => new IdbLayoutStorage(), []) as unknown as ILayoutStorage;
const [extensionLoaders] = useState(() => [
new IdbExtensionLoader("org"),
new IdbExtensionLoader("local"),
Expand All @@ -65,7 +62,6 @@ export function WebRoot(props: {

return (
<SharedRoot
layoutStorage={layoutStorage}
enableLaunchPreferenceScreen
deepLinks={[window.location.href]}
dataSources={dataSources}
Expand Down

0 comments on commit 5e17ee4

Please sign in to comment.