Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CSR-3] Handle cypress crashes, faster reporting #137

Merged
merged 32 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e521048
feat: use ws to send spec results asap
agoldis May 30, 2023
685fc28
chore: rename cancellation
agoldis May 30, 2023
904b3e4
chore: use execution state
agoldis May 30, 2023
4a3da39
feat: report specs early via spec:before
agoldis Jun 1, 2023
1455637
chore: remove unused code
agoldis Jun 1, 2023
eac06a4
fix: report results for cypress crashes
agoldis Jun 1, 2023
4162bb2
chore: store config in executionState
agoldis Jun 1, 2023
feef33b
chore: add @types/ws
agoldis Jun 1, 2023
ab891a9
chore: fix tests
agoldis Jun 1, 2023
cab6abe
chore: prevent timeouts and double-reporting
agoldis Jun 1, 2023
8768dc2
chore: terminate http on shutdown
agoldis Jun 1, 2023
3fe9cef
chore: add debug messages
agoldis Jun 1, 2023
cc0019f
chore: use ESM friendly imports for ws
agoldis Jun 1, 2023
f783b8a
chore: release v1.8.0-beta.0
agoldis Jun 1, 2023
a289767
chore: use lil-http-terminator
agoldis Jun 2, 2023
39f2f20
chore: release v1.8.0-beta.1
agoldis Jun 2, 2023
f281119
chore: handle exceptions and edge cases
agoldis Jun 2, 2023
bc6f3e9
chore: mute tests
agoldis Jun 4, 2023
24b563f
chore: release v1.8.0-beta.2
agoldis Jun 5, 2023
2e8c6e2
fix: support --headed mode
agoldis Jun 12, 2023
ae23d0d
Merge branch 'feat/support-headed' into feat/faster-reporting
agoldis Jun 12, 2023
1a504f2
chore: release v1.8.0-beta.3
agoldis Jun 12, 2023
1d17d13
fix: support ESM packages (#144)
agoldis Jun 13, 2023
4c109b5
Merge branch 'feat/faster-reporting' of https://github.com/currents-d…
agoldis Jun 13, 2023
8619dcb
chore: release v1.8.0-beta.5
agoldis Jun 13, 2023
474471b
fix: merge default and fs config
agoldis Jun 21, 2023
4c11896
chore: [email protected]
agoldis Jun 21, 2023
4bb0bcf
chore: temp enable windows ci
agoldis Jun 21, 2023
9253db0
chore: test esm on windows
agoldis Jun 21, 2023
709d477
chore: use urls to load config files
agoldis Jun 21, 2023
92fc0d6
chore: restore example [skip ci]
agoldis Jun 21, 2023
6d4a49b
chore: release v1.8.0-beta.6
agoldis Jun 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Install the package:
npm install cypress-cloud
```

- Create a new configuration file: `currents.config.js` in the Cypress project’s root
- Create a new configuration file: `currents.config.js|mjs|cjs` in the Cypress project’s root (Using ESM project? See the guide below).
- Set the `projectId` and the record key obtained from [Currents](https://app.currents.dev) or your self-hosted instance of Sorry Cypress:

```js
Expand Down Expand Up @@ -88,9 +88,15 @@ module.exports = {
};
```

`cypress-cloud` will search for `currents.config.js` at the project's root location (defined with `-P --project` CLI option).
`cypress-cloud` will search for a configuration file at the project's root location (defined with `-P --project` CLI option) in the following order:

Override the default configuration values via environment variables:
- `currents.config.js`
- `currents.config.cjs`
- `currents.config.mjs`

The configuration file will be read using [`import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) expression. Please make sure to use the correct syntax if you're using ESM modules (see the guide below).

You can override the configuration values via environment variables:

- `CURRENTS_API_URL` - sorry-cypress users - set the URL of your director service
- `CURRENTS_PROJECT_ID` - set the `projectId`
Expand All @@ -100,7 +106,7 @@ The configuration variables will resolve as follows:

- the corresponding CLI flag or `run` function parameter, otherwise
- environment variable if exist, otherwise
- `currents.config.js` value, otherwise
- `currents.config.js|cjs|mjs` value, otherwise
- the default value, otherwise throw

## Batched Orchestration
Expand Down Expand Up @@ -179,6 +185,16 @@ As an alternative, you can activate the `cloudPlugin` first, and then implement

Enable the debug mode to troubleshoot files discovery: `DEBUG=currents:specs npx cypress-cloud ...`

### Usage with ESM project

For ESM projects (`"type": "module"` in `package.json`) you can use one of the following formats:

