Skip to content

Commit

Permalink
DEVPROD-5138: Merge Jest config (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad authored Apr 2, 2024
1 parent e6e8590 commit 23b0bea
Show file tree
Hide file tree
Showing 19 changed files with 187 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .evergreen/attach.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ functions:
command: attach.xunit_results
params:
files:
- "./ui/${app_dir}/bin/jest/*.xml"
- "./ui/bin/jest/*.xml"
4 changes: 2 additions & 2 deletions .evergreen/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ functions:
yarn-test:
command: shell.exec
params:
working_dir: ui/${app_dir}
working_dir: ui
script: |
${PREPARE_SHELL}
yarn test --ci --testPathIgnorePatterns=snapshot.test.ts
yarn test --ci --testPathIgnorePatterns=snapshot.test.ts --selectProjects ${build_variant}
yarn-tsc:
command: shell.exec
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules

# artifacts
bin
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# Evergreen UI

The new home of [Spruce](/apps/spruce) and [Parsley](/apps/parsley).

## Monorepo Tips & Tricks

Check out the [Yarn Workspaces documentation](https://classic.yarnpkg.com/lang/en/docs/workspaces/) for more.

### Upgrades

To upgrade a dependency across workspaces:

```bash
yarn upgrade-interactive [--latest] [package-name]
```

### Scripts

To run a script in a workspace from root:

```bash
yarn workspace [workspace-name] run [script-name]
```

For example, `yarn workspace spruce run storybook`.

### Testing

To run all unit tests across the repository, from root:
```bash
yarn test
```

To run a particular workspace's unit tests from root:
```bash
yarn test --selectProjects [workspace-name]
```
File renamed without changes.
34 changes: 11 additions & 23 deletions apps/parsley/jest.config.js → apps/parsley/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
module.exports = {
import type { Config } from "jest";

const config: Config = {
displayName: "parsley",
collectCoverageFrom: [
"src/**/*.{js,jsx,ts,tsx}",
"!<rootDir>/node_modules/",
"!<rootDir>/src/{main.tsx,vite-env.d.ts}",
],
coverageReporters: ["text"],
moduleFileExtensions: ["json", "js", "jsx", "ts", "tsx"],
moduleFileExtensions: ["tsx", "ts", "json", "js", "jsx"],
moduleNameMapper: {
"^uuid$": "<rootDir>/node_modules/uuid/dist/index.js",
},
modulePaths: ["<rootDir>/src"],
setupFiles: ["./jest.setup.ts"],
preset: "ts-jest",
setupFiles: ["./config/jest/jest.setup.ts"],
preset: "ts-jest/presets/js-with-ts",
resetMocks: true,
setupFilesAfterEnv: ["<rootDir>/config/jest/setupTests.ts"],
snapshotSerializers: ["@emotion/jest/serializer"],
testEnvironment: "jsdom",
testMatch: ["<rootDir>/{src,scripts}/**/*.{spec,test}.{js,jsx,ts,tsx}"],
testMatch: ["<rootDir>/{src,scripts}/**/*.{spec,test}.{ts,tsx}"],
transform: {
"^.+\\.[tj]sx?$": ["ts-jest", { isolatedModules: true }],
"^.+\\.graphql$": "@graphql-tools/jest-transform",
"^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": "ts-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)":
"<rootDir>/config/jest/svgTransform.js",
Expand All @@ -35,20 +37,6 @@ module.exports = {
"filter-obj",
].join("|")})`,
],
watchPlugins: [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname",
],

// Set the output directory for generating test results.
reporters: [
"default",
[
"jest-junit",
{
outputDirectory: "bin/jest",
outputName: "junit.xml",
},
],
],
};

export default config;
5 changes: 2 additions & 3 deletions apps/parsley/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"verify-backend": "./scripts/verify-backend.sh",
"storybook": "storybook dev -p 6006",
"storybook:build": "env-cmd -e local -r .env-cmdrc.local.json storybook build",
"test": "jest --watchAll=false",
"test:watch": "jest --watch --verbose",
"test": "yarn --cwd='../..' test --selectProjects parsley",
"postversion": "scripts/push-version.sh"
},
"dependencies": {
Expand Down Expand Up @@ -102,7 +101,7 @@
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "14.1.2",
"@testing-library/user-event": "14.5.1",
"@types/jest": "29.5.5",
"@types/jest": "29.5.12",
"@types/jest-specific-snapshot": "0.5.9",
"@types/js-cookie": "3.0.4",
"@types/lodash.debounce": "4.0.7",
Expand Down
11 changes: 6 additions & 5 deletions apps/parsley/scripts/deploy/utils/git/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { execSync } from "child_process";
import { resolve } from "path";

/**
* `getCommitMessages` returns a string of all commit messages between the currently deployed commit and HEAD.
Expand All @@ -8,7 +9,7 @@ import { execSync } from "child_process";
const getCommitMessages = (currentlyDeployedCommit: string) => {
const commitMessages = execSync(
`git log ${currentlyDeployedCommit}..HEAD --oneline -- .`,
{ encoding: "utf-8" }
{ encoding: "utf-8" },
).toString();
return commitMessages;
};
Expand All @@ -19,10 +20,10 @@ const getCommitMessages = (currentlyDeployedCommit: string) => {
* @returns - the currently deployed commit
*/
const getCurrentlyDeployedCommit = () => {
const currentlyDeployedCommit = execSync(
"bash scripts/deploy/get-current-deployed-commit.sh",
{ encoding: "utf-8" }
)
const filePath = resolve(__dirname, "../../get-current-deployed-commit.sh");
const currentlyDeployedCommit = execSync(`bash ${filePath}`, {
encoding: "utf-8",
})
.toString()
.trim();
return currentlyDeployedCommit;
Expand Down
44 changes: 39 additions & 5 deletions apps/parsley/src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ export type EditSpawnHostInput = {
publicKey?: InputMaybe<PublicKeyInput>;
savePublicKey?: InputMaybe<Scalars["Boolean"]["input"]>;
servicePassword?: InputMaybe<Scalars["String"]["input"]>;
sleepSchedule?: InputMaybe<SleepScheduleInput>;
volume?: InputMaybe<Scalars["String"]["input"]>;
};

Expand Down Expand Up @@ -707,6 +708,7 @@ export type Host = {
persistentDnsName: Scalars["String"]["output"];
provider: Scalars["String"]["output"];
runningTask?: Maybe<TaskInfo>;
sleepSchedule?: Maybe<SleepSchedule>;
startedBy: Scalars["String"]["output"];
status: Scalars["String"]["output"];
tag: Scalars["String"]["output"];
Expand Down Expand Up @@ -1268,6 +1270,7 @@ export type MutationSchedulePatchTasksArgs = {

export type MutationScheduleTasksArgs = {
taskIds: Array<Scalars["String"]["input"]>;
versionId?: InputMaybe<Scalars["String"]["input"]>;
};

export type MutationScheduleUndispatchedBaseTasksArgs = {
Expand Down Expand Up @@ -1420,10 +1423,12 @@ export type ParsleyFilterInput = {
/** ParsleySettings contains information about a user's settings for Parsley. */
export type ParsleySettings = {
__typename?: "ParsleySettings";
jumpToFailingLineEnabled: Scalars["Boolean"]["output"];
sectionsEnabled: Scalars["Boolean"]["output"];
};

export type ParsleySettingsInput = {
jumpToFailingLineEnabled?: InputMaybe<Scalars["Boolean"]["input"]>;
sectionsEnabled?: InputMaybe<Scalars["Boolean"]["input"]>;
};

Expand Down Expand Up @@ -1892,6 +1897,7 @@ export enum ProjectSettingsAccess {
export type ProjectSettingsInput = {
aliases?: InputMaybe<Array<ProjectAliasInput>>;
githubWebhooksEnabled?: InputMaybe<Scalars["Boolean"]["input"]>;
projectId?: InputMaybe<Scalars["String"]["input"]>;
projectRef?: InputMaybe<ProjectInput>;
subscriptions?: InputMaybe<Array<SubscriptionInput>>;
vars?: InputMaybe<ProjectVarsInput>;
Expand Down Expand Up @@ -2029,7 +2035,8 @@ export type QueryGithubProjectConflictsArgs = {
};

export type QueryHasVersionArgs = {
id: Scalars["String"]["input"];
id?: InputMaybe<Scalars["String"]["input"]>;
patchId?: InputMaybe<Scalars["String"]["input"]>;
};

export type QueryHostArgs = {
Expand Down Expand Up @@ -2065,7 +2072,8 @@ export type QueryMainlineCommitsArgs = {
};

export type QueryPatchArgs = {
id: Scalars["String"]["input"];
id?: InputMaybe<Scalars["String"]["input"]>;
patchId?: InputMaybe<Scalars["String"]["input"]>;
};

export type QueryPodArgs = {
Expand All @@ -2088,12 +2096,14 @@ export type QueryProjectSettingsArgs = {

export type QueryRepoEventsArgs = {
before?: InputMaybe<Scalars["Time"]["input"]>;
id: Scalars["String"]["input"];
id?: InputMaybe<Scalars["String"]["input"]>;
limit?: InputMaybe<Scalars["Int"]["input"]>;
repoId?: InputMaybe<Scalars["String"]["input"]>;
};

export type QueryRepoSettingsArgs = {
id: Scalars["String"]["input"];
id?: InputMaybe<Scalars["String"]["input"]>;
repoId?: InputMaybe<Scalars["String"]["input"]>;
};

export type QueryTaskArgs = {
Expand All @@ -2120,7 +2130,8 @@ export type QueryUserArgs = {
};

export type QueryVersionArgs = {
id: Scalars["String"]["input"];
id?: InputMaybe<Scalars["String"]["input"]>;
versionId?: InputMaybe<Scalars["String"]["input"]>;
};

export type RepoCommitQueueParams = {
Expand Down Expand Up @@ -2242,6 +2253,7 @@ export type RepoSettingsInput = {
aliases?: InputMaybe<Array<ProjectAliasInput>>;
githubWebhooksEnabled?: InputMaybe<Scalars["Boolean"]["input"]>;
projectRef?: InputMaybe<RepoRefInput>;
repoId?: InputMaybe<Scalars["String"]["input"]>;
subscriptions?: InputMaybe<Array<SubscriptionInput>>;
vars?: InputMaybe<ProjectVarsInput>;
};
Expand Down Expand Up @@ -2351,6 +2363,27 @@ export type SlackConfig = {
name?: Maybe<Scalars["String"]["output"]>;
};

export type SleepSchedule = {
__typename?: "SleepSchedule";
dailyStartTime: Scalars["String"]["output"];
dailyStopTime: Scalars["String"]["output"];
permanentlyExempt: Scalars["Boolean"]["output"];
shouldKeepOff: Scalars["Boolean"]["output"];
temporarilyExemptUntil?: Maybe<Scalars["Time"]["output"]>;
timeZone: Scalars["String"]["output"];
wholeWeekdaysOff: Array<Scalars["Int"]["output"]>;
};

export type SleepScheduleInput = {
dailyStartTime: Scalars["String"]["input"];
dailyStopTime: Scalars["String"]["input"];
permanentlyExempt: Scalars["Boolean"]["input"];
shouldKeepOff: Scalars["Boolean"]["input"];
temporarilyExemptUntil?: InputMaybe<Scalars["Time"]["input"]>;
timeZone: Scalars["String"]["input"];
wholeWeekdaysOff: Array<Scalars["Int"]["input"]>;
};

export enum SortDirection {
Asc = "ASC",
Desc = "DESC",
Expand Down Expand Up @@ -2390,6 +2423,7 @@ export type SpawnHostInput = {
region: Scalars["String"]["input"];
savePublicKey: Scalars["Boolean"]["input"];
setUpScript?: InputMaybe<Scalars["String"]["input"]>;
sleepSchedule?: InputMaybe<SleepScheduleInput>;
spawnHostsStartedByTask?: InputMaybe<Scalars["Boolean"]["input"]>;
taskId?: InputMaybe<Scalars["String"]["input"]>;
taskSync?: InputMaybe<Scalars["Boolean"]["input"]>;
Expand Down
File renamed without changes.
27 changes: 8 additions & 19 deletions apps/spruce/jest.config.js → apps/spruce/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module.exports = {
import type { Config } from "jest";

const config: Config = {
displayName: "spruce",
collectCoverageFrom: [
"src/**/*.{js,jsx,ts,tsx}",
"!<rootDir>/node_modules/",
"!<rootDir>/src/{index.tsx,react-app-env.d.ts}",
],
coverageReporters: ["text"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json"],
moduleNameMapper: {
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
Expand All @@ -16,7 +18,7 @@ module.exports = {
setupFilesAfterEnv: ["<rootDir>/config/jest/setupTests.ts"],
snapshotSerializers: ["@emotion/jest/serializer"],
testEnvironment: "jsdom",
testMatch: ["<rootDir>/{src,scripts}/**/*.{spec,test}.{js,jsx,ts,tsx}"],
testMatch: ["<rootDir>/{src,scripts}/**/*.{spec,test}.{ts,tsx}"],
transform: {
"^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": "babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
Expand All @@ -35,20 +37,7 @@ module.exports = {
"filter-obj",
].join("|")})`,
],
watchPlugins: [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname",
],
globalSetup: "<rootDir>/global-setup.js",
testTimeout: 30000,
reporters: [
"default",
[
"jest-junit",
{
outputDirectory: "bin/jest",
outputName: "junit.xml",
},
],
],
globalSetup: "<rootDir>/config/jest/global-setup.js",
};

export default config;
3 changes: 1 addition & 2 deletions apps/spruce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"staging": "env-cmd -e devStaging -r .env-cmdrc.local.json yarn start",
"start": "vite",
"storybook": "storybook dev -p 6006",
"test:watch": "node scripts/test.js --verbose",
"test": "node scripts/test.js --watchAll=false",
"test": "yarn --cwd='../..' test --selectProjects spruce",
"postversion": "scripts/push-version.sh"
},
"browserslist": {
Expand Down
3 changes: 2 additions & 1 deletion apps/spruce/scripts/deploy/utils/git/git.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { execSync } from "child_process";
import { getCurrentlyDeployedCommit } from ".";

const currentlyDeployedCommitRegex = /^[0-9a-f]{40}$/;
Expand All @@ -6,7 +7,7 @@ describe("getCurrentlyDeployedCommit", () => {
it("should return the currently deployed commit", () => {
const currentlyDeployedCommit = getCurrentlyDeployedCommit();
const currentlyDeployedCommitIsHash = currentlyDeployedCommitRegex.test(
currentlyDeployedCommit
currentlyDeployedCommit,
);
expect(currentlyDeployedCommitIsHash).toBeTruthy();
});
Expand Down
Loading

0 comments on commit 23b0bea

Please sign in to comment.