Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of https://github.com/evergreen-ci/spruce into DE…
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad committed Nov 28, 2023
2 parents b13fe47 + 9668376 commit 7a0478e
Show file tree
Hide file tree
Showing 47 changed files with 1,478 additions and 1,397 deletions.
58 changes: 36 additions & 22 deletions .evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ functions:
params:
working_dir: spruce/evergreen
command: make configure-mongod

- command: shell.exec
type: setup
params:
shell: bash
script: |
${PREPARE_SHELL}
cd $PROJECT_DIRECTORY
mkdir mongodb-tools && cd mongodb-tools
curl ${mongodb_tools_url} -o mongodb-tools.tgz
${decompress} mongodb-tools.tgz
mv ./mongodb-*/bin/* .
setup-node:
- command: subprocess.exec
params:
Expand Down Expand Up @@ -202,7 +212,7 @@ functions:
script: |
${PREPARE_SHELL}
yarn build-storybook
yarn-snapshot:
command: shell.exec
params:
Expand All @@ -229,8 +239,11 @@ functions:
script: |
${PREPARE_SHELL}
# Only record to cypress cloud if this is a pr, mainline commit or an intentional patch.
if [[ "${requester}" == "github_pr" || "${requester}" == "commit" || "${requester}" == "patch" ]]; then
# And only allow spec filtering for an intentional patch.
if [[ "${requester}" == "github_pr" || "${requester}" == "commit" ]]; then
yarn cy:run --record --key "${cypress_record_key}" --reporter junit
elif [[ "${requester}" == "patch" ]]; then
yarn cy:run --record --key "${cypress_record_key}" --reporter junit --spec ${cypress_spec}
else
yarn cy:run --reporter junit
fi
Expand All @@ -247,8 +260,7 @@ functions:
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
["spruce/cypress/screenshots/*"]
local_files_include_filter: ["spruce/cypress/screenshots/*"]
remote_file: spruce/${task_id}/
bucket: mciuploads
content_type: image/png
Expand All @@ -259,8 +271,7 @@ functions:
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
["spruce/cypress/videos/*"]
local_files_include_filter: ["spruce/cypress/videos/*"]
remote_file: spruce/${task_id}/
bucket: mciuploads
content_type: video/mp4
Expand Down Expand Up @@ -290,8 +301,7 @@ functions:
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
["spruce/storybook-static/*.html"]
local_files_include_filter: ["spruce/storybook-static/*.html"]
remote_file: spruce/${task_id}/storybook/
bucket: mciuploads
content_type: text/html
Expand All @@ -303,7 +313,10 @@ functions:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
["spruce/storybook-static/**/*.js$", "spruce/storybook-static/**/*.mjs$"]
[
"spruce/storybook-static/**/*.js$",
"spruce/storybook-static/**/*.mjs$",
]
remote_file: spruce/${task_id}/storybook/
bucket: mciuploads
content_type: application/javascript
Expand All @@ -314,8 +327,7 @@ functions:
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
["spruce/storybook-static/**/*.js.map"]
local_files_include_filter: ["spruce/storybook-static/**/*.js.map"]
remote_file: spruce/${task_id}/storybook/
bucket: mciuploads
content_type: application/json
Expand All @@ -326,8 +338,7 @@ functions:
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
["spruce/storybook-static/**/*.css"]
local_files_include_filter: ["spruce/storybook-static/**/*.css"]
remote_file: spruce/${task_id}/storybook/
bucket: mciuploads
content_type: text/css
Expand All @@ -338,8 +349,7 @@ functions:
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
["spruce/storybook-static/**/*.json"]
local_files_include_filter: ["spruce/storybook-static/**/*.json"]
remote_file: spruce/${task_id}/storybook/
bucket: mciuploads
content_type: application/json
Expand All @@ -358,7 +368,7 @@ functions:
content_type: font/woff2
permissions: public-read
preserve_path: true

attach-codegen-diff:
command: s3.put
type: system
Expand All @@ -371,7 +381,7 @@ functions:
bucket: mciuploads
content_type: text/plain
permissions: public-read

attach-email:
command: s3.put
type: system
Expand Down Expand Up @@ -411,7 +421,7 @@ functions:
EOF
echo "Done populating"
prod-deploy:
command: shell.exec
params:
Expand All @@ -427,8 +437,6 @@ functions:
AUTHOR_EMAIL=${author_email} \
yarn deploy:prod
#######################################
# Tasks #
#######################################
Expand Down Expand Up @@ -474,7 +482,7 @@ tasks:
- func: yarn-serve
- func: wait-for-evergreen
- func: run-cypress-tests