- `currents.config.cjs` - CommonJS formatted file
- `currents.config.js` - ESM formatted file (i.e. no `require` statements)
- `currents.config.mjs` - ESM formatted file (i.e. no `require` statements)

Also, make sure that your `cypress.config.js|mjs|cjs|ts` is formatted accordingly. See examples at [`./e2e`](./e2e) directory.

## Troubleshooting

Enable the debug mode and run the command:
Expand Down Expand Up @@ -230,8 +246,6 @@ Using:
npm install cypress-cloud --registry http://localhost:4873
```



## Disclaimer

This software is not affilicated with Cypress.io Inc. All third party trademarks and materials (including logos, icons and labels) referenced herein are the property of their respective owners. The third party products or services that this software connects to are subject to their respective owners, please refer to their intellectual property and terms of service agreements.
50 changes: 50 additions & 0 deletions .github/workflows/e2e-config-esm-cjs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: e2e-config-esm-cjs

on:
push:

jobs:
e2e-config-esm-cjs:
if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]')"
runs-on: ubuntu-latest
env:
DEBUG: currents:*

services:
director:
image: agoldis/sorry-cypress-director
ports:
- 1234:1234

strategy:
matrix:
node-version: ["18"]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Link monorepo packages
run: npm install

- name: config-esm-cjs
working-directory: ./e2e/config-esm-cjs
env:
CURRENTS_API_URL: http://localhost:1234
run: >
npx cypress-cloud run
--record
--parallel
--key some-key
--browser chrome
--tag smoke,linux
--spec "./cypress/e2e/*.spec.js"
--ci-build-id "${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}}"
50 changes: 50 additions & 0 deletions .github/workflows/e2e-config-esm-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: e2e-config-esm-js

on:
push:

jobs:
e2e-config-esm-js:
if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]')"
runs-on: ubuntu-latest
env:
DEBUG: currents:*

services:
director:
image: agoldis/sorry-cypress-director
ports:
- 1234:1234

strategy:
matrix:
node-version: ["18"]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Link monorepo packages
run: npm install

- name: config-esm-js
working-directory: ./e2e/config-esm-js
env:
CURRENTS_API_URL: http://localhost:1234
run: >
npx cypress-cloud run
--record
--parallel
--key some-key
--browser chrome
--tag smoke,linux
--spec "./cypress/e2e/*.spec.js"
--ci-build-id "${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}}"
50 changes: 50 additions & 0 deletions .github/workflows/e2e-config-esm-mjs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: e2e-config-esm-mjs

on:
push:

jobs:
e2e-config-esm-mjs:
if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]')"
runs-on: ubuntu-latest
env:
DEBUG: currents:*

services:
director:
image: agoldis/sorry-cypress-director
ports:
- 1234:1234

strategy:
matrix:
node-version: ["18"]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Link monorepo packages
run: npm install

- name: config-esm-mjs
working-directory: ./e2e/config-esm-mjs
env:
CURRENTS_API_URL: http://localhost:1234
run: >
npx cypress-cloud run
--record
--parallel
--key some-key
--browser chrome
--tag smoke,linux
--spec "./cypress/e2e/*.spec.js"
--ci-build-id "${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}}"
50 changes: 50 additions & 0 deletions .github/workflows/e2e-config-noesm-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: e2e-config-noesm-js

on:
push:

jobs:
e2e-config-noesm-js:
if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]')"
runs-on: ubuntu-latest
env:
DEBUG: currents:*

services:
director:
image: agoldis/sorry-cypress-director
ports:
- 1234:1234

strategy:
matrix:
node-version: ["18"]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Link monorepo packages
run: npm install

- name: config-noesm-js
working-directory: ./e2e/config-noesm-js
env:
CURRENTS_API_URL: http://localhost:1234
run: >
npx cypress-cloud run
--record
--parallel
--key some-key
--browser chrome
--tag smoke,linux
--spec "./cypress/e2e/*.spec.js"
--ci-build-id "${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}}"
14 changes: 13 additions & 1 deletion .github/workflows/e2e-smoke-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: e2e-smoke-windows

on:
push:
branches: [main]
# branches: [main]

jobs:
build:
Expand All @@ -27,6 +27,18 @@ jobs:
- name: Link monorepo packages
run: npm install

- name: Test ESM imports
working-directory: ./e2e/config-esm-js
run: >
npx cypress-cloud run
--record
--parallel
--key ${{ secrets.CURRENTS_RECORD_KEY }}
--browser chrome
--tag smoke,linux
--spec "./cypress/e2e/*.spec.js"
--ci-build-id "config-esm-js-${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}}"

- name: Run Cypress with cypress-cloud
working-directory: ./examples/webapp
run: |
Expand Down
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@


# [1.8.0-beta.6](https://github.com/currents-dev/cypress-cloud/compare/v1.8.0-beta.5...v1.8.0-beta.6) (2023-06-21)


### Bug Fixes

* merge default and fs config ([474471b](https://github.com/currents-dev/cypress-cloud/commit/474471bfefb4caa030f570b873b942f6b7addf4f))

# [1.8.0-beta.5](https://github.com/currents-dev/cypress-cloud/compare/v1.8.0-beta.3...v1.8.0-beta.5) (2023-06-13)


### Bug Fixes

* support ESM packages ([#144](https://github.com/currents-dev/cypress-cloud/issues/144)) ([1d17d13](https://github.com/currents-dev/cypress-cloud/commit/1d17d13c9df2d7a63b23b9cb9ce8c9667efabcd4))

# [1.8.0-beta.4](https://github.com/currents-dev/cypress-cloud/compare/v1.8.0-beta.3...v1.8.0-beta.4) (2023-06-13)


### Bug Fixes

* support ESM packages ([#144](https://github.com/currents-dev/cypress-cloud/issues/144)) ([1d17d13](https://github.com/currents-dev/cypress-cloud/commit/1d17d13c9df2d7a63b23b9cb9ce8c9667efabcd4))

# [1.8.0-beta.3](https://github.com/currents-dev/cypress-cloud/compare/v1.8.0-beta.2...v1.8.0-beta.3) (2023-06-12)


### Bug Fixes

* support --headed mode ([2e8c6e2](https://github.com/currents-dev/cypress-cloud/commit/2e8c6e27675321e30273df4bf9a50d2af686ba59))

# [1.8.0-beta.2](https://github.com/currents-dev/cypress-cloud/compare/v1.8.0-beta.1...v1.8.0-beta.2) (2023-06-05)

# [1.8.0-beta.1](https://github.com/currents-dev/cypress-cloud/compare/v1.8.0-beta.0...v1.8.0-beta.1) (2023-06-02)

# [1.8.0-beta.0](https://github.com/currents-dev/cypress-cloud/compare/v1.7.4...v1.8.0-beta.0) (2023-06-01)


### Bug Fixes

* report results for cypress crashes ([eac06a4](https://github.com/currents-dev/cypress-cloud/commit/eac06a44a2669cf499e799171383040e500c88a4))


### Features

* report specs early via spec:before ([4a3da39](https://github.com/currents-dev/cypress-cloud/commit/4a3da396940ae4e32ce09c5cb5cca1782ed443e7))
* use ws to send spec results asap ([e521048](https://github.com/currents-dev/cypress-cloud/commit/e5210483e0893fd361901fa5d1364f9b12b98b68))

## [1.7.4](https://github.com/currents-dev/cypress-cloud/compare/v1.7.3...v1.7.4) (2023-04-28)


Expand Down
12 changes: 12 additions & 0 deletions e2e/config-esm-cjs/currents.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
e2e: {
batchSize: 3, // how many specs to send in one batch
},
component: {
batchSize: 5, // how many specs to send in one batch
},
projectId: !!(process.env.GITHUB_ACTION || process.env.CIRCLE_BRANCH)
? "Ij0RfK"
: "1OPP8c",
// cloudServiceUrl: "http://localhost:1234",
};
29 changes: 29 additions & 0 deletions e2e/config-esm-cjs/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import grepPlugin from "@cypress/grep/src/plugin";
import { defineConfig } from "cypress";
import currents from "cypress-cloud/plugin";
import terminalPlugin from "cypress-terminal-report/src/installLogsPrinter";

export default defineConfig({
e2e: {
baseUrl: "https://todomvc.com/examples/vanillajs",
videoUploadOnPasses: false,
supportFile: "cypress/support/e2e.js",
specPattern: "cypress/*/**/*.spec.js",
setupNodeEvents(on, config) {
grepPlugin(config);
terminalPlugin(on);
return currents(on, config);
},
},

component: {
specPattern: ["pages/__tests__/*.spec.tsx"],
setupNodeEvents(on, config) {
return currents(on, config);
},
devServer: {
framework: "next",
bundler: "webpack",
},
},
});
10 changes: 10 additions & 0 deletions e2e/config-esm-cjs/cypress/e2e/smoke.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// type definitions for Cypress object "cy"
/// <reference types="cypress" />

describe("TodoMVC", function () {
// a very simple example helpful during presentations
it("adds 2 todos", function () {
cy.get(".new-todo").type("learn testing{enter}").type("be cool{enter}");
cy.get(".todo-list li").should("have.length", 2);
});
});
Loading