remove more ENTERPRISE=1 remnants (#57232)

There are still many places that build the old non-enterprise bundle. This is no longer needed or maintained. This change simplifies our builds by removing that unnecessary target. There are still some remnants (such as `ui/assets/{enterprise,oss}`); not *all* are removed here.
This commit is contained in:
Quinn Slack 2023-10-02 10:43:11 -07:00 committed by GitHub
parent bd61b4bcab
commit cbac3c6390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 52 additions and 431 deletions

View File

@ -2,8 +2,6 @@
import fs from 'fs'
import path from 'path'
import { getEnvironmentBoolean } from './utils/environment-config'
// TODO(bazel): drop when non-bazel removed.
const IS_BAZEL = !!(process.env.JS_BINARY__TARGET || process.env.BAZEL_BINDIR || process.env.BAZEL_TEST)
@ -34,11 +32,7 @@ export function resolveAssetsPath(root: string): string {
// and be done with it. With Bazel, we have different loaders on the backend where the assets gets embedded. So
// what we do here is "simulate" what happens in bazel, by putting the assets in the correct relative directory
// so that when the backend is compiled the assets gets embedded properly
const isEnterprise: boolean = getEnvironmentBoolean('ENTERPRISE')
const relativeAssetPath: string = isEnterprise ? 'enterprise' : 'oss'
const path: string = resolveWithSymlink(root, 'ui/assets', relativeAssetPath)
return path
return resolveWithSymlink(root, 'ui/assets/enterprise')
}
export const ROOT_PATH = IS_BAZEL ? process.cwd() : resolveWithSymlink(__dirname, '../../../')

View File

@ -2,7 +2,7 @@
* The script collects web application bundlesize information from the disk and uploads it to Honeycomb.
*
* 1. Build web application using:
* ENTERPRISE=1 NODE_ENV=production DISABLE_TYPECHECKING=true WEBPACK_USE_NAMED_CHUNKS=true pnpm build-web
* NODE_ENV=production DISABLE_TYPECHECKING=true WEBPACK_USE_NAMED_CHUNKS=true pnpm build-web
*
* 2. Upload bundlesize information to Honeycomb:
* HONEYCOMB_API_KEY=XXX pnpm --filter @sourcegraph/observability-server run bundlesize:web:upload
@ -13,7 +13,7 @@ import { execSync } from 'child_process'
import path from 'path'
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
import { cleanEnv, bool, str } from 'envalid'
import { cleanEnv, str } from 'envalid'
import { STATIC_ASSETS_PATH, WORKSPACES_PATH } from '@sourcegraph/build-config'
@ -23,7 +23,6 @@ import { libhoneySDK } from '../sdk'
import { getBundleSizeStats } from './getBundleSizeStats'
const environment = cleanEnv(process.env, {
ENTERPRISE: bool({ default: false }),
NODE_ENV: str({ choices: ['development', 'production'] }),
})
@ -56,7 +55,6 @@ for (const [baseFilePath, fileInfo] of Object.entries(bundleSizeStats)) {
'bundle.file.isDefaultVendors': fileInfo.isDefaultVendors,
'bundle.file.isCss': fileInfo.isCss,
'bundle.file.isJs': fileInfo.isJs,
'bundle.enterprise': environment.ENTERPRISE,
'bundle.env': environment.NODE_ENV,
...SDK_INFO,

View File

@ -1,5 +1,2 @@
# Whether to run the enterprise version (default). Unsetting the value
# corresponds to running the OSS version.
PUBLIC_SG_ENTERPRISE=true
PUBLIC_DOTCOM=
PUBLIC_ENABLE_EVENT_LOGGER=

View File

@ -1,15 +0,0 @@
import { error } from '@sveltejs/kit'
import { PUBLIC_SG_ENTERPRISE } from '$env/static/public'
import type { LayoutLoad } from './$types'
export const load: LayoutLoad = () => {
// Example for how we could prevent access to all enterprese specific routes.
// It's not quite the same as not having the routes at all and have the
// interpreted differently, like in the current web app.
if (!PUBLIC_SG_ENTERPRISE) {
// eslint-disable-next-line etc/throw-error, rxjs/throw-error
throw error(404, { message: 'enterprise feature' })
}
}

View File

@ -5,7 +5,7 @@ load("@npm//:bundlesize2/package_json.bzl", bundlesize_bin = "bin")
load("//client/shared/dev:generate_graphql_operations.bzl", "generate_graphql_operations")
load("//client/shared/dev:tools.bzl", "module_style_typings")
load("//dev:defs.bzl", "jest_test", "npm_package", "sass", "ts_project")
load("//dev:webpack.bzl", "webpack_bundle", "webpack_devserver", "webpack_web_app")
load("//dev:webpack.bzl", "webpack_bundle", "webpack_web_app")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("//dev:eslint.bzl", "eslint_config_and_lint_root", "eslint_test_with_types")
load("//dev:write_generated_to_source_files.bzl", "write_generated_to_source_files")
@ -163,7 +163,6 @@ ts_project(
"src/LegacyLayout.tsx",
"src/LegacyRouteContext.tsx",
"src/LegacySourcegraphWebApp.tsx",
"src/OpenSourceWebApp.tsx",
"src/PageError.tsx",
"src/SearchQueryStateObserver.tsx",
"src/SourcegraphWebApp.tsx",
@ -1125,7 +1124,6 @@ ts_project(
"src/insights/types.ts",
"src/insights/utils/use-series-toggle.ts",
"src/jscontext.ts",
"src/main.tsx",
"src/marketing/backend.ts",
"src/marketing/components/SurveyRatingRadio.tsx",
"src/marketing/components/SurveyUseCaseForm.tsx",
@ -2114,9 +2112,6 @@ BUNDLE_DATA_DEPS = [
":module_styles",
":package_styles",
"src/get-cody/SourceSans3VF-Upright.ttf.woff2",
]
ENTERPRISE_BUNDLE_DATA_DEPS = BUNDLE_DATA_DEPS + [
# TODO(bazel): this is already in the main ts_project(srcs). Why also here?
"src/enterprise/codeintel/configuration/schema.json",
":enterprise-yaml",
@ -2132,10 +2127,14 @@ ENTERPRISE_BUNDLE_DATA_DEPS = BUNDLE_DATA_DEPS + [
"//:package_json",
],
entry_points = {
"src/main.js": "app",
"src/enterprise/main.js": "app",
"src/enterprise/embed/main.js": "embed",
},
env = {
"NODE_ENV": "production" if prod else "development",
"INTEGRATION_TESTS": "false",
"WEBPACK_BUNDLE_ANALYZER": "false",
"WEBPACK_USE_NAMED_CHUNKS": "false",
},
output_dir = True,
visibility = ["//ui/assets:__subpackages__"],
@ -2148,35 +2147,11 @@ ENTERPRISE_BUNDLE_DATA_DEPS = BUNDLE_DATA_DEPS + [
]
]
webpack_bundle(
name = "bundle-enterprise",
srcs = ENTERPRISE_BUNDLE_DATA_DEPS + [
"//:babel_config",
"//:browserslist",
"//:package_json",
],
entry_points = {
"src/enterprise/main.js": "app",
"src/enterprise/embed/main.js": "embed",
},
env = {
"NODE_ENV": "production",
"ENTERPRISE": "true",
"INTEGRATION_TESTS": "false",
"WEBPACK_BUNDLE_ANALYZER": "false",
"WEBPACK_USE_NAMED_CHUNKS": "false",
},
output_dir = True,
visibility = ["//ui/assets:__subpackages__"],
webpack_config = "webpack.bazel.config.js",
deps = WEBPACK_CONFIG_DEPS,
)
# Used for integration tests and has bigger bundle size
# because of the inlined source-maps.
webpack_web_app(
name = "app-enterprise",
srcs = ENTERPRISE_BUNDLE_DATA_DEPS + [
name = "app",
srcs = BUNDLE_DATA_DEPS + [
"//:babel_config",
"//:browserslist",
"//:package_json",
@ -2186,7 +2161,6 @@ webpack_web_app(
},
env = {
"NODE_ENV": "production",
"ENTERPRISE": "true",
"INTEGRATION_TESTS": "true",
},
output_dir = True,
@ -2195,46 +2169,14 @@ webpack_web_app(
deps = WEBPACK_CONFIG_DEPS,
)
# ibazel run //client/web:devserver
# should make the web application available under http://localhost:3080/ by default.
webpack_devserver(
name = "devserver",
data = BUNDLE_DATA_DEPS + WEBPACK_CONFIG_DEPS + [
"//:babel_config",
"//:browserslist",
"//:package_json",
# references from the devserver config
"webpack.bazel.config.js",
],
entry_points = {
"src/main.js": "app",
},
env = {
"NODE_ENV": "development",
# TODO(bazel): make it dynamic or make multiple targets.
"SOURCEGRAPH_API_URL": "https://sourcegraph.sourcegraph.com",
},
webpack_config = "webpack.bazel.devserver.config.js",
)
build_test(
name = "webpack_test",
size = "enormous",
tags = ["manual"], # avoid building the oss bundle
targets = [
":bundle",
],
)
build_test(
name = "webpack_test_enterprise",
size = "enormous",
targets = [
":bundle-enterprise",
],
)
bundlesize_bin.bundlesize_test(
name = "bundlesize-report",
timeout = "short",
@ -2244,10 +2186,10 @@ bundlesize_bin.bundlesize_test(
],
data = [
"bundlesize.config.js",
":bundle-enterprise",
":bundle",
],
env = {
"INTERNAL_SKIP_CACHE": "true",
"WEB_BUNDLE_PATH": "$(rootpath //client/web:bundle-enterprise)",
"WEB_BUNDLE_PATH": "$(rootpath //client/web:bundle)",
},
)

View File

@ -4,10 +4,7 @@ function relativeAssets(base) {
if (process.env.NODE_ENV !== undefined && process.env.NODE_ENV === 'development') {
return path.join(base, '../../ui/assets')
}
if (process.env.ENTERPRISE !== undefined && process.env.ENTERPRISE === '1') {
return path.join(base, '../../ui/assets/enterprise')
}
return path.join(base, '../../ui/assets/oss')
return path.join(base, '../../ui/assets/enterprise')
}
const STATIC_ASSETS_PATH = process.env.WEB_BUNDLE_PATH || relativeAssets(__dirname)

View File

@ -21,19 +21,14 @@ import { ENVIRONMENT_CONFIG, IS_DEVELOPMENT, IS_PRODUCTION } from '../utils'
import { manifestPlugin } from './manifestPlugin'
const isEnterpriseBuild = ENVIRONMENT_CONFIG.ENTERPRISE
const isCodyApp = ENVIRONMENT_CONFIG.CODY_APP
const omitSlowDeps = ENVIRONMENT_CONFIG.DEV_WEB_BUILDER_OMIT_SLOW_DEPS
export const BUILD_OPTIONS: esbuild.BuildOptions = {
entryPoints: {
// Enterprise vs. OSS builds use different entrypoints. The enterprise entrypoint imports a
// strict superset of the OSS entrypoint.
'scripts/app': isCodyApp
? path.join(ROOT_PATH, 'client/web/src/enterprise/app-main.tsx')
: isEnterpriseBuild
? path.join(ROOT_PATH, 'client/web/src/enterprise/main.tsx')
: path.join(ROOT_PATH, 'client/web/src/main.tsx'),
: path.join(ROOT_PATH, 'client/web/src/enterprise/main.tsx'),
},
bundle: true,
minify: IS_PRODUCTION,

View File

@ -77,7 +77,6 @@ export const ENVIRONMENT_CONFIG = {
* Application features configuration.
* ----------------------------------------
*/
ENTERPRISE: getEnvironmentBoolean('ENTERPRISE'),
SOURCEGRAPHDOTCOM_MODE: getEnvironmentBoolean('SOURCEGRAPHDOTCOM_MODE'),
CODY_APP: getEnvironmentBoolean('CODY_APP'),

View File

@ -29,7 +29,7 @@
"lint:js": "NODE_OPTIONS=\"--max_old_space_size=16192\" eslint --cache '**/*.[tj]s?(x)'",
"lint:css": "stylelint 'src/**/*.scss' --quiet",
"browserslist": "pnpm exec browserslist",
"analyze-bundle": "WEBPACK_USE_NAMED_CHUNKS=true NODE_ENV=production ENTERPRISE=1 WEBPACK_BUNDLE_ANALYZER=1 pnpm build",
"analyze-bundle": "WEBPACK_USE_NAMED_CHUNKS=true NODE_ENV=production WEBPACK_BUNDLE_ANALYZER=1 pnpm build",
"bundlesize": "pnpm exec bundlesize --config=./bundlesize.config.js",
"report-bundle-diff": "ts-node-transpile-only scripts/report-bundle-diff"
},

View File

@ -22,7 +22,7 @@ js_test(
"//:node_modules/@statoscope/cli",
"//:node_modules/octokit",
"//:node_modules/shelljs",
"//client/web:bundle-enterprise",
"//client/web:bundle",
],
entry_point = "report-bundle-diff.js",
env = {
@ -31,7 +31,7 @@ js_test(
"BUILDKITE_PULL_REQUEST_REPO": "$$BUILDKITE_PULL_REQUEST_REPO",
"BUILDKITE_PULL_REQUEST": "$$BUILDKITE_PULL_REQUEST",
"GH_TOKEN": "$(GH_TOKEN)",
"WEB_BUNDLE_PATH": "$(rootpath //client/web:bundle-enterprise)",
"WEB_BUNDLE_PATH": "$(rootpath //client/web:bundle)",
},
tags = ["manual"],
)

View File

@ -1,69 +0,0 @@
import type { FC } from 'react'
import './SourcegraphWebApp.scss'
import { LegacySourcegraphWebApp } from './LegacySourcegraphWebApp'
import { orgAreaHeaderNavItems } from './org/area/navitems'
import { orgAreaRoutes } from './org/area/routes'
import { orgSettingsAreaRoutes } from './org/settings/routes'
import { orgSettingsSideBarItems } from './org/settings/sidebaritems'
import { repoContainerRoutes } from './repo/repoContainerRoutes'
import { repoHeaderActionButtons } from './repo/repoHeaderActionButtons'
import { repoRevisionContainerRoutes } from './repo/repoRevisionContainerRoutes'
import { repoSettingsAreaRoutes } from './repo/settings/routes'
import { repoSettingsSideBarGroups } from './repo/settings/sidebaritems'
import { routes } from './routes'
import { siteAdminAreaRoutes } from './site-admin/routes'
import { siteAdminSidebarGroups } from './site-admin/sidebaritems'
import {
type StaticAppConfig,
type StaticHardcodedAppConfig,
type StaticInjectedAppConfig,
windowContextConfig,
} from './staticAppConfig'
import { userAreaHeaderNavItems } from './user/area/navitems'
import { userAreaRoutes } from './user/area/routes'
import { userSettingsAreaRoutes } from './user/settings/routes'
import { userSettingsSideBarItems } from './user/settings/sidebaritems'
const injectedValuesConfig = {
/**
* Routes and nav links
*/
siteAdminAreaRoutes,
siteAdminSideBarGroups: siteAdminSidebarGroups,
siteAdminOverviewComponents: [],
userAreaRoutes,
userAreaHeaderNavItems,
userSettingsSideBarItems,
userSettingsAreaRoutes,
orgSettingsSideBarItems,
orgSettingsAreaRoutes,
orgAreaRoutes,
orgAreaHeaderNavItems,
repoContainerRoutes,
repoRevisionContainerRoutes,
repoHeaderActionButtons,
repoSettingsAreaRoutes,
repoSettingsSidebarGroups: repoSettingsSideBarGroups,
routes,
} satisfies StaticInjectedAppConfig
const hardcodedConfig = {
codeIntelligenceEnabled: false,
searchContextsEnabled: false,
notebooksEnabled: false,
codeMonitoringEnabled: false,
searchAggregationEnabled: false,
ownEnabled: false,
} satisfies StaticHardcodedAppConfig
const staticAppConfig = {
...injectedValuesConfig,
...windowContextConfig,
...hardcodedConfig,
} satisfies StaticAppConfig
// Entry point for the app without enterprise functionality.
// For more info see: https://docs.sourcegraph.com/admin/subscriptions#paid-subscriptions-for-sourcegraph-enterprise
export const OpenSourceWebApp: FC = () => <LegacySourcegraphWebApp {...staticAppConfig} />

View File

@ -1,4 +1,4 @@
// This is the entry point for the enterprise web app
// This is the entry point for the web app
// Order is important here
// Don't remove the empty lines between these imports

View File

@ -96,7 +96,6 @@ export const enterpriseSiteAdminAreaRoutes: readonly SiteAdminAreaRoute[] = (
path: '/users',
render: () => (
<UsersManagement
isEnterprise={true}
renderAssignmentModal={(onCancel, onSuccess, user) => (
<RoleAssignmentModal onCancel={onCancel} onSuccess={onSuccess} user={user} />
)}

View File

@ -112,9 +112,9 @@ mocha_test(
"--parallel",
"--jobs 16",
],
data = ["//client/web:app-enterprise"],
data = ["//client/web:app"],
env = {
"WEB_BUNDLE_PATH": "$(rootpath //client/web:app-enterprise)",
"WEB_BUNDLE_PATH": "$(rootpath //client/web:app)",
},
flaky = True,
is_percy_enabled = True,

View File

@ -1,27 +0,0 @@
// This is the entry point for the web app
// Order is important here
// Don't remove the empty lines between these imports
// prettier-ignore-start
import '@sourcegraph/shared/src/polyfills'
// prettier-ignore-end
import './initBuildInfo'
import './monitoring/initMonitoring'
import { createRoot } from 'react-dom/client'
import { RouterLink, setLinkComponent } from '@sourcegraph/wildcard'
import { OpenSourceWebApp } from './OpenSourceWebApp'
setLinkComponent(RouterLink)
// It's important to have a root component in a separate file to create a react-refresh boundary and avoid page reload.
// https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#edits-always-lead-to-full-reload
window.addEventListener('DOMContentLoaded', () => {
const root = createRoot(document.querySelector('#root')!)
root.render(<OpenSourceWebApp />)
})

View File

@ -58,7 +58,6 @@ const LIMIT = 25
interface UsersListProps {
onActionEnd?: () => void
isEnterprise: boolean
renderAssignmentModal: (
onCancel: () => void,
onSuccess: (user: { username: string }) => void,
@ -129,11 +128,7 @@ const dateRangeQueryParameterToVariable = (
}
}
export const UsersList: React.FunctionComponent<UsersListProps> = ({
onActionEnd,
renderAssignmentModal,
isEnterprise,
}) => {
export const UsersList: React.FunctionComponent<UsersListProps> = ({ onActionEnd, renderAssignmentModal }) => {
const [filters, setFilters] = useURLSyncedState(DEFAULT_FILTERS)
const debouncedSearchText = useDebounce(filters.searchText, 300)
@ -330,7 +325,7 @@ export const UsersList: React.FunctionComponent<UsersListProps> = ({
label: 'Manage roles',
icon: mdiBadgeAccount,
onClick: openRoleAssignmentModal,
condition: ([user]) => isEnterprise && !user?.deletedAt,
condition: ([user]) => !user?.deletedAt,
},
{
key: 'unlock-user',

View File

@ -16,7 +16,6 @@ import { USERS_MANAGEMENT_SUMMARY } from './queries'
import styles from './index.module.scss'
export interface UsersManagementProps {
isEnterprise: boolean
renderAssignmentModal: (
onCancel: () => void,
onSuccess: (user: { username: string }) => void,
@ -24,10 +23,7 @@ export interface UsersManagementProps {
) => React.ReactNode
}
export const UsersManagement: React.FunctionComponent<UsersManagementProps> = ({
isEnterprise,
renderAssignmentModal,
}) => {
export const UsersManagement: React.FunctionComponent<UsersManagementProps> = ({ renderAssignmentModal }) => {
useEffect(() => {
eventLogger.logPageView('UsersManagement')
}, [])
@ -121,11 +117,7 @@ export const UsersManagement: React.FunctionComponent<UsersManagementProps> = ({
) : (
<ValueLegendList className="mb-3" items={legends} />
)}
<UsersList
onActionEnd={refetch}
isEnterprise={isEnterprise}
renderAssignmentModal={renderAssignmentModal}
/>
<UsersList onActionEnd={refetch} renderAssignmentModal={renderAssignmentModal} />
</Card>
<Text className="font-italic text-center mt-2">
All events are generated from entries in the event logs table and are updated every 24 hours.

View File

@ -262,7 +262,7 @@ export const otherSiteAdminRoutes: readonly SiteAdminAreaRoute[] = [
const siteAdminUserManagementRoute: SiteAdminAreaRoute = {
path: '/users',
render: () => <UsersManagement isEnterprise={false} renderAssignmentModal={() => null} />,
render: () => <UsersManagement renderAssignmentModal={() => null} />,
}
export const siteAdminAreaRoutes: readonly SiteAdminAreaRoute[] = [

View File

@ -32,7 +32,6 @@ const {
NODE_ENV,
CI: IS_CI,
INTEGRATION_TESTS,
ENTERPRISE,
EMBED_DEVELOPMENT,
ENABLE_SENTRY,
ENABLE_OPEN_TELEMETRY,
@ -53,7 +52,7 @@ const {
const isHotReloadEnabled = NODE_ENV !== 'production' && !IS_CI
const IS_PERSISTENT_CACHE_ENABLED = false // Disabled in Bazel
const IS_EMBED_ENTRY_POINT_ENABLED = ENTERPRISE && (IS_PRODUCTION || (IS_DEVELOPMENT && EMBED_DEVELOPMENT))
const IS_EMBED_ENTRY_POINT_ENABLED = IS_PRODUCTION || (IS_DEVELOPMENT && EMBED_DEVELOPMENT)
const RUNTIME_ENV_VARIABLES = {
NODE_ENV,

View File

@ -34,7 +34,6 @@ const {
NODE_ENV,
CI: IS_CI,
INTEGRATION_TESTS,
ENTERPRISE,
EMBED_DEVELOPMENT,
ENABLE_SENTRY,
ENABLE_OPEN_TELEMETRY,
@ -56,7 +55,7 @@ const {
const isHotReloadEnabled = NODE_ENV !== 'production' && !IS_CI
const IS_PERSISTENT_CACHE_ENABLED = IS_DEVELOPMENT && !IS_CI
const IS_EMBED_ENTRY_POINT_ENABLED = ENTERPRISE && (IS_PRODUCTION || (IS_DEVELOPMENT && EMBED_DEVELOPMENT))
const IS_EMBED_ENTRY_POINT_ENABLED = IS_PRODUCTION || (IS_DEVELOPMENT && EMBED_DEVELOPMENT)
const RUNTIME_ENV_VARIABLES = {
NODE_ENV,
@ -127,15 +126,10 @@ const config = {
}),
},
entry: {
// Desktop app vs. Enterprise vs. OSS builds use different entrypoints. The enterprise entrypoint imports a
// strict superset of the OSS entrypoint. The app endoint imports a strict superset of the enterprise entrypoint.
app: CODY_APP
? path.join(enterpriseDirectory, 'app-main.tsx')
: ENTERPRISE
? path.join(enterpriseDirectory, 'main.tsx')
: path.join(__dirname, 'src', 'main.tsx'),
// Desktop app vs. web builds use different entrypoints.
app: CODY_APP ? path.join(enterpriseDirectory, 'app-main.tsx') : path.join(enterpriseDirectory, 'main.tsx'),
// Embedding entrypoint. It uses a small subset of the main webapp intended to be embedded into
// iframes on 3rd party sites. Added only in production enterprise builds or if embed development is enabled.
// iframes on 3rd party sites. Added only in production builds or if embed development is enabled.
...(IS_EMBED_ENTRY_POINT_ENABLED && { embed: path.join(enterpriseDirectory, 'embed', 'main.tsx') }),
},
output: {

View File

@ -9,11 +9,6 @@ if [ -z "$USE_KEYCLOAK" ]; then
exit 0
fi
if [ -z "$ENTERPRISE" ]; then
echo Not using Keycloak. Only runs in enterprise mode.
exit 0
fi
unset CDPATH
cd "$(dirname "${BASH_SOURCE[0]}")" # cd to dev/auth-provider dir

View File

@ -2,7 +2,6 @@
set -e
echo "ENTERPRISE=$ENTERPRISE"
echo "NODE_ENV=$NODE_ENV"
echo "# Note: NODE_ENV only used for build command"

View File

@ -83,7 +83,6 @@ commands:
install: go build .bin/frontend github.com/sourcegraph/sourcegraph/cmd/frontend
checkBinary: .bin/frontend
env:
ENTERPRISE: 1
EXTSVC_CONFIG_FILE: '../dev-private/enterprise/dev/external-services-config.json'
watch:
- lib
@ -120,7 +119,7 @@ commands:
Cmd: ".bin/frontend",
Install: "go build .bin/frontend github.com/sourcegraph/sourcegraph/cmd/frontend",
CheckBinary: ".bin/frontend",
Env: map[string]string{"ENTERPRISE": "1", "EXTSVC_CONFIG_FILE": ""},
Env: map[string]string{"EXTSVC_CONFIG_FILE": ""},
Watch: []string{
"lib",
"internal",

View File

@ -1,4 +1,4 @@
load("@aspect_rules_webpack//webpack:defs.bzl", _webpack_bundle = "webpack_bundle", _webpack_devserver = "webpack_devserver")
load("@aspect_rules_webpack//webpack:defs.bzl", _webpack_bundle = "webpack_bundle")
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
def webpack_bundle(name, **kwargs):
@ -25,10 +25,3 @@ def webpack_web_app(name, **kwargs):
srcs = ["//ui/assets/img:img", ":%s" % bundle_name],
visibility = ["//visibility:public"],
)
def webpack_devserver(name, **kwargs):
_webpack_devserver(
name = name,
webpack = "//dev:webpack",
**kwargs
)

View File

@ -44,11 +44,8 @@ All client tests (of all types such as jest and mocha) can be invoked by `bazel
The primary `client/web` bundle targets are:
* `//client/web:bundle`
* `//client/web:bundle-dev`
* `//client/web:bundle-enterprise`
See `client/web/BUILD`.
The `client/web` devserver can be run using `bazel run //client/web:devserver`
## Rule configuration
Most rules used throughout `client/*` are macros defined in `dev/*.bzl` to provide a consistent configuration used throughout the repo.

View File

@ -364,9 +364,9 @@ Gazelle will automatically remove sources added to the new BUILD file from the B
mocha_test(
name = "integration-tests",
timeout = "moderate",
data = ["//client/web:app-enterprise"],
data = ["//client/web:app"],
env = {
"WEB_BUNDLE_PATH": "$(rootpath //client/web:app-enterprise)",
"WEB_BUNDLE_PATH": "$(rootpath //client/web:app)",
},
is_percy_enabled = True,
tags = [

View File

@ -44,7 +44,7 @@ To work on most frontend issues, it is necessary to run three applications local
```sh
# Prepare web application for integration tests
ENTERPRISE=1 DISABLE_TYPECHECKING=true pnpm run build-web
DISABLE_TYPECHECKING=true pnpm run build-web
# Run integration tests
pnpm test-integration
```

View File

@ -169,7 +169,7 @@ Some common failure modes:
- Page disconnected or browser session closed: another part of the test code might have called `page.close()` asynchronously, the browser crashed (check the video), or the build got canceled.
- Node was detached from the DOM: components can change the DOM asynchronously, make sure to not rely on element handles.
- Timing problems: Use `retry()` to "poll" for a condition that cannot be expressed through `waitForSelector()` (as opposed to relying on a fixed `setTimeout()`).
- `GraphQL query X has no configured mock response` this test may need enterprise features. Run either `ENTERPRISE=1 pnpm build-web` or `ENTERPRISE=1 pnpm watch-web`
- `GraphQL query X has no configured mock response` this test may need enterprise features. Run either `pnpm build-web` or `pnpm watch-web`
Retrying the Buildkite step can help determine whether the test is flaky or broken. If it's flaky, [disable it with `it.skip()` and file an issue on the author](../background-information/testing_principles.md#flaky-tests).
@ -203,7 +203,7 @@ Test coverage from integration tests is tracked in [Codecov](https://codecov.io/
To run integration tests for the web app:
1. Run `INTEGRATION_TESTS=true ENTERPRISE=1 pnpm watch-web` in the repository root in a separate terminal to watch files and build a JavaScript bundle. You can also launch it as the VS Code task "Watch web app".
1. Run `INTEGRATION_TESTS=true pnpm watch-web` in the repository root in a separate terminal to watch files and build a JavaScript bundle. You can also launch it as the VS Code task "Watch web app".
- Alternatively, `sg run web-integration-build` will only build a bundle once.
- Alternatively, `sg run web-integration-build-prod` will only build a bundle once and will also mirror our CI setup where we use the production bundle of the web application for integration tests.
1. Run `sg test web-integration` in the repository root to run the tests.

View File

@ -16,7 +16,7 @@ go_build() {
echo "--- :chrome: Building web"
# esbuild is faster
pnpm install
NODE_ENV=production ENTERPRISE=1 CODY_APP=1 DEV_WEB_BUILDER=esbuild pnpm run build-web
NODE_ENV=production CODY_APP=1 DEV_WEB_BUILDER=esbuild pnpm run build-web
fi
export GO111MODULE=on

View File

@ -5,7 +5,7 @@ echo "Building version: ${version}"
echo "--- :chrome: Building web"
pnpm install
NODE_ENV=production ENTERPRISE=1 CODY_APP=1 pnpm run build-web
NODE_ENV=production CODY_APP=1 pnpm run build-web
export PATH=$PATH:/c/msys64/ucrt64/bin
platform="x86_64-pc-windows-msvc" # This is the name Tauri expects for the Windows executable

View File

@ -166,8 +166,8 @@ func bazelTest(targets ...string) func(*bk.Pipeline) {
// bazel build //client/web:bundle is very resource hungry and often crashes when ran along other targets
// so we run it first to avoid failing builds midway.
cmds = append(cmds,
bazelAnnouncef("bazel build //client/web:bundle-enterprise"),
bk.Cmd(bazelCmd("build //client/web:bundle-enterprise")),
bazelAnnouncef("bazel build //client/web:bundle"),
bk.Cmd(bazelCmd("build //client/web:bundle")),
)
for _, target := range targets {

View File

@ -24,10 +24,11 @@ type CoreTestOperationsOptions struct {
ChromaticShouldAutoAccept bool
MinimumUpgradeableVersion string
ForceReadyForReview bool
// for addWebAppOSSBuild
CacheBundleSize bool
CreateBundleSizeDiff bool
IsMainBranch bool
CacheBundleSize bool // for addWebAppEnterpriseBuild
CreateBundleSizeDiff bool // for addWebAppEnterpriseBuild
IsMainBranch bool
}
// CoreTestOperations is a core set of tests that should be run in most CI cases. More
@ -132,18 +133,6 @@ func addStylelint(pipeline *bk.Pipeline) {
bk.Cmd("dev/ci/pnpm-run.sh lint:css:all"))
}
// Adds steps for the OSS and Enterprise web app builds. Runs the web app tests.
func addWebAppOSSBuild(opts CoreTestOperationsOptions) operations.Operation {
return func(pipeline *bk.Pipeline) {
// Webapp build
pipeline.AddStep(":webpack::globe_with_meridians: Build",
withPnpmCache(),
bk.Cmd("dev/ci/pnpm-build.sh client/web"),
bk.Env("NODE_ENV", "production"),
bk.Env("ENTERPRISE", ""))
}
}
func addWebAppTests(opts CoreTestOperationsOptions) operations.Operation {
return func(pipeline *bk.Pipeline) {
// Webapp tests
@ -167,7 +156,6 @@ func addWebAppEnterpriseBuild(opts CoreTestOperationsOptions) operations.Operati
withPnpmCache(),
bk.Cmd("dev/ci/pnpm-build.sh client/web"),
bk.Env("NODE_ENV", "production"),
bk.Env("ENTERPRISE", "1"),
bk.Env("CHECK_BUNDLESIZE", "1"),
// Emit a stats.json file for bundle size diffs
bk.Env("WEBPACK_EXPORT_STATS", "true"),
@ -282,7 +270,6 @@ func clientIntegrationTests(pipeline *bk.Pipeline) {
pipeline.AddStep(":puppeteer::electric_plug: Puppeteer tests prep",
withPnpmCache(),
bk.Key(prepStepKey),
bk.Env("ENTERPRISE", "1"),
bk.Env("NODE_ENV", "production"),
bk.Env("INTEGRATION_TESTS", "true"),
bk.Env("COVERAGE_INSTRUMENT", "true"),

View File

@ -51,7 +51,6 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) {
// Additional flags
"FORCE_COLOR": "3",
"ENTERPRISE": "1",
// Add debug flags for scripts to consume
"CI_DEBUG_PROFILE": strconv.FormatBool(c.MessageFlags.ProfilingEnabled),
// Bump Node.js memory to prevent OOM crashes

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
set -ex
cd "$(dirname "${BASH_SOURCE[0]}")"/..
# Build a Sourcegraph server docker image with private code built in to run for
# development purposes
time cmd/server/pre-build.sh
IMAGE=sourcegraph/server:0.0.0-ENTERPRISE-DEVELOPMENT VERSION=0.0.0-ENTERPRISE-DEVELOPMENT time cmd/server/build.sh
IMAGE=sourcegraph/server:0.0.0-ENTERPRISE-DEVELOPMENT ../dev/run-server-image.sh

View File

@ -162,7 +162,6 @@ commands:
env:
CONFIGURATION_MODE: server
USE_ENHANCED_LANGUAGE_DETECTION: false
ENTERPRISE: 1
SITE_CONFIG_FILE: "../dev-private/enterprise/dev/site-config.json"
SITE_CONFIG_ESCAPE_HATCH_PATH: "$HOME/.sourcegraph/site-config.json"
# frontend processes need this to be so that the paths to the assets are rendered correctly
@ -220,8 +219,6 @@ commands:
fi
go build -gcflags="$GCFLAGS" -o .bin/repo-updater github.com/sourcegraph/sourcegraph/cmd/repo-updater
checkBinary: .bin/repo-updater
env:
ENTERPRISE: 1
watch:
- lib
- internal
@ -389,7 +386,6 @@ commands:
cmd: ./node_modules/.bin/gulp --color dev
install: pnpm install
env:
ENTERPRISE: 1
ENABLE_OPEN_TELEMETRY: true
web-standalone-http:
@ -415,14 +411,12 @@ commands:
description: Build development web application for integration tests
cmd: pnpm --filter @sourcegraph/web run build
env:
ENTERPRISE: 1
INTEGRATION_TESTS: true
web-integration-build-prod:
description: Build production web application for integration tests
cmd: pnpm --filter @sourcegraph/web run build
env:
ENTERPRISE: 1
INTEGRATION_TESTS: true
NODE_ENV: production
@ -940,7 +934,6 @@ commands:
go build -gcflags="$GCFLAGS" -ldflags="-X github.com/sourcegraph/sourcegraph/internal/conf/deploy.forceType=single-program" -o .bin/sourcegraph github.com/sourcegraph/sourcegraph/cmd/sourcegraph
checkBinary: .bin/sourcegraph
env:
ENTERPRISE: 1
SITE_CONFIG_FILE: "../dev-private/enterprise/dev/site-config.json"
SITE_CONFIG_ESCAPE_HATCH_PATH: "$HOME/.sourcegraph/site-config.json"
WEBPACK_DEV_SERVER: 1
@ -992,7 +985,6 @@ bazelCommands:
env:
CONFIGURATION_MODE: server
USE_ENHANCED_LANGUAGE_DETECTION: false
ENTERPRISE: 1
SITE_CONFIG_FILE: "../dev-private/enterprise/dev/site-config.json"
SITE_CONFIG_ESCAPE_HATCH_PATH: "$HOME/.sourcegraph/site-config.json"
# frontend processes need this to be so that the paths to the assets are rendered correctly
@ -1005,8 +997,6 @@ bazelCommands:
target: //cmd/repo-updater
precmd: |
export SOURCEGRAPH_LICENSE_GENERATION_KEY=$(cat ../dev-private/enterprise/dev/test-license-generation-key.pem)
env:
ENTERPRISE: 1
symbols:
target: //enterprise/cmd/symbols
checkBinary: .bin/symbols
@ -1466,15 +1456,11 @@ commandsets:
commands:
- web-standalone-http
- caddy
env:
ENTERPRISE: 1
web-standalone-prod:
commands:
- web-standalone-http-prod
- caddy
env:
ENTERPRISE: 1
# For testing our OpenTelemetry stack
otel:

View File

@ -3,14 +3,10 @@
// It exports a Provider global variable, that should be used by all code
// seeking to provide access to assets, regardless of their type (dev, oss
// or enterprise).
// You must also import the embedded assets:
//
// To select a particular bundle variant, use _one_ of the following imports in
// the main.go:
//
// - If you want the oss bundle:
// import _ "github.com/sourcegraph/sourcegraph/ui/assets/oss" // Select oss assets
// - If you want the enterprise bundle:
// import _ "github.com/sourcegraph/sourcegraph/ui/assets/enterprise" // Select enterprise assets
// import _ "github.com/sourcegraph/sourcegraph/ui/assets/enterprise" // Select enterprise assets
//
// And to support working with dev assets, with the webpack process handling them for you, you can use:
//

View File

@ -18,12 +18,12 @@ copy_to_directory(
srcs = [
"//:CONTRIBUTING.md",
"//client/browser:integration-assets",
"//client/web:bundle-enterprise",
"//client/web:bundle",
"//ui/assets/img",
],
out = "dist",
replace_prefixes = {
"client/web/bundle-enterprise": "",
"client/web/bundle": "",
"ui/assets/img": "img",
"client/browser/integration-assets": "",
},

View File

@ -1,28 +0,0 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
go_library(
name = "oss",
srcs = ["assets.go"],
embedsrcs = ["copy_bundle"], # keep
importpath = "github.com/sourcegraph/sourcegraph/ui/assets/oss",
visibility = ["//visibility:public"],
deps = [
"//lib/errors",
"//ui/assets",
],
)
copy_to_directory(
name = "copy_bundle",
srcs = [
"//:CONTRIBUTING.md",
"//client/web:bundle",
"//ui/assets/img",
],
out = "dist",
replace_prefixes = {
"client/web/bundle": "",
"ui/assets/img": "img",
},
)

View File

@ -1,76 +0,0 @@
package oss
import (
"embed"
"encoding/json"
"io"
"io/fs"
"net/http"
"sync"
"github.com/sourcegraph/sourcegraph/lib/errors"
"github.com/sourcegraph/sourcegraph/ui/assets"
)
//go:embed *
var assetsFS embed.FS
var afs fs.FS = assetsFS
var Assets http.FileSystem
var (
webpackManifestOnce sync.Once
assetsOnce sync.Once
webpackManifest *assets.WebpackManifest
webpackManifestErr error
)
func init() {
// Sets the global assets provider.
assets.Provider = Provider{}
}
type Provider struct{}
func (p Provider) LoadWebpackManifest() (*assets.WebpackManifest, error) {
webpackManifestOnce.Do(func() {
f, err := afs.Open("webpack.manifest.json")
if err != nil {
webpackManifestErr = errors.Wrap(err, "read manifest file")
return
}
defer f.Close()
manifestContent, err := io.ReadAll(f)
if err != nil {
webpackManifestErr = errors.Wrap(err, "read manifest file")
return
}
if err := json.Unmarshal(manifestContent, &webpackManifest); err != nil {
webpackManifestErr = errors.Wrap(err, "unmarshal manifest json")
return
}
})
return webpackManifest, webpackManifestErr
}
func (p Provider) Assets() http.FileSystem {
assetsOnce.Do(func() {
// When we're building this package with Bazel, we cannot directly output the files in this current folder, because
// it's already containing other files known to Bazel. So instead we put those into the dist folder.
// If we do detect a dist folder when running this code, we immediately substitute the root to that dist folder.
//
// Therefore, this code works with both the traditionnal build approach and when built with Bazel.
if _, err := assetsFS.ReadDir("dist"); err == nil {
var err error
afs, err = fs.Sub(assetsFS, "dist")
if err != nil {
panic("incorrect embed")
}
}
Assets = http.FS(afs)
})
return Assets
}

View File

@ -1,5 +0,0 @@
{
"environment": "development",
"app.js": "/.assets/scripts/app.bundle.js",
"runtime.js": "/.assets/scripts/runtime.bundle.js"
}