- name: check_codegen
commands:
- func: sym-link
Expand All @@ -493,6 +501,7 @@ buildvariants:
- ubuntu2204-large
expansions:
goroot: /opt/golang/go1.20
mongodb_tools_url: https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.8.0.tgz
mongodb_url_2204: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-7.0.2.tgz
mongosh_url_2204: https://downloads.mongodb.com/compass/mongosh-2.0.2-linux-x64.tgz
node_version: 16.17.0
Expand All @@ -512,3 +521,8 @@ buildvariants:
git_tag_only: true
patchable: false
priority: 100

parameters:
- key: cypress_spec
value: "cypress/integration/**/*"
description: Specify the Cypress spec files to run for user submitted patches running the e2e_test task.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Spruce is the React UI for MongoDB's continuous integration software.
### Running Locally

1. Clone the Spruce Github repository
2. Ensure you have Node.js 16+ installed
2. Ensure you have Node.js v16+ and MongoDB Command Line Database Tools
v100.8.0+ installed
3. Ask a colleague for their .cmdrc.json file and follow the instructions
[here](#environment-variables)
4. Run `yarn`
Expand Down Expand Up @@ -159,10 +160,13 @@ on localhost:9090 for the front-end to work.
In order to run the Cypress tests, do the following, assuming you have this repo
checked out and all the dependencies installed by yarn:

1. Start the evergreen back-end with the sample local test data. You can do this
1. Increase the limit on open files by running `ulimit -n 64000` before running
mongod in the same shell.
2. Start the evergreen back-end with the sample local test data. You can do this
by typing `make local-evergreen` in your evergreen folder.
2. Start the Spruce local server by typing `yarn build:local && yarn serve` in this repo.
3. Run Cypress by typing one of the following:
3. Start the Spruce local server by typing `yarn build:local && yarn serve` in
this repo.
4. Run Cypress by typing one of the following:
- `yarn cy:open` - opens the Cypress app in interactive mode. You can select
tests to run from here in the Cypress browser.
- `yarn cy:run` - runs all the Cypress tests at the command-line and reports
Expand Down Expand Up @@ -200,22 +204,26 @@ production environments.
switched to db mci
mci:SECONDARY> db.distro.find({_id: "archlinux-small"}) // the full query
```

5. Exit from the mongo shell and prepare to run `mongoexport`

```
mongoexport --db=mci --collection=distro --out=distro.json --query='{_id: "archlinux-small"}'
mongoexport --db=mci --collection=distro --out=distro.json --query='{_id: "archlinux-small"}'
2020-07-29T17:41:50.266+0000 connected to: localhost
2020-07-29T17:41:50.269+0000 exported 1 record
```

After running this command a file will be saved to your home directory with
the results of the `mongoexport`

_Note you may need to provide the full path to mongoexport on the staging db_

```
/var/lib/mongodb-mms-automation/mongodb-linux-x86_64-4.0.5/bin/mongoexport --db=mci --collection=distro --out=distro.json --query='{_id: "archlinux-small"}'
/var/lib/mongodb-mms-automation/mongodb-linux-x86_64-4.0.5/bin/mongoexport --db=mci --collection=distro --out=distro.json --query='{_id: "archlinux-small"}'
2020-07-29T17:41:50.266+0000 connected to: localhost
2020-07-29T17:41:50.269+0000 exported 1 record
```

6. Exit the ssh session using `exit` or `Ctrl + D`
7. You can now transfer this json file to your local system by running the
following command. `scp <db you sshed into>:~/distro.json .` This will save a
Expand All @@ -225,9 +233,8 @@ production environments.
from within the evergreen folder
9. Once you have this file you can copy the contents of it to the relevant
`testdata/local/<collection>.json` file with in the evergreen folder
10. You can then delete `/bin/.load-local-data` within the evergreen folder and
run `make local-evergreen` to repopulate the local database with your new
data.
10. You can then run `yarn evg-db-ops --reseed` to repopulate the local database
with your new data.

**Notes**

Expand Down Expand Up @@ -266,4 +273,5 @@ Run one of the following commands to deploy to the appropriate environment
3. `yarn deploy:beta` = deploy to https://spruce-beta.corp.mongodb.com (Beta
connects to the production backend)

In case of emergency (i.e. Evergreen, GitHub, or other systems are down), a production build can be pushed directly to S3 with `yarn deploy:prod --local`.
In case of emergency (i.e. Evergreen, GitHub, or other systems are down), a
production build can be pushed directly to S3 with `yarn deploy:prod --local`.
18 changes: 18 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { defineConfig } from "cypress";
import { execSync } from "child_process";

export default defineConfig({
e2e: {
retries: 3,
baseUrl: "http://localhost:3000",
projectId: "yshv48",
reporterOptions: {
Expand All @@ -11,5 +13,21 @@ export default defineConfig({
specPattern: "cypress/integration/**/*.ts",
viewportWidth: 1920,
viewportHeight: 1080,
setupNodeEvents(on) {
on("before:run", () => {
try {
execSync("yarn evg-db-ops --dump");
} catch (e) {
console.error(e);
}
});
on("after:run", () => {
try {
execSync("yarn evg-db-ops --clean-up");
} catch (e) {
console.error(e);
}
});
},
},
});
9 changes: 3 additions & 6 deletions cypress/integration/announcements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ import {
} from "constants/cookies";

describe("Announcement overlays", () => {
beforeEach(() => {
cy.clearCookie(CY_DISABLE_NEW_USER_WELCOME_MODAL);
cy.clearCookie(CY_DISABLE_COMMITS_WELCOME_MODAL);
cy.clearCookie("This is an important notification");
});

it("Displays a welcome modal only when you first visit spruce", () => {
cy.clearCookie(CY_DISABLE_NEW_USER_WELCOME_MODAL);
cy.visit("/");
cy.dataCy("welcome-modal").should("exist");
cy.dataCy("close-welcome-modal").click();
Expand All @@ -19,6 +14,7 @@ describe("Announcement overlays", () => {
});

it("Should not show a Sitewide banner after it has been dismissed", () => {
cy.clearCookie("This is an important notification");
cy.visit("/");
cy.dataCy("sitewide-banner-success").should("exist");
cy.closeBanner("sitewide-banner-success");
Expand All @@ -41,6 +37,7 @@ describe("Announcement overlays", () => {
});

it("visiting the commits page for the first time should show a welcome modal", () => {
cy.clearCookie(CY_DISABLE_COMMITS_WELCOME_MODAL);
cy.visit("/commits/spruce");
cy.dataCy("welcome-modal").should("be.visible");
cy.dataCy("close-welcome-modal").click();
Expand Down
22 changes: 10 additions & 12 deletions cypress/integration/commit_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,47 @@ const COMMIT_QUEUE_ROUTE_2 = `/commit-queue/${commitQueue.id2}`;
const INVALID_COMMIT_QUEUE_ROUTE = `/commit-queue/${commitQueue.id3}`;
const COMMIT_QUEUE_ROUTE_4 = `/commit-queue/${commitQueue.id4}`;

describe("commit queue page", { testIsolation: false }, () => {
describe("commit queue page", () => {
describe(COMMIT_QUEUE_ROUTE_1, () => {
before(() => {
beforeEach(() => {
cy.visit(COMMIT_QUEUE_ROUTE_1);
});

it("Should render the commit queue page with one card", () => {
cy.dataCy("commit-queue-card").should("have.length", 1);
});

it("Clicking on Total Code changes should toggle a drop down table", () => {
it("Clicking on 'Total code changes' should show the code changes table", () => {
cy.dataCy("code-changes-table").should("not.be.visible");
cy.dataCy("accordion-toggle").click();
cy.dataCy("code-changes-table").should("be.visible");
});

it("Clicking on remove a patch from the commit queue should work", () => {
it("Should be able to remove a patch from the commit queue", () => {
cy.dataCy("commit-queue-card").should("exist");
cy.dataCy("commit-queue-patch-button").should("exist");
cy.dataCy("commit-queue-patch-button").click();
cy.dataCy("commit-queue-confirmation-modal").should("be.visible");
cy.dataCy("commit-queue-confirmation-modal").within(() => {
cy.contains("Remove").click();
cy.contains("button", "Remove").click();
});
cy.dataCy("commit-queue-confirmation-modal").should("not.exist");
cy.dataCy("commit-queue-card").should("not.exist");
});
});

describe(COMMIT_QUEUE_ROUTE_2, () => {
before(() => {
cy.visit(COMMIT_QUEUE_ROUTE_2);
});
it("visiting a page with multiple sets of code changes should have multiple tables", () => {
cy.visit(COMMIT_QUEUE_ROUTE_2);
cy.dataCy("accordion-toggle").should("have.length", 4);
});
});

describe(COMMIT_QUEUE_ROUTE_4, () => {
before(() => {
beforeEach(() => {
cy.visit(COMMIT_QUEUE_ROUTE_4);
});

it("should display the commit queue message if there is one", () => {
cy.dataCy("commit-queue-message").should("exist");
cy.dataCy("commit-queue-message").should(
Expand All @@ -75,10 +75,8 @@ describe("commit queue page", { testIsolation: false }, () => {
});

describe(INVALID_COMMIT_QUEUE_ROUTE, () => {
before(() => {
it("visiting a nonexistent commit queue page should display an error", () => {
cy.visit(INVALID_COMMIT_QUEUE_ROUTE);
});
it("visiting a non existent commit queue page should display an error", () => {
cy.validateToast("error", "There was an error loading the commit queue");
});
});
Expand Down
Loading

0 comments on commit 7a0478e

Please sign in to comment.