diff --git a/.aspect/bazelrc/ci.sourcegraph.bazelrc b/.aspect/bazelrc/ci.sourcegraph.bazelrc index a21635654df..83ebec40510 100644 --- a/.aspect/bazelrc/ci.sourcegraph.bazelrc +++ b/.aspect/bazelrc/ci.sourcegraph.bazelrc @@ -1,4 +1,4 @@ -# Provides secrets like GH_TOKEN and PERCY_TOKEN via --action_env flag. +# Provides secrets like GH_TOKEN via --action_env flag. # Generated via the `.buildkite/hooks/post-checkout` hook. try-import %workspace%/.aspect/bazelrc/ci.generated.bazelrc @@ -32,7 +32,7 @@ common --test_env=HEADLESS=false common --test_env=SOURCEGRAPH_BASE_URL="http://127.0.0.1:7080" common --test_env=DISPLAY=:99 -# Provides git commit, branch information to build targets like Percy via status file. +# Provides git commit, branch information to build targets via status file. # https://bazel.build/docs/user-manual#workspace-status common --workspace_status_command=./dev/bazel_buildkite_stamp_vars.sh diff --git a/.buildkite/hooks/post-checkout b/.buildkite/hooks/post-checkout index 0240569aabd..051d25448c2 100644 --- a/.buildkite/hooks/post-checkout +++ b/.buildkite/hooks/post-checkout @@ -32,4 +32,4 @@ done ln -s "$(pwd)/dev/ci/scripts/annotated-command.sh" an 2>/dev/null || true # Provides secrets to the client integration tests target. -echo -e "build --action_env=GH_TOKEN=$GH_TOKEN\nbuild --action_env=PERCY_TOKEN=$PERCY_TOKEN" >.aspect/bazelrc/ci.generated.bazelrc +echo -e "build --action_env=GH_TOKEN=$GH_TOKEN" >.aspect/bazelrc/ci.generated.bazelrc diff --git a/.percy.yml b/.percy.yml deleted file mode 100644 index 0e09eaa76f5..00000000000 --- a/.percy.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: 2 -snapshot: - widths: - - 1920 # Full-width browser window - percy-css: | - .percy-hide, - .monaco-editor .cursor { - visibility: hidden !important; - } - .percy-inactive-element { - pointer-events: none !important; - } - .percy-display-none { - display: none !important; - } -discovery: - disable-cache: true -percy: - # Defer uploading snapshots until the very end of the test suite. - # This allows many snapshots with the same name AND different widths to be merged together. - # This is useful for flaky client integration tests that can be retried automatically. - # - # This should prevent creating a Percy build if the test suite fails according to sources: - # 1. The exit code is used force stop the local Percy server: https://github.com/percy/cli/blob/9c89383d6e1a9aa41f0c83f8e4b9ddcdf827583b/packages/cli-exec/src/exec.js#L78-L81 - # 2. The `force` options is propagated to `this.#snapshots.close(true)`: https://github.com/percy/cli/blob/master/packages/core/src/percy.js#L219-L223 - # 3. The snapshots queue is cleared if `force` is true: https://github.com/percy/cli/blob/9c89383d6e1a9aa41f0c83f8e4b9ddcdf827583b/packages/core/src/queue.js#L177 - defer-uploads: true diff --git a/client/browser/scripts/test-integration.js b/client/browser/scripts/test-integration.js index f1391244bcf..d3fdb6ff1d5 100644 --- a/client/browser/scripts/test-integration.js +++ b/client/browser/scripts/test-integration.js @@ -5,7 +5,7 @@ const { decompressRecordings, deleteRecordings } = require('./utils') // eslint-disable-next-line no-void void (async () => { await decompressRecordings() - shelljs.exec('POLLYJS_MODE=replay pnpm percy exec --quiet -- pnpm run-integration', async code => { + shelljs.exec('POLLYJS_MODE=replay pnpm run-integration', async code => { await deleteRecordings() process.exit(code) }) diff --git a/client/browser/src/integration/github.test.ts b/client/browser/src/integration/github.test.ts index f711e5ab6b1..b2843b0ee65 100644 --- a/client/browser/src/integration/github.test.ts +++ b/client/browser/src/integration/github.test.ts @@ -285,8 +285,6 @@ describe('GitHub', () => { // }, // }) - // await percySnapshot(driver.page, 'Browser extension: GitHub - blob view with code intel popup') - // // 2. Check that token click does not do anything by default // await token.click() // await driver.page.waitForTimeout(1000) diff --git a/client/browser/src/integration/gitlab.test.ts b/client/browser/src/integration/gitlab.test.ts index 832a2067616..9fd6bf87a2a 100644 --- a/client/browser/src/integration/gitlab.test.ts +++ b/client/browser/src/integration/gitlab.test.ts @@ -207,8 +207,5 @@ describe('GitLab', () => { timeout: 6000, }, }) - - // disable flaky snapshot - // await percySnapshot(driver.page, 'Browser extension: GitLab - blob view with code intel popup') }) }) diff --git a/client/browser/src/integration/shared.ts b/client/browser/src/integration/shared.ts index 2cb1611d0fb..c5a6dc96b7a 100644 --- a/client/browser/src/integration/shared.ts +++ b/client/browser/src/integration/shared.ts @@ -1,7 +1,5 @@ import type puppeteer from 'puppeteer' -import { percySnapshot as percySnapshotCommon } from '@sourcegraph/shared/src/testing/driver' - /** * Find a tab that contains the browser extension's after-install page (url * ending in `/after_install.html`) and, if found, close it. @@ -25,22 +23,3 @@ export async function closeInstallPageTab(browser: puppeteer.Browser): Promise => - page.evaluate(() => - [...document.styleSheets] - .filter(styleSheet => styleSheet.href?.startsWith('chrome-extension://')) - .reduce( - (styleSheetRules, styleSheet) => - styleSheetRules.concat( - [...styleSheet.cssRules].reduce((rules, rule) => rules.concat(rule.cssText), '') - ), - '' - ) - ) - -export const percySnapshot: typeof percySnapshotCommon = async (page, name, options) => { - const extensionStyles = await extractExtensionStyles(page) - - return percySnapshotCommon(page, name, { ...options, percyCSS: extensionStyles.concat(options?.percyCSS || '') }) -} diff --git a/client/shared/dev/BUILD.bazel b/client/shared/dev/BUILD.bazel index d68342f84aa..1d755c7819d 100644 --- a/client/shared/dev/BUILD.bazel +++ b/client/shared/dev/BUILD.bazel @@ -53,19 +53,6 @@ ts_binary( visibility = ["//client:__subpackages__"], ) -js_library( - name = "run_mocha_tests_with_percy", - srcs = ["runMochaTestsWithPercy.js"], - data = [ - "//:node_modules/@percy/cli", - "//:node_modules/@percy/puppeteer", - "//:node_modules/mocha", - "//:node_modules/puppeteer", - "//:node_modules/resolve-bin", - ], - visibility = ["//client:__subpackages__"], -) - js_library( name = "mocha-reporter", srcs = [ diff --git a/client/shared/dev/runMochaTestsWithPercy.js b/client/shared/dev/runMochaTestsWithPercy.js deleted file mode 100644 index 5409d329211..00000000000 --- a/client/shared/dev/runMochaTestsWithPercy.js +++ /dev/null @@ -1,73 +0,0 @@ -// @ts-check - -const path = require('path') -const { readFileSync } = require('fs') -const { execFileSync } = require('child_process') - -const puppeteer = require('puppeteer') -const resolveBin = require('resolve-bin') - -// Reads environment variables set by Bazel. -// It also adds a custom environment variable, "PERCY_BROWSER_EXECUTABLE", which points -// to the Puppeteer browser executable downloaded in the postinstall script. -/** @returns {Record} env vars */ -function getEnvVars() { - // JS_BINARY__EXECROOT – Set by Bazel `js_test` rule. - // JS_BINARY__BINDIR – Set by Bazel `js_test` rule. - const { JS_BINARY__EXECROOT, JS_BINARY__BINDIR } = process.env - - if (!JS_BINARY__EXECROOT || !JS_BINARY__BINDIR) { - throw new Error('Missing required environment variables') - } - - // Read the Bazel status file and convert its contents to an object. - // Here we provide information about the current BRANCH and COMMIT to allow Percy to - // build the correct visual diff report and auto-accept change on `main` if we're on it. - // https://github.com/percy/cli/blob/059ec21653a07105e223aa5a3ec1f815a7123ad7/packages/env/src/environment.js#L138-L139 - // https://bazel.build/docs/user-manual#workspace-status - // - // NB: we derive the volatile-status.txt file path from the JS_BINARY__BINDIR since we are - // intentionally pulling volatile data without defining the volatile status as an input so we - // don't bust the cache with its contents of volatile-status.txt - // (https://github.com/bazelbuild/bazel/issues/16231). This can be improved in the future by using - // the new --experimental_remote_cache_key_ignore_stamping flag in Bazel to filter out the - // volatile-status.txt file from the action inputs - // (https://github.com/bazelbuild/bazel/pull/16240) - const statusFilePath = path.join( - path.dirname(path.dirname(path.join(JS_BINARY__EXECROOT, JS_BINARY__BINDIR))), - 'volatile-status.txt' - ) - const volatileEnvVariables = Object.fromEntries( - readFileSync(statusFilePath, 'utf8') - .split('\n') - .filter(Boolean) - .map(item => item.split(' ')) - ) - - // Merge the custom "PERCY_BROWSER_EXECUTABLE" variable with the Bazel-provided variables - // This is required to skip the "download Chromium" step in Percy's "exec" command. - // https://docs.percy.io/docs/skipping-asset-discovery-browser-download#using-an-environment-variable - const customEnvVariables = { - ...volatileEnvVariables, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - PERCY_BROWSER_EXECUTABLE: puppeteer.executablePath(), - } - - // Convert the merged environment variables to a string with the "KEY=VALUE" format - return customEnvVariables -} - -// Resolve the binary paths for Percy and Mocha -const percyBin = resolveBin.sync('@percy/cli', { executable: 'percy' }) -const mochaBin = resolveBin.sync('mocha') - -// Extract command-line arguments to pass to Mocha -const args = process.argv.slice(2) - -// Execute the final command, inheriting the stdio settings from the parent process and and wrapping -// the Mocha command with Percy's "exec" command (https://docs.percy.io/docs/cli-exec). -execFileSync(percyBin, ['exec', '--', mochaBin, ...args], { - env: { ...process.env, ...getEnvVars() }, - stdio: 'inherit', -}) diff --git a/client/shared/src/testing/BUILD.bazel b/client/shared/src/testing/BUILD.bazel index c2eeeeb0d66..f1fde899312 100644 --- a/client/shared/src/testing/BUILD.bazel +++ b/client/shared/src/testing/BUILD.bazel @@ -60,7 +60,6 @@ ts_project( deps = [ "//:node_modules/@apollo/client", "//:node_modules/@axe-core/puppeteer", - "//:node_modules/@percy/puppeteer", "//:node_modules/@pollyjs/adapter", "//:node_modules/@pollyjs/core", "//:node_modules/@pollyjs/persister-fs", diff --git a/client/shared/src/testing/driver.ts b/client/shared/src/testing/driver.ts index 8343b669114..811debb20cf 100644 --- a/client/shared/src/testing/driver.ts +++ b/client/shared/src/testing/driver.ts @@ -1,24 +1,23 @@ import * as os from 'os' import * as path from 'path' -import realPercySnapshot from '@percy/puppeteer' import delay from 'delay' import expect from 'expect' import * as jsonc from 'jsonc-parser' import { escapeRegExp } from 'lodash' import { readFile } from 'mz/fs' import puppeteer, { - type PageEventObject, - type Page, - type Serializable, - type LaunchOptions, - type ConsoleMessage, - type Target, - type BrowserLaunchArgumentOptions, type BrowserConnectOptions, + type BrowserLaunchArgumentOptions, + type ConsoleMessage, + type LaunchOptions, + type Page, + type PageEventObject, + type Serializable, + type Target, } from 'puppeteer' -import { from, fromEvent, merge, Subscription } from 'rxjs' -import { filter, map, concatAll, mergeMap, mergeAll, takeUntil } from 'rxjs/operators' +import { Subscription, from, fromEvent, merge } from 'rxjs' +import { concatAll, filter, map, mergeAll, mergeMap, takeUntil } from 'rxjs/operators' import { Key } from 'ts-key-enum' import { isDefined, logger } from '@sourcegraph/common' @@ -37,7 +36,7 @@ import type { Settings } from '../settings/settings' import { getConfig } from './config' import { formatPuppeteerConsoleMessage } from './console' -import { readEnvironmentBoolean, retry } from './utils' +import { retry } from './utils' /** * Returns a Promise for the next emission of the given event on the given Puppeteer page. @@ -56,28 +55,6 @@ export const extractStyles = (page: puppeteer.Page): Promise => ) ) -interface CommonSnapshotOptions { - widths?: number[] - minHeight?: number - percyCSS?: string - enableJavaScript?: boolean - devicePixelRatio?: number - scope?: string -} - -export const percySnapshot = async ( - page: puppeteer.Page, - name: string, - options: CommonSnapshotOptions = {} -): Promise => { - if (!readEnvironmentBoolean({ variable: 'PERCY_ON', defaultValue: false })) { - return Promise.resolve() - } - - const pageStyles = await extractStyles(page) - return realPercySnapshot(page, name, { ...options, percyCSS: pageStyles.concat(options.percyCSS || '') }) -} - export const BROWSER_EXTENSION_DEV_ID = 'bmfbcejdknlknpncfpeloejonjoledha' /** @@ -723,7 +700,6 @@ export class Driver { /** * Finds the first HTML element matching the text using the regular expressions returned in * {@link findElementRegexpStrings}. - * * @param options specifies additional parameters for finding the element. If you want to wait * until the element appears, specify the `wait` field (which can contain additional inner * options for how long to wait). diff --git a/client/web/src/enterprise/batches/batch-spec/edit/RunServerSideModal.tsx b/client/web/src/enterprise/batches/batch-spec/edit/RunServerSideModal.tsx index 0d92e6bcf7f..bfc026d2179 100644 --- a/client/web/src/enterprise/batches/batch-spec/edit/RunServerSideModal.tsx +++ b/client/web/src/enterprise/batches/batch-spec/edit/RunServerSideModal.tsx @@ -40,7 +40,7 @@ export const RunServerSideModal: React.FunctionComponent