From 868472f43e800deef84d3194aa8d3f8c2732f9bd Mon Sep 17 00:00:00 2001 From: Valery Bugakov Date: Thu, 14 Apr 2022 00:37:25 -0700 Subject: [PATCH] ci: run client linters on changed files (#33701) --- .vscode/tasks.json | 2 +- client/branded/package.json | 4 +- client/browser/package.json | 4 +- client/build-config/package.json | 2 +- client/client-api/package.json | 2 +- client/codeintellify/package.json | 4 +- .../src/testutils/github/styles.css | 1 + .../src/testutils/sourcegraph/styles.css | 1 + client/common/package.json | 2 +- client/eslint-plugin-sourcegraph/package.json | 2 +- client/extension-api-types/package.json | 2 +- client/extension-api/package.json | 2 +- client/http-client/package.json | 2 +- client/search-ui/package.json | 2 +- .../input/CodeMirrorQueryInput.module.scss | 3 + .../src/input/CodeMirrorQueryInput.tsx | 2 +- ...treamingProgressSkippedPopover.module.scss | 2 + client/search/package.json | 2 +- client/shared/package.json | 4 +- client/storybook/package.json | 2 +- client/template-parser/package.json | 2 +- client/vscode/.stylelintrc.json | 11 ++++ client/vscode/package.json | 2 +- client/web/package.json | 4 +- client/wildcard/package.json | 4 +- dev/ci/yarn-web-integration.sh | 2 +- dev/foreach-ts-project.sh | 1 - dev/release/package.json | 4 +- .../architecture/architecture.css | 1 + .../background-information/ci/reference.md | 22 ++++---- doc/dev/background-information/web/web_app.md | 2 +- doc/dev/contributing/frontend_contribution.md | 8 +-- enterprise/dev/ci/internal/ci/operations.go | 55 +++++++++++++------ enterprise/dev/ci/internal/ci/pipeline.go | 9 ++- package.json | 20 ++++--- 35 files changed, 119 insertions(+), 75 deletions(-) create mode 100644 client/vscode/.stylelintrc.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1e7605ccf541..89ffcad30564 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -39,7 +39,7 @@ { "label": "stylelint", "command": "yarn", - "args": ["-s", "run", "all:stylelint", "--", "--formatter", "compact"], + "args": ["-s", "run", "lint:css:all", "--", "--formatter", "compact"], "problemMatcher": { "owner": "stylelint", "applyTo": "closedDocuments", diff --git a/client/branded/package.json b/client/branded/package.json index 9d297165fdc6..9119a6c8aca8 100644 --- a/client/branded/package.json +++ b/client/branded/package.json @@ -5,8 +5,8 @@ "license": "Apache-2.0", "scripts": { "storybook": "STORIES_GLOB=client/branded/src/**/*.story.tsx yarn workspace @sourcegraph/storybook run start", - "eslint": "eslint --cache '**/*.[jt]s?(x)'", - "stylelint": "stylelint 'src/**/*.scss' --quiet", + "lint:js": "eslint --cache '**/*.[jt]s?(x)'", + "lint:css": "stylelint 'src/**/*.scss' --quiet", "test": "jest" } } diff --git a/client/browser/package.json b/client/browser/package.json index 9d46130513c1..a0265ed765ea 100644 --- a/client/browser/package.json +++ b/client/browser/package.json @@ -23,8 +23,8 @@ "release:firefox": "./scripts/release-firefox.sh", "release:npm": "TS_NODE_COMPILER_OPTIONS=\"{\\\"module\\\":\\\"commonjs\\\"}\" ts-node ./scripts/publish-npm.ts", "lint": "yarn run eslint && yarn run stylelint", - "eslint": "eslint --cache '**/*.[jt]s?(x)'", - "stylelint": "stylelint 'src/**/*.scss'", + "lint:js": "eslint --cache '**/*.[jt]s?(x)'", + "lint:css": "stylelint 'src/**/*.scss'", "clean": "rm -rf build/ dist/ *.zip *.xpi .checksum", "test": "jest --testPathIgnorePatterns end-to-end integration", "test-e2e": "mocha './src/end-to-end/**/*.test.ts'", diff --git a/client/build-config/package.json b/client/build-config/package.json index 589bc18551ee..7fc828d57ce2 100644 --- a/client/build-config/package.json +++ b/client/build-config/package.json @@ -7,7 +7,7 @@ "sideEffects": false, "license": "Apache-2.0", "scripts": { - "eslint": "eslint --cache 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'", "test": "jest" } } diff --git a/client/client-api/package.json b/client/client-api/package.json index 14a955872f0f..b2bf51322485 100644 --- a/client/client-api/package.json +++ b/client/client-api/package.json @@ -7,7 +7,7 @@ "sideEffects": false, "license": "Apache-2.0", "scripts": { - "eslint": "eslint --cache 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'", "test": "jest" } } diff --git a/client/codeintellify/package.json b/client/codeintellify/package.json index b7a867432796..a50cfdbe0b1a 100644 --- a/client/codeintellify/package.json +++ b/client/codeintellify/package.json @@ -7,7 +7,7 @@ "sideEffects": false, "license": "Apache-2.0", "scripts": { - "eslint": "eslint --cache 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'", "test": "jest" } -} \ No newline at end of file +} diff --git a/client/codeintellify/src/testutils/github/styles.css b/client/codeintellify/src/testutils/github/styles.css index 4013366321bf..19714999a84c 100644 --- a/client/codeintellify/src/testutils/github/styles.css +++ b/client/codeintellify/src/testutils/github/styles.css @@ -1,3 +1,4 @@ +/* stylelint-disable */ .github-testase * { box-sizing: border-box; } diff --git a/client/codeintellify/src/testutils/sourcegraph/styles.css b/client/codeintellify/src/testutils/sourcegraph/styles.css index 3fde919a453f..c1bc34d10d47 100644 --- a/client/codeintellify/src/testutils/sourcegraph/styles.css +++ b/client/codeintellify/src/testutils/sourcegraph/styles.css @@ -1,3 +1,4 @@ +/* stylelint-disable */ .sourcegraph-testcase * { box-sizing: border-box; } diff --git a/client/common/package.json b/client/common/package.json index e7eac24138c7..33e4036074cd 100644 --- a/client/common/package.json +++ b/client/common/package.json @@ -7,7 +7,7 @@ "sideEffects": false, "license": "Apache-2.0", "scripts": { - "eslint": "eslint --cache 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'", "test": "jest" } } diff --git a/client/eslint-plugin-sourcegraph/package.json b/client/eslint-plugin-sourcegraph/package.json index 21b08105e86f..a591baf8615e 100644 --- a/client/eslint-plugin-sourcegraph/package.json +++ b/client/eslint-plugin-sourcegraph/package.json @@ -10,7 +10,7 @@ ], "main": "lib/index.js", "scripts": { - "eslint": "echo 'TODO: add proper ESLint config, issue #19448'", + "lint:js": "echo 'TODO: add proper ESLint config, issue #19448'", "test": "mocha tests --recursive" }, "dependencies": { diff --git a/client/extension-api-types/package.json b/client/extension-api-types/package.json index 7d03e1960fcd..708efc002ab1 100644 --- a/client/extension-api-types/package.json +++ b/client/extension-api-types/package.json @@ -19,7 +19,7 @@ ], "sideEffects": false, "scripts": { - "eslint": "eslint 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint 'src/**/*.[jt]s?(x)'", "prepublishOnly": "yarn run eslint" }, "peerDependencies": { diff --git a/client/extension-api/package.json b/client/extension-api/package.json index 7905930e06b9..bd5c967e052e 100644 --- a/client/extension-api/package.json +++ b/client/extension-api/package.json @@ -21,7 +21,7 @@ ], "sideEffects": false, "scripts": { - "eslint": "eslint 'src/*.[jt]s?(x)'", + "lint:js": "eslint 'src/*.[jt]s?(x)'", "docs": "typedoc", "prepublishOnly": "yarn run eslint && yarn run docs" }, diff --git a/client/http-client/package.json b/client/http-client/package.json index a689ba3fbe3c..0eb609f8f05a 100644 --- a/client/http-client/package.json +++ b/client/http-client/package.json @@ -7,7 +7,7 @@ "sideEffects": false, "license": "Apache-2.0", "scripts": { - "eslint": "eslint --cache 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'", "test": "jest" } } diff --git a/client/search-ui/package.json b/client/search-ui/package.json index eb8d24c96ae0..f10a488355c2 100644 --- a/client/search-ui/package.json +++ b/client/search-ui/package.json @@ -8,7 +8,7 @@ "license": "Apache-2.0", "scripts": { "storybook": "STORIES_GLOB=client/search-ui/src/**/*.story.tsx yarn workspace @sourcegraph/storybook run start", - "eslint": "eslint --cache 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'", "test": "jest" } } diff --git a/client/search-ui/src/input/CodeMirrorQueryInput.module.scss b/client/search-ui/src/input/CodeMirrorQueryInput.module.scss index e2de2f357ec3..9369a77c1d32 100644 --- a/client/search-ui/src/input/CodeMirrorQueryInput.module.scss +++ b/client/search-ui/src/input/CodeMirrorQueryInput.module.scss @@ -1,3 +1,5 @@ +// This rule is disable to preserve 1-1 mapping between `DecoratedToken` types and classes. +/* stylelint-disable selector-class-pattern */ .root { flex: 1; min-width: 0; @@ -46,6 +48,7 @@ code { background-color: rgba(220, 220, 220, 0.4); border-radius: var(--border-radius); + /* stylelint-disable-next-line declaration-property-unit-allowed-list */ padding: 0 0.4em; } diff --git a/client/search-ui/src/input/CodeMirrorQueryInput.tsx b/client/search-ui/src/input/CodeMirrorQueryInput.tsx index 4b303792491a..13074045703a 100644 --- a/client/search-ui/src/input/CodeMirrorQueryInput.tsx +++ b/client/search-ui/src/input/CodeMirrorQueryInput.tsx @@ -375,7 +375,7 @@ const tokenDecorators: { [key: string]: Decoration } = Object.fromEntries( const emptyDecorator = Decoration.mark({}) const focusedFilterDeco = Decoration.mark({ class: styles.focusedFilter }) -// Chooses the correct decorator for the decorated token. Copied (and adapated) +// Chooses the correct decorator for the decorated token. Copied (and adapted) // from decoratedToMonaco (decoratedToken.ts). const decoratedToDecoration = (token: DecoratedToken): Decoration => { let cssClass = 'identifier' diff --git a/client/search-ui/src/results/progress/StreamingProgressSkippedPopover.module.scss b/client/search-ui/src/results/progress/StreamingProgressSkippedPopover.module.scss index 12f3aedbca85..788d1deacf2a 100644 --- a/client/search-ui/src/results/progress/StreamingProgressSkippedPopover.module.scss +++ b/client/search-ui/src/results/progress/StreamingProgressSkippedPopover.module.scss @@ -30,6 +30,7 @@ // Border should appear directly under the width of the icon // Halfway past the icon, minus half the border size + /* stylelint-disable scss/operator-no-newline-after */ margin-left: calc( var(--icon-inline-size) / 2 - var(--streaming-skipped-item-message-border-size) / 2 + var(--streaming-skipped-item-button-margin) @@ -39,6 +40,7 @@ var(--icon-inline-size) / 2 - var(--streaming-skipped-item-message-border-size) / 2 + var(--streaming-skipped-item-button-margin) ); + /* stylelint-enable scss/operator-no-newline-after */ margin-right: var(--streaming-skipped-item-button-margin); } diff --git a/client/search/package.json b/client/search/package.json index a627fa7d5c49..fed4b10dde20 100644 --- a/client/search/package.json +++ b/client/search/package.json @@ -7,7 +7,7 @@ "sideEffects": false, "license": "Apache-2.0", "scripts": { - "eslint": "eslint --cache 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'", "test": "jest" } } diff --git a/client/shared/package.json b/client/shared/package.json index f7634fd4d63b..0c74dee433d2 100644 --- a/client/shared/package.json +++ b/client/shared/package.json @@ -5,8 +5,8 @@ "license": "Apache-2.0", "scripts": { "storybook": "STORIES_GLOB=client/shared/src/**/*.story.tsx yarn workspace @sourcegraph/storybook run start", - "eslint": "eslint --cache '**/*.[jt]s?(x)'", - "stylelint": "stylelint 'src/**/*.scss' --quiet", + "lint:js": "eslint --cache '**/*.[jt]s?(x)'", + "lint:css": "stylelint 'src/**/*.scss' --quiet", "test": "jest", "graphql": "gulp graphQlSchema", "schema": "gulp schema", diff --git a/client/storybook/package.json b/client/storybook/package.json index b7a3c86bc7e5..c7cc0cc514b8 100644 --- a/client/storybook/package.json +++ b/client/storybook/package.json @@ -7,7 +7,7 @@ "license": "Apache-2.0", "main": "./src/index.ts", "scripts": { - "eslint": "eslint --cache 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'", "start": "TS_NODE_TRANSPILE_ONLY=true start-storybook -p 9001 -c ./src -s ./assets,../../ui/assets", "build": "TS_NODE_TRANSPILE_ONLY=true build-storybook -c ./src -s ./assets,../../ui/assets", "build:webpack-stats": "TS_NODE_TRANSPILE_ONLY=true WEBPACK_DLL_PLUGIN=false start-storybook -c ./src -s ./assets --smoke-test --webpack-stats-json ./storybook-static --loglevel warn", diff --git a/client/template-parser/package.json b/client/template-parser/package.json index aa69084a9752..176c5bacc5ec 100644 --- a/client/template-parser/package.json +++ b/client/template-parser/package.json @@ -7,7 +7,7 @@ "sideEffects": false, "license": "Apache-2.0", "scripts": { - "eslint": "eslint --cache 'src/**/*.[jt]s?(x)'", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'", "test": "jest" } } diff --git a/client/vscode/.stylelintrc.json b/client/vscode/.stylelintrc.json new file mode 100644 index 000000000000..d1e4f59e66b5 --- /dev/null +++ b/client/vscode/.stylelintrc.json @@ -0,0 +1,11 @@ +{ + "extends": ["../../.stylelintrc.json"], + "overrides": [ + { + "files": ["./src/webview/index.scss"], + "rules": { + "filenames/match-regex": null + } + } + ] +} diff --git a/client/vscode/package.json b/client/vscode/package.json index 4ae87322eb17..9af98cf963ca 100644 --- a/client/vscode/package.json +++ b/client/vscode/package.json @@ -207,7 +207,7 @@ } }, "scripts": { - "eslint": "eslint --cache '**/*.[jt]s?(x)'", + "lint:js": "eslint --cache '**/*.[jt]s?(x)'", "test": "ts-node ./tests/runTests.ts", "package": "ts-node ./scripts/package.ts", "task:gulp": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192\" gulp", diff --git a/client/web/package.json b/client/web/package.json index 387f98cd224c..d9e92581fee6 100644 --- a/client/web/package.json +++ b/client/web/package.json @@ -27,8 +27,8 @@ "watch-webpack": "yarn task:gulp watchWebpack", "webpack": "yarn task:gulp webpack", "lint": "yarn run eslint && gulp unusedExports && yarn run stylelint", - "eslint": "NODE_OPTIONS=\"--max_old_space_size=16192\" eslint --cache '**/*.[tj]s?(x)'", - "stylelint": "stylelint 'src/**/*.scss' --quiet", + "lint:js": "NODE_OPTIONS=\"--max_old_space_size=16192\" eslint --cache '**/*.[tj]s?(x)'", + "lint:css": "stylelint 'src/**/*.scss' --quiet", "browserslist": "browserslist", "analyze-bundle": "WEBPACK_USE_NAMED_CHUNKS=true NODE_ENV=production ENTERPRISE=1 WEBPACK_ANALYZER=1 yarn build", "bundlesize": "bundlesize --config=./bundlesize.config.js" diff --git a/client/wildcard/package.json b/client/wildcard/package.json index f17719f5bf13..a3f2e9b41be9 100644 --- a/client/wildcard/package.json +++ b/client/wildcard/package.json @@ -8,8 +8,8 @@ "license": "Apache-2.0", "scripts": { "storybook": "STORIES_GLOB=client/wildcard/src/**/*.story.tsx yarn workspace @sourcegraph/storybook run start", - "eslint": "eslint --cache '**/*.[jt]s?(x)'", - "stylelint": "stylelint 'src/**/*.scss' --quiet", + "lint:js": "eslint --cache '**/*.[jt]s?(x)'", + "lint:css": "stylelint 'src/**/*.scss' --quiet", "test": "jest" } } diff --git a/dev/ci/yarn-web-integration.sh b/dev/ci/yarn-web-integration.sh index 03fa9fc22dea..5ac826f1842f 100755 --- a/dev/ci/yarn-web-integration.sh +++ b/dev/ci/yarn-web-integration.sh @@ -11,7 +11,7 @@ echo "--- Yarn install in root" yarn --mutex network --frozen-lockfile --network-timeout 60000 echo "--- Run integration test suite" -yarn percy exec yarn cover-integration:base "$@" +yarn percy exec yarn _cover-integration "$@" echo "--- Process NYC report" yarn nyc report -r json diff --git a/dev/foreach-ts-project.sh b/dev/foreach-ts-project.sh index 693d34e2ef0a..7493082a3b4d 100755 --- a/dev/foreach-ts-project.sh +++ b/dev/foreach-ts-project.sh @@ -29,7 +29,6 @@ DIRS=( client/storybook client/client-api dev/release - dev/ts-morph ) run_command() { diff --git a/dev/release/package.json b/dev/release/package.json index 43d79439fdf5..6fc7aa287a20 100644 --- a/dev/release/package.json +++ b/dev/release/package.json @@ -3,8 +3,8 @@ "description": "Scripts for managing release captain duties", "private": true, "scripts": { - "release": "../../node_modules/.bin/ts-node --transpile-only ./src/main.ts", - "eslint": "../../node_modules/.bin/eslint 'src/**/*.ts'" + "release": "ts-node --transpile-only ./src/main.ts", + "lint:js": "eslint --cache 'src/**/*.[jt]s?(x)'" }, "dependencies": {} } diff --git a/doc/dev/background-information/architecture/architecture.css b/doc/dev/background-information/architecture/architecture.css index 39cfb7b73b30..006997bd9752 100644 --- a/doc/dev/background-information/architecture/architecture.css +++ b/doc/dev/background-information/architecture/architecture.css @@ -1,3 +1,4 @@ +/* stylelint-disable */ @import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600&display=swap'); @media (prefers-color-scheme: dark) { diff --git a/doc/dev/background-information/ci/reference.md b/doc/dev/background-information/ci/reference.md index 61186a17a1bc..19e828d1d88f 100644 --- a/doc/dev/background-information/ci/reference.md +++ b/doc/dev/background-information/ci/reference.md @@ -23,12 +23,12 @@ The default run type. - **Pipeline setup**: Trigger async - Client PR preview - **Linters and static analysis**: Prettier, Misc linters, Yarn deduplicate lint - - **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, ESLint, Build TS, Stylelint + - **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, Build TS, ESLint (changed), Stylelint (changed) - Upload build trace - Pipeline for `GraphQL` changes: - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint - - **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, ESLint, Build TS, Stylelint + - **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, Build TS, ESLint (changed), Stylelint (changed) - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - Upload build trace @@ -78,9 +78,8 @@ The run type for environment including `{"BEXT_NIGHTLY":"true"}`. Base pipeline (more steps might be included based on branch changes): -- ESLint -- Build TS -- Stylelint +- ESLint (all) +- Stylelint (all) - Test (client/browser) - Puppeteer tests for chrome extension - Test (all) @@ -97,7 +96,7 @@ Base pipeline (more steps might be included based on branch changes): - **Image builds**: Build alpine-3.12, Build alpine-3.14, Build cadvisor, Build codeinsights-db, Build codeintel-db, Build frontend, Build github-proxy, Build gitserver, Build grafana, Build indexed-searcher, Build jaeger-agent, Build jaeger-all-in-one, Build minio, Build postgres-12-alpine, Build postgres_exporter, Build precise-code-intel-worker, Build prometheus, Build redis-cache, Build redis-store, Build redis_exporter, Build repo-updater, Build search-indexer, Build searcher, Build symbols, Build syntax-highlighter, Build worker, Build migrator, Build server, Build sg - **Image security scans**: Scan alpine-3.12, Scan alpine-3.14, Scan cadvisor, Scan codeinsights-db, Scan codeintel-db, Scan frontend, Scan github-proxy, Scan gitserver, Scan grafana, Scan indexed-searcher, Scan jaeger-agent, Scan jaeger-all-in-one, Scan minio, Scan postgres-12-alpine, Scan postgres_exporter, Scan precise-code-intel-worker, Scan prometheus, Scan redis-cache, Scan redis-store, Scan redis_exporter, Scan repo-updater, Scan search-indexer, Scan searcher, Scan symbols, Scan syntax-highlighter, Scan worker, Scan migrator, Scan server, Scan sg - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint, SVG lint, Yarn deduplicate lint, Docker linters, Check and build docsite -- **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, ESLint, Build TS, Stylelint +- **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, Build TS, ESLint (all), Stylelint (all) - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - **DB backcompat tests**: Backcompat test (all), Backcompat test (enterprise/internal/codeintel/stores/dbstore), Backcompat test (enterprise/internal/codeintel/stores/lsifstore), Backcompat test (enterprise/internal/insights), Backcompat test (internal/database), Backcompat test (internal/repos), Backcompat test (enterprise/internal/batches), Backcompat test (cmd/frontend), Backcompat test (enterprise/internal/database), Backcompat test (enterprise/cmd/frontend/internal/batches/resolvers) - **CI script tests**: test-trace-command.sh @@ -116,7 +115,7 @@ Base pipeline (more steps might be included based on branch changes): - **Image builds**: Build alpine-3.12, Build alpine-3.14, Build cadvisor, Build codeinsights-db, Build codeintel-db, Build frontend, Build github-proxy, Build gitserver, Build grafana, Build indexed-searcher, Build jaeger-agent, Build jaeger-all-in-one, Build minio, Build postgres-12-alpine, Build postgres_exporter, Build precise-code-intel-worker, Build prometheus, Build redis-cache, Build redis-store, Build redis_exporter, Build repo-updater, Build search-indexer, Build searcher, Build symbols, Build syntax-highlighter, Build worker, Build migrator, Build server, Build sg, Build executor image, Build docker registry mirror image - **Image security scans**: Scan alpine-3.12, Scan alpine-3.14, Scan cadvisor, Scan codeinsights-db, Scan codeintel-db, Scan frontend, Scan github-proxy, Scan gitserver, Scan grafana, Scan indexed-searcher, Scan jaeger-agent, Scan jaeger-all-in-one, Scan minio, Scan postgres-12-alpine, Scan postgres_exporter, Scan precise-code-intel-worker, Scan prometheus, Scan redis-cache, Scan redis-store, Scan redis_exporter, Scan repo-updater, Scan search-indexer, Scan searcher, Scan symbols, Scan syntax-highlighter, Scan worker, Scan migrator, Scan server, Scan sg - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint, SVG lint, Yarn deduplicate lint, Docker linters, Check and build docsite -- **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, ESLint, Build TS, Stylelint +- **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, Build TS, ESLint (all), Stylelint (all) - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - **DB backcompat tests**: Backcompat test (all), Backcompat test (enterprise/internal/codeintel/stores/dbstore), Backcompat test (enterprise/internal/codeintel/stores/lsifstore), Backcompat test (enterprise/internal/insights), Backcompat test (internal/database), Backcompat test (internal/repos), Backcompat test (enterprise/internal/batches), Backcompat test (cmd/frontend), Backcompat test (enterprise/internal/database), Backcompat test (enterprise/cmd/frontend/internal/batches/resolvers) - **CI script tests**: test-trace-command.sh @@ -131,9 +130,8 @@ The run type for branches matching `bext/release` (exact match). Base pipeline (more steps might be included based on branch changes): -- ESLint -- Build TS -- Stylelint +- ESLint (all) +- Stylelint (all) - Test (client/browser) - Puppeteer tests for chrome extension - Test (all) @@ -153,7 +151,7 @@ Base pipeline (more steps might be included based on branch changes): - **Image builds**: Build alpine-3.12, Build alpine-3.14, Build cadvisor, Build codeinsights-db, Build codeintel-db, Build frontend, Build github-proxy, Build gitserver, Build grafana, Build indexed-searcher, Build jaeger-agent, Build jaeger-all-in-one, Build minio, Build postgres-12-alpine, Build postgres_exporter, Build precise-code-intel-worker, Build prometheus, Build redis-cache, Build redis-store, Build redis_exporter, Build repo-updater, Build search-indexer, Build searcher, Build symbols, Build syntax-highlighter, Build worker, Build migrator, Build server, Build sg, Build executor image - **Image security scans**: Scan alpine-3.12, Scan alpine-3.14, Scan cadvisor, Scan codeinsights-db, Scan codeintel-db, Scan frontend, Scan github-proxy, Scan gitserver, Scan grafana, Scan indexed-searcher, Scan jaeger-agent, Scan jaeger-all-in-one, Scan minio, Scan postgres-12-alpine, Scan postgres_exporter, Scan precise-code-intel-worker, Scan prometheus, Scan redis-cache, Scan redis-store, Scan redis_exporter, Scan repo-updater, Scan search-indexer, Scan searcher, Scan symbols, Scan syntax-highlighter, Scan worker, Scan migrator, Scan server, Scan sg - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint, SVG lint, Yarn deduplicate lint, Docker linters, Check and build docsite -- **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, ESLint, Build TS, Stylelint +- **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, Build TS, ESLint (all), Stylelint (all) - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - **DB backcompat tests**: Backcompat test (all), Backcompat test (enterprise/internal/codeintel/stores/dbstore), Backcompat test (enterprise/internal/codeintel/stores/lsifstore), Backcompat test (enterprise/internal/insights), Backcompat test (internal/database), Backcompat test (internal/repos), Backcompat test (enterprise/internal/batches), Backcompat test (cmd/frontend), Backcompat test (enterprise/internal/database), Backcompat test (enterprise/cmd/frontend/internal/batches/resolvers) - **CI script tests**: test-trace-command.sh @@ -177,7 +175,7 @@ Base pipeline (more steps might be included based on branch changes): - **Image builds**: Build alpine-3.12, Build alpine-3.14, Build cadvisor, Build codeinsights-db, Build codeintel-db, Build frontend, Build github-proxy, Build gitserver, Build grafana, Build indexed-searcher, Build jaeger-agent, Build jaeger-all-in-one, Build minio, Build postgres-12-alpine, Build postgres_exporter, Build precise-code-intel-worker, Build prometheus, Build redis-cache, Build redis-store, Build redis_exporter, Build repo-updater, Build search-indexer, Build searcher, Build symbols, Build syntax-highlighter, Build worker, Build migrator, Build server, Build sg, Build executor image - **Image security scans**: Scan alpine-3.12, Scan alpine-3.14, Scan cadvisor, Scan codeinsights-db, Scan codeintel-db, Scan frontend, Scan github-proxy, Scan gitserver, Scan grafana, Scan indexed-searcher, Scan jaeger-agent, Scan jaeger-all-in-one, Scan minio, Scan postgres-12-alpine, Scan postgres_exporter, Scan precise-code-intel-worker, Scan prometheus, Scan redis-cache, Scan redis-store, Scan redis_exporter, Scan repo-updater, Scan search-indexer, Scan searcher, Scan symbols, Scan syntax-highlighter, Scan worker, Scan migrator, Scan server, Scan sg - **Linters and static analysis**: Prettier, Misc linters, GraphQL lint, SVG lint, Yarn deduplicate lint, Docker linters, Check and build docsite -- **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, ESLint, Build TS, Stylelint +- **Client checks**: Puppeteer tests prep, Puppeteer tests for chrome extension, Puppeteer tests chunk #1, Puppeteer tests chunk #2, Puppeteer tests chunk #3, Puppeteer tests chunk #4, Puppeteer tests chunk #5, Puppeteer tests chunk #6, Puppeteer tests chunk #7, Puppeteer tests chunk #8, Puppeteer tests chunk #9, Upload Storybook to Chromatic, Test (all), Build, Enterprise build, Test (client/web), Test (client/browser), Puppeteer tests for VS Code extension, Build TS, ESLint (all), Stylelint (all) - **Go checks**: Test (all), Test (enterprise/internal/codeintel/stores/dbstore), Test (enterprise/internal/codeintel/stores/lsifstore), Test (enterprise/internal/insights), Test (internal/database), Test (internal/repos), Test (enterprise/internal/batches), Test (cmd/frontend), Test (enterprise/internal/database), Test (enterprise/cmd/frontend/internal/batches/resolvers), Build - **DB backcompat tests**: Backcompat test (all), Backcompat test (enterprise/internal/codeintel/stores/dbstore), Backcompat test (enterprise/internal/codeintel/stores/lsifstore), Backcompat test (enterprise/internal/insights), Backcompat test (internal/database), Backcompat test (internal/repos), Backcompat test (enterprise/internal/batches), Backcompat test (cmd/frontend), Backcompat test (enterprise/internal/database), Backcompat test (enterprise/cmd/frontend/internal/batches/resolvers) - **CI script tests**: test-trace-command.sh diff --git a/doc/dev/background-information/web/web_app.md b/doc/dev/background-information/web/web_app.md index 0ece1c9cd03e..06d99876ffc0 100644 --- a/doc/dev/background-information/web/web_app.md +++ b/doc/dev/background-information/web/web_app.md @@ -131,7 +131,7 @@ If you don't do this (and just use a normal `import`), it will still work, but i ## Formatting We use [Prettier](https://github.com/prettier/prettier) so you never have to worry about how to format your code. -`yarn run prettier` will check & autoformat all code. +`yarn run format` will check & autoformat all code. ## Tests diff --git a/doc/dev/contributing/frontend_contribution.md b/doc/dev/contributing/frontend_contribution.md index 3cdfa292c366..e78052e89610 100644 --- a/doc/dev/contributing/frontend_contribution.md +++ b/doc/dev/contributing/frontend_contribution.md @@ -27,10 +27,10 @@ To work on most frontend issues, it is necessary to run three applications local 2. Linters. ```sh - yarn all:eslint - yarn prettier-check - yarn all:stylelint - yarn graphql-lint + yarn lint:js:all + yarn lint:css:all + yarn lint:graphql + yarn format:check ``` 3. Unit tests diff --git a/enterprise/dev/ci/internal/ci/operations.go b/enterprise/dev/ci/internal/ci/operations.go index f27bf60097d2..fbc94521133a 100644 --- a/enterprise/dev/ci/internal/ci/operations.go +++ b/enterprise/dev/ci/internal/ci/operations.go @@ -22,8 +22,9 @@ import ( // e.g. by adding flags, and not as a condition for adding steps or commands. type CoreTestOperationsOptions struct { // for clientChromaticTests - ChromaticShouldAutoAccept bool - MinimumUpgradeableVersion string + ChromaticShouldAutoAccept bool + MinimumUpgradeableVersion string + ClientLintOnlyChangedFiles bool } // CoreTestOperations is a core set of tests that should be run in most CI cases. More @@ -65,14 +66,23 @@ func CoreTestOperations(diff changed.Diff, opts CoreTestOperationsOptions) *oper if diff.Has(changed.Client | changed.GraphQL) { // If there are any Graphql changes, they are impacting the client as well. - ops.Merge(operations.NewNamedSet("Client checks", + clientChecks := operations.NewNamedSet("Client checks", clientIntegrationTests, clientChromaticTests(opts.ChromaticShouldAutoAccept), frontendTests, // ~4.5m addWebApp, // ~5.5m addBrowserExtensionUnitTests, // ~4.5m addVSCExt, // ~5.5m - addClientLinters)) // ~9m + addTypescriptCheck, // ~4m + ) + + if opts.ClientLintOnlyChangedFiles { + clientChecks.Append(addClientLintersForChangedFiles) + } else { + clientChecks.Append(addClientLintersForAllFiles) + } + + ops.Merge(clientChecks) } if diff.Has(changed.Go | changed.GraphQL) { @@ -143,14 +153,14 @@ func addCheck(pipeline *bk.Pipeline) { func addPrettier(pipeline *bk.Pipeline) { pipeline.AddStep(":lipstick: Prettier", withYarnCache(), - bk.Cmd("dev/ci/yarn-run.sh prettier-check")) + bk.Cmd("dev/ci/yarn-run.sh format:check")) } // yarn ~41s + ~1s func addGraphQLLint(pipeline *bk.Pipeline) { pipeline.AddStep(":lipstick: :graphql: GraphQL lint", withYarnCache(), - bk.Cmd("dev/ci/yarn-run.sh graphql-lint")) + bk.Cmd("dev/ci/yarn-run.sh lint:graphql")) } func addSVGLint(pipeline *bk.Pipeline) { @@ -163,22 +173,33 @@ func addYarnDeduplicateLint(pipeline *bk.Pipeline) { bk.Cmd("dev/check/yarn-deduplicate.sh")) } -// Adds client linters and Typescript check. -func addClientLinters(pipeline *bk.Pipeline) { - // - ESLint ~9m - pipeline.AddStep(":eslint: ESLint", - withYarnCache(), - bk.Cmd("dev/ci/yarn-run.sh all:eslint")) - - // - build-ts ~4m +// Adds Typescript check. +func addTypescriptCheck(pipeline *bk.Pipeline) { pipeline.AddStep(":typescript: Build TS", withYarnCache(), bk.Cmd("dev/ci/yarn-run.sh build-ts")) +} + +// Adds client linters to check all files. +func addClientLintersForAllFiles(pipeline *bk.Pipeline) { + pipeline.AddStep(":eslint: ESLint (all)", + withYarnCache(), + bk.Cmd("dev/ci/yarn-run.sh lint:js:all")) + + pipeline.AddStep(":stylelint: Stylelint (all)", + withYarnCache(), + bk.Cmd("dev/ci/yarn-run.sh lint:css:all")) +} + +// Adds client linters to check changed in PR files. +func addClientLintersForChangedFiles(pipeline *bk.Pipeline) { + pipeline.AddStep(":eslint: ESLint (changed)", + withYarnCache(), + bk.Cmd("dev/ci/yarn-run.sh lint:js:changed")) - // - Stylelint ~2m - pipeline.AddStep(":stylelint: Stylelint", + pipeline.AddStep(":stylelint: Stylelint (changed)", withYarnCache(), - bk.Cmd("dev/ci/yarn-run.sh all:stylelint")) + bk.Cmd("dev/ci/yarn-run.sh lint:css:changed")) } // Adds steps for the OSS and Enterprise web app builds. Runs the web app tests. diff --git a/enterprise/dev/ci/internal/ci/pipeline.go b/enterprise/dev/ci/internal/ci/pipeline.go index 2b70521b9090..d4c11bf8a76a 100644 --- a/enterprise/dev/ci/internal/ci/pipeline.go +++ b/enterprise/dev/ci/internal/ci/pipeline.go @@ -99,7 +99,10 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { ops.Append(prPreview()) } } - ops.Merge(CoreTestOperations(c.Diff, CoreTestOperationsOptions{MinimumUpgradeableVersion: minimumUpgradeableVersion})) + ops.Merge(CoreTestOperations(c.Diff, CoreTestOperationsOptions{ + MinimumUpgradeableVersion: minimumUpgradeableVersion, + ClientLintOnlyChangedFiles: c.RunType.Is(runtype.PullRequest), + })) case runtype.ReleaseNightly: ops.Append(triggerReleaseBranchHealthchecks(minimumUpgradeableVersion)) @@ -120,7 +123,7 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { // If this is a browser extension release branch, run the browser-extension tests and // builds. ops = operations.NewSet( - addClientLinters, + addClientLintersForAllFiles, addBrowserExtensionUnitTests, addBrowserExtensionIntegrationTests(0), // we pass 0 here as we don't have other pipeline steps to contribute to the resulting Percy build frontendTests, @@ -131,7 +134,7 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { // If this is a browser extension nightly build, run the browser-extension tests and // e2e tests. ops = operations.NewSet( - addClientLinters, + addClientLintersForAllFiles, addBrowserExtensionUnitTests, addBrowserExtensionIntegrationTests(0), // we pass 0 here as we don't have other pipeline steps to contribute to the resulting Percy build frontendTests, diff --git a/package.json b/package.json index f68a607d76b7..522953913fa7 100644 --- a/package.json +++ b/package.json @@ -11,21 +11,25 @@ "yarn": "^1.22.4" }, "scripts": { - "prettier": "prettier '**/{*.{js?(on),ts?(x),graphql,md,scss},.*.js?(on)}' --write --list-different --config prettier.config.js", - "prettier-check": "yarn -s run prettier --write=false --check --list-different=false --loglevel=warn", - "all:eslint": "DOCSITE_LIST=\"$(./dev/docsite.sh -config doc/docsite.json ls)\" dev/foreach-ts-project.sh yarn -s run eslint --quiet", - "all:stylelint": "yarn --cwd client/web run stylelint && yarn --cwd client/shared run stylelint && yarn --cwd client/branded run stylelint && yarn --cwd client/browser run stylelint && yarn --cwd client/wildcard run stylelint", + "format": "prettier '**/{*.{js?(on),ts?(x),graphql,md,scss},.*.js?(on)}' --write --list-different --config prettier.config.js", + "format:check": "yarn -s run format --write=false --check --list-different=false --loglevel=warn", + "_lint:js": "DOCSITE_LIST=\"$(./dev/docsite.sh -config doc/docsite.json ls)\" NODE_OPTIONS=\"--max_old_space_size=16192\" eslint", + "lint:js:changed": "yarn _lint:js $(git diff --diff-filter=d --name-only main | grep -E '.[tj]sx?$' | xargs)", + "lint:js:all": "DOCSITE_LIST=\"$(./dev/docsite.sh -config doc/docsite.json ls)\" dev/foreach-ts-project.sh yarn -s run lint:js --quiet", + "_lint:css": "stylelint", + "lint:css:changed": "yarn _lint:css $(git diff --diff-filter=d --name-only main | grep -E '.s?css$' | xargs)", + "lint:css:all": "yarn _lint:css 'client/*/src/**/*.scss'", + "lint:graphql": "graphql-schema-linter", "build-ts": "tsc -b tsconfig.all.json", - "graphql-lint": "graphql-schema-linter", "build-web": "yarn workspace @sourcegraph/web run build", "watch-web": "yarn workspace @sourcegraph/web run watch", "generate": "gulp generate", "watch-generate": "gulp watchGenerate", "test": "jest --testPathIgnorePatterns end-to-end regression integration storybook /out/.*test.js", - "test-integration:base": "TS_NODE_PROJECT=client/web/src/integration/tsconfig.json mocha --parallel=$CI --retries=1 --jobs=2", - "test-integration": "yarn test-integration:base \"./client/web/src/integration/**/*.test.ts\"", + "_test-integration": "TS_NODE_PROJECT=client/web/src/integration/tsconfig.json mocha --parallel=$CI --retries=1 --jobs=2", + "test-integration": "yarn _test-integration\"./client/web/src/integration/**/*.test.ts\"", "test-browser-integration": "yarn workspace @sourcegraph/browser run test-integration", - "cover-integration:base": "nyc --hook-require=false yarn test-integration:base", + "_cover-integration": "nyc --hook-require=false yarn _test-integration", "cover-integration": "nyc --hook-require=false yarn test-integration", "cover-browser-integration": "nyc --hook-require=false yarn workspace @sourcegraph/browser test-integration", "test-lighthouse": "SOURCEGRAPH_API_URL=https://sourcegraph.com lhci collect && lhci open",