Skip to content

Commit

Permalink
Merge branch 'develop' into retry-flake
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Dec 19, 2022
2 parents b84b45f + 470b94b commit 08dcded
Show file tree
Hide file tree
Showing 206 changed files with 14,614 additions and 15,821 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/update-browser-versions.yml
Expand Up @@ -108,12 +108,13 @@ jobs:
uses: actions/github-script@v4
with:
script: |
const { createPullRequest } = require('./scripts/github-actions/update-browser-versions.js')
const { createPullRequest } = require('./scripts/github-actions/create-pull-request.js')
await createPullRequest({
context,
github,
baseBranch: '${{ env.BASE_BRANCH }}',
branchName: '${{ steps.check-branch.outputs.branch_name }}',
description: '${{ steps.get-versions.outputs.description }}',
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
})
135 changes: 131 additions & 4 deletions .github/workflows/update_v8_snapshot_cache.yml
@@ -1,10 +1,137 @@
name: Update V8 Snapshot Cache
on: [workflow_dispatch]
on:
schedule:
# Run every Wednesday at 00:00 UTC
- cron: '0 0 * * 3'
push:
branches:
- ryanm/feature/v8-snapshots-auto-pr
- develop
- 'release/**'
workflow_dispatch:
inputs:
branch:
description: 'Branch to update'
required: true
default: 'develop'
generate_from_scratch:
description: 'Generate from scratch'
type: boolean
default: false
commit_directly_to_branch:
description: 'Commit directly to branch'
type: boolean
default: false
concurrency:
group: ${{ github.ref }}
group: ${{ inputs.branch || github.ref }}
cancel-in-progress: true
jobs:
update-v8-snapshot-cache:
strategy:
max-parallel: 1
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.platform }}
env:
CYPRESS_BOT_APP_ID: ${{ secrets.CYPRESS_BOT_APP_ID }}
BASE_BRANCH: ${{ inputs.branch || github.ref_name }}
GENERATE_FROM_SCRATCH: ${{ inputs.generate_from_scratch == true || github.event_name == 'schedule' }}
steps:
- name: Dummy step
run: echo "Dummy step"
- name: Determine snapshot files - Windows
if: ${{ matrix.platform == 'windows-latest' }}
run: echo "SNAPSHOT_FILES='tooling\v8-snapshot\cache\win32\snapshot-meta.json'" >> $GITHUB_ENV
shell: bash
- name: Determine snapshot files - Linux
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: echo "SNAPSHOT_FILES='tooling/v8-snapshot/cache/linux/snapshot-meta.json'" >> $GITHUB_ENV
- name: Determine snapshot files - Mac
if: ${{ matrix.platform == 'macos-latest' }}
run: echo "SNAPSHOT_FILES='tooling/v8-snapshot/cache/darwin/snapshot-meta.json'" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ env.BASE_BRANCH }}
- name: Set committer info
## attribute the commit to cypress-bot: https://github.community/t/logging-into-git-as-a-github-app/115916
run: |
git config --local user.email "${{ env.CYPRESS_BOT_APP_ID }}+cypress-bot[bot]@users.noreply.github.com"
git config --local user.name "cypress-bot[bot]"
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'yarn'
- name: Run yarn
run: yarn
- name: Run build
run: yarn build
- name: Generate prod snapshot from scratch
if: ${{ env.GENERATE_FROM_SCRATCH == 'true' }}
run: yarn cross-env V8_SNAPSHOT_FROM_SCRATCH=1 V8_UPDATE_METAFILE=1 yarn build-v8-snapshot-prod
- name: Generate prod snapshot iteratively
if: ${{ env.GENERATE_FROM_SCRATCH != 'true' }}
run: yarn cross-env V8_UPDATE_METAFILE=1 yarn build-v8-snapshot-prod
- name: Check for v8 snapshot cache changes
id: check-for-v8-snapshot-cache-changes
run: |
echo "has_changes=$(test "$(git status --porcelain -- ${{ env.SNAPSHOT_FILES }})" && echo 'true')" >> $GITHUB_OUTPUT
shell: bash
- name: Determine branch name - commit directly to branch
if: ${{ inputs.commit_directly_to_branch == true }}
run: |
echo "BRANCH_NAME=${{ env.BASE_BRANCH }}" >> $GITHUB_ENV
echo "BRANCH_EXISTS=true" >> $GITHUB_ENV
shell: bash
- name: Determine branch name - commit to separate branch
if: ${{ inputs.commit_directly_to_branch != true }}
run: |
echo "BRANCH_NAME=update-v8-snapshot-cache-on-${{ env.BASE_BRANCH }}" >> $GITHUB_ENV
echo "BRANCH_EXISTS=$(git show-ref --verify --quiet refs/remotes/origin/update-v8-snapshot-cache-on-${{ env.BASE_BRANCH }} && echo 'true')" >> $GITHUB_ENV
shell: bash
- name: Check need for PR or branch update
id: check-need-for-pr
run: |
echo "needs_pr=${{ steps.check-for-v8-snapshot-cache-changes.outputs.has_changes == 'true' && env.BRANCH_EXISTS != 'true' }}" >> $GITHUB_OUTPUT
echo "needs_branch_update=${{ steps.check-for-v8-snapshot-cache-changes.outputs.has_changes == 'true' && env.BRANCH_EXISTS == 'true' }}" >> $GITHUB_OUTPUT
shell: bash
## Update available and a branch/PR already exists
- name: Checkout existing branch
if: ${{ steps.check-need-for-pr.outputs.needs_branch_update == 'true' }}
run: |
git stash push -- ${{ env.SNAPSHOT_FILES }}
git reset --hard
git checkout ${{ env.BRANCH_NAME }}
git pull origin ${{ env.BRANCH_NAME }}
git merge --squash -Xtheirs stash
## Update available and a PR doesn't already exist
- name: Checkout new branch
if: ${{ steps.check-need-for-pr.outputs.needs_pr == 'true' }}
run: git checkout -b ${{ env.BRANCH_NAME }} ${{ env.BASE_BRANCH }}
## Commit changes if present
- name: Commit the changes
if: ${{ steps.check-for-v8-snapshot-cache-changes.outputs.has_changes == 'true' }}
run: |
git diff-index --quiet HEAD || git commit -am "chore: updating v8 snapshot cache"
## Push branch
- name: Push branch to remote
if: ${{ steps.check-for-v8-snapshot-cache-changes.outputs.has_changes == 'true' }}
run: git push origin ${{ env.BRANCH_NAME }}
# PR needs to be created
- name: Create Pull Request
if: ${{ steps.check-need-for-pr.outputs.needs_pr == 'true' }}
uses: actions/github-script@v4
with:
script: |
const { createPullRequest } = require('./scripts/github-actions/create-pull-request.js')
await createPullRequest({
context,
github,
baseBranch: '${{ env.BASE_BRANCH }}',
branchName: '${{ env.BRANCH_NAME }}',
description: 'Update v8 snapshot cache',
body: 'This PR was automatically generated by the [update-v8-snapshot-cache](https://github.com/cypress-io/cypress/actions/workflows/update_v8_snapshot_cache.yml) github action.',
reviewers: ['ryanthemanuel']
})
8 changes: 8 additions & 0 deletions .gitignore
Expand Up @@ -389,3 +389,11 @@ globbed_node_modules
# Snapshot Binaries
snapshot_blob.bin
v8_context_snapshot.x86_64.bin

# Legacy snapshot cache files
tooling/v8-snapshot/cache/dev-darwin
tooling/v8-snapshot/cache/dev-linux
tooling/v8-snapshot/cache/dev-win32
tooling/v8-snapshot/cache/prod-darwin
tooling/v8-snapshot/cache/prod-linux
tooling/v8-snapshot/cache/prod-win32
26 changes: 2 additions & 24 deletions CONTRIBUTING.md
Expand Up @@ -435,17 +435,9 @@ During the process of snapshot generation, metadata is created/updated in `tooli

**Generation**

If you run into errors while generating the v8 snapshot, you can occasionally identify the problem dependency via the output. You can try to remove that dependency from the cache and see if regenerating succeeds. If it does, likely it was moved to a more restrictive section (e.g. healthy to deferred/no-rewrite or deferred to norewrite). If all else fails, you can try running the following (but keep in mind this may take a while):
If the `build-v8-snapshot-prod` command is taking a long time to run on Circle CI, the snapshot cache probably needs to be updated. Run the [Update V8 Snapshot Cache](https://github.com/cypress-io/cypress/actions/workflows/update_v8_snapshot_cache.yml) github action against your branch to generate the snapshots for you on all platforms. You can choose to commit directly to your branch or alternatively issue a PR to your branch.

```
V8_SNAPSHOT_FROM_SCRATCH=1 yarn build-v8-snapshot-dev
```

or

```
V8_SNAPSHOT_FROM_SCRATCH=1 yarn build-v8-snapshot-prod
```
![Update V8 SnapshotCache](https://user-images.githubusercontent.com/4873279/206541239-1afb1d29-4d66-4593-92a7-5a5961a12137.png)

**Runtime**

Expand All @@ -456,20 +448,6 @@ If you're experiencing issues during runtime, you can try and narrow down where
* If the problem occurs with both `yarn build-v8-snapshot-prod` and `yarn build-v8-snapshot-dev` but does not occur when using the `DISABLE_SNAPSHOT_REQUIRE` environment variable, then that means there's a problem with a node module dependency. Chances are that a file is not being flagged properly (e.g. healthy when it should be deferred or norewrite).
* If the problem still occurs when using the `DISABLE_SNAPSHOT_REQUIRE` environment variable, then that means the problem is not snapshot related.

**Build Length**

If the `build-v8-snapshot-prod` command is taking a long time to run on Circle CI, the snapshot cache probably needs to be updated. Run these commands on a windows, linux, and mac and commit the updates to the snapshot cache to git:

```
yarn build-v8-snapshot-dev
```

or

```
yarn build-v8-snapshot-prod
```

## Committing Code

### Branches
Expand Down
12 changes: 6 additions & 6 deletions cli/types/cypress.d.ts
Expand Up @@ -1589,19 +1589,19 @@ declare namespace Cypress {
*
* @see https://on.cypress.io/nextuntil
*/
nextUntil<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
nextUntil<K extends keyof HTMLElementTagNameMap>(selector: K, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/nextuntil
*/
nextUntil<E extends HTMLElement = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
nextUntil<E extends Node = HTMLElement>(selector: string, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/nextuntil
*/
nextUntil<E extends HTMLElement = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
nextUntil<E extends Node = HTMLElement>(element: E | JQuery<E>, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>

/**
* Filter DOM element(s) from a set of DOM elements. Opposite of `.filter()`
Expand Down Expand Up @@ -1774,21 +1774,21 @@ declare namespace Cypress {
* Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
* > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery.
*
* @see https://on.cypress.io/prevall
* @see https://on.cypress.io/prevuntil
*/
prevUntil<K extends keyof HTMLElementTagNameMap>(selector: K, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
* > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery.
*
* @see https://on.cypress.io/prevall
* @see https://on.cypress.io/prevuntil
*/
prevUntil<E extends Node = HTMLElement>(selector: string, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
* > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery.
*
* @see https://on.cypress.io/prevall
* @see https://on.cypress.io/prevuntil
*/
prevUntil<E extends Node = HTMLElement>(element: E | JQuery<E>, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>

Expand Down
26 changes: 26 additions & 0 deletions cli/types/tests/cypress-tests.ts
Expand Up @@ -1136,3 +1136,29 @@ namespace CypressLocalStorageTests {
cy.clearAllSessionStorage({ log: false })
cy.clearAllSessionStorage({ log: 'true' }) // $ExpectError
}

namespace CypressTraversalTests {
cy.wrap({}).prevUntil('a') // $ExpectType Chainable<JQuery<HTMLAnchorElement>>
cy.wrap({}).prevUntil('#myItem') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).prevUntil('span', 'a') // $ExpectType Chainable<JQuery<HTMLSpanElement>>
cy.wrap({}).prevUntil('#myItem', 'a') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).prevUntil('div', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLDivElement>>
cy.wrap({}).prevUntil('#myItem', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).prevUntil('#myItem', 'a', { log: 'true' }) // $ExpectError

cy.wrap({}).nextUntil('a') // $ExpectType Chainable<JQuery<HTMLAnchorElement>>
cy.wrap({}).nextUntil('#myItem') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).nextUntil('span', 'a') // $ExpectType Chainable<JQuery<HTMLSpanElement>>
cy.wrap({}).nextUntil('#myItem', 'a') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).nextUntil('div', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLDivElement>>
cy.wrap({}).nextUntil('#myItem', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).nextUntil('#myItem', 'a', { log: 'true' }) // $ExpectError

cy.wrap({}).parentsUntil('a') // $ExpectType Chainable<JQuery<HTMLAnchorElement>>
cy.wrap({}).parentsUntil('#myItem') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).parentsUntil('span', 'a') // $ExpectType Chainable<JQuery<HTMLSpanElement>>
cy.wrap({}).parentsUntil('#myItem', 'a') // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).parentsUntil('div', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLDivElement>>
cy.wrap({}).parentsUntil('#myItem', 'a', { log: false, timeout: 100 }) // $ExpectType Chainable<JQuery<HTMLElement>>
cy.wrap({}).parentsUntil('#myItem', 'a', { log: 'true' }) // $ExpectError
}
7 changes: 7 additions & 0 deletions npm/grep/CHANGELOG.md
@@ -1,3 +1,10 @@
# [@cypress/grep-v3.1.3](https://github.com/cypress-io/cypress/compare/@cypress/grep-v3.1.2...@cypress/grep-v3.1.3) (2022-12-14)


### Bug Fixes

* **grep:** @cypress/grep types ([#24844](https://github.com/cypress-io/cypress/issues/24844)) ([55058e7](https://github.com/cypress-io/cypress/commit/55058e7783420d0946bd19eeb72a08ccf3f3a86e))

# [@cypress/grep-v3.1.2](https://github.com/cypress-io/cypress/compare/@cypress/grep-v3.1.1...@cypress/grep-v3.1.2) (2022-12-09)


Expand Down
20 changes: 15 additions & 5 deletions npm/grep/README.md
Expand Up @@ -79,7 +79,7 @@ yarn add -D @cypress/grep

### Support file

**required:** load this module from the [support file](https://on.cypress.io/writing-and-organizing-tests#Support-file) or at the top of the spec file if not using the support file. You improve the registration function and then call it:
**required:** load this module from the [support file](https://on.cypress.io/writing-and-organizing-tests#Support-file) or at the top of the spec file if not using the support file. You import the registration function and then call it:

```js
// cypress/support/index.js
Expand All @@ -89,6 +89,16 @@ const registerCypressGrep = require('@cypress/grep')
registerCypressGrep()

// if you want to use the "import" keyword
// note: `./index.d.ts` currently extends the global Cypress types and
// does not define `registerCypressGrep` so the import path is directly
// pointed to the `support.js` file
import registerCypressGrep from '@cypress/grep/src/support'
registerCypressGrep()


// "import" with `@ts-ignore`
// @see error 2306 https://github.com/microsoft/TypeScript/blob/3fcd1b51a1e6b16d007b368229af03455c7d5794/src/compiler/diagnosticMessages.json#L1635
// @ts-ignore
import registerCypressGrep from '@cypress/grep'
registerCypressGrep()
```
Expand Down Expand Up @@ -207,7 +217,7 @@ $ npx cypress run --env grep="-hello world"
$ npx cypress run --env grep="hello; -world"
```

**Note:** Inverted title filter is not compativle with the `grepFilterSpecs` option
**Note:** Inverted title filter is not compatible with the `grepFilterSpecs` option

## Filter with tags

Expand Down Expand Up @@ -277,7 +287,7 @@ If you want to run all tests with tag `@slow` but without tag `@smoke`:
--env grepTags=@slow+-@smoke
```

**Note:** Inverted tag filter is not compativle with the `grepFilterSpecs` option
**Note:** Inverted tag filter is not compatible with the `grepFilterSpecs` option

### NOT tags

Expand Down Expand Up @@ -417,7 +427,7 @@ This package comes with [src/index.d.ts](./src/index.d.ts) definition file that

```js
// cypress/integration/my-spec.js
/// <reference types="cypress-grep" />
/// <reference types="@cypress/grep" />
```

If you have `tsconfig.json` file, add this library to the types list
Expand All @@ -427,7 +437,7 @@ If you have `tsconfig.json` file, add this library to the types list
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "cypress-grep"]
"types": ["cypress", "@cypress/grep"]
},
"include": ["**/*.ts"]
}
Expand Down
2 changes: 1 addition & 1 deletion npm/grep/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "@cypress/grep",
"version": "0.0.0-development",
"description": "Filter tests using substring",
"main": "src/support",
"main": "src/support.js",
"scripts": {
"cy:run": "node ../../scripts/cypress.js run --config specPattern='**/unit.js'",
"cy:open": "node ../../scripts/cypress.js open --e2e -b electron --config specPattern='**/unit.js'"
Expand Down
13 changes: 12 additions & 1 deletion npm/grep/src/index.d.ts
@@ -1,6 +1,17 @@
/// <reference types="cypress" />

declare namespace Cypress {
interface SuiteConfigOverrides {
/**
* List of tags for this suite
* @example a single tag
* describe('block with config tag', { tags: '@smoke' }, () => {})
* @example multiple tags
* describe('block with config tag', { tags: ['@smoke', '@slow'] }, () => {})
*/
tags?: string | string[]
}

// specify additional properties in the TestConfig object
// in our case we will add "tags" property
interface TestConfigOverrides {
Expand All @@ -17,4 +28,4 @@ declare namespace Cypress {
interface Cypress {
grep?: (grep?: string, tags?: string, burn?: string) => void
}
}
}

5 comments on commit 08dcded

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 08dcded Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/linux-arm64/retry-flake-08dcdedccb030a555584f4b50b087678c6055da9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 08dcded Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/linux-x64/retry-flake-08dcdedccb030a555584f4b50b087678c6055da9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 08dcded Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/darwin-arm64/retry-flake-08dcdedccb030a555584f4b50b087678c6055da9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 08dcded Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/darwin-x64/retry-flake-08dcdedccb030a555584f4b50b087678c6055da9/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 08dcded Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/win32-x64/retry-flake-08dcdedccb030a555584f4b50b087678c6055da9/cypress.tgz

Please sign in to comment.