Skip to content

Commit

Permalink
Merge branch 'develop' into webkit-video
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig authored Sep 6, 2022
2 parents 45e9b8f + a51e340 commit edff645
Show file tree
Hide file tree
Showing 34 changed files with 1,015 additions and 174 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Add issue/PR to project
name: 'Triage: add issue/PR to project'

on:
issues:
types:
- opened
pull_request:
pull_request_target:
types:
- opened

Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/triage_add_to_routed_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Triage: route to team project board'
on:
issues:
types:
- labeled
jobs:
route-to-e2e:
if: github.event.label.name == 'routed-to-e2e'
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
ORGANIZATION: 'cypress-io'
PROJECT_NUMBER: 10
run: |
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectV2(number: $number) {
id
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq -r '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
- name: add issue to e2e project
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
gh api graphql -f query='
mutation($project:ID!, $issue:ID!) {
addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) {
item {
id
}
}
}' -f project=$PROJECT_ID -f issue=$ISSUE_ID
93 changes: 93 additions & 0 deletions .github/workflows/triage_closed_issue_comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: 'Triage: closed issue comment'
on:
issue_comment:
types:
- created
jobs:
move-to-new-issue-status:
if: |
!github.event.issue.pull_request &&
github.event.issue.state == 'closed' &&
github.event.comment.created_at != github.event.issue.closed_at &&
github.event.sender.login != 'cypress-bot'
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
ORGANIZATION: 'cypress-io'
REPOSITORY: 'cypress'
PROJECT_NUMBER: 9
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
gh api graphql -f query='
query($org: String!, $repo: String!, $project: Int!, $issue: Int!) {
organization(login: $org) {
repository(name: $repo) {
issue(number: $issue) {
projectItems(first: 10, includeArchived: false) {
nodes {
id
fieldValueByName(name: "Status") {
... on ProjectV2ItemFieldSingleSelectValue {
name
field {
... on ProjectV2SingleSelectField {
project {
... on ProjectV2 {
id
number
}
}
}
}
}
}
}
}
}
}
projectV2(number: $project) {
field(name: "Status") {
... on ProjectV2SingleSelectField {
id
options {
id
name
}
}
}
}
}
}' -f org=$ORGANIZATION -f repo=$REPOSITORY -F issue=$ISSUE_NUMBER -F project=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq -r '.data.organization.repository.issue.projectItems.nodes[].fieldValueByName.field.project | select(.number == ${{ env.PROJECT_NUMBER }}) | .id' project_data.json) >> $GITHUB_ENV
echo 'PROJECT_ITEM_ID='$(jq -r '.data.organization.repository.issue.projectItems.nodes[] | select(.fieldValueByName.field.project.number == ${{ env.PROJECT_NUMBER }}) | .id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq -r '.data.organization.projectV2.field | .id' project_data.json) >> $GITHUB_ENV
echo 'STATUS='$(jq -r '.data.organization.repository.issue.projectItems.nodes[].fieldValueByName | select(.field.project.number == ${{ env.PROJECT_NUMBER }}) | .name' project_data.json) >> $GITHUB_ENV
echo 'NEW_ISSUE_OPTION_ID='$(jq -r '.data.organization.projectV2.field.options[] | select(.name== "New Issue") | .id' project_data.json) >> $GITHUB_ENV
- name: Move issue to New Issue status
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
if: env.STATUS == 'Closed'
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$status_field: ID!
$status_value: String!
) {
updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: {
singleSelectOptionId: $status_value
}
}) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$PROJECT_ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=$NEW_ISSUE_OPTION_ID
114 changes: 114 additions & 0 deletions .github/workflows/triage_issue_metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: 'Triage: issue metrics'

on:
workflow_dispatch:
inputs:
startDate:
description: 'Start date (YYYY-MM-DD)'
type: date
endDate:
description: 'End date (YYYY-MM-DD)'
type: date
jobs:
seven-day-close:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
env:
ORGANIZATION: 'cypress-io'
REPOSITORY: 'cypress'
PROJECT_NUMBER: 9
with:
github-token: ${{ secrets.ADD_TO_PROJECT_TOKEN }}
script: |
const ROUTED_TO_LABELS = ['routed-to-e2e', 'routed-to-ct']
const MS_PER_DAY = 1000 * 60 * 60 * 24
const { REPOSITORY, ORGANIZATION, PROJECT_NUMBER } = process.env
const issues = []
const determineDateRange = () => {
const inputStartDate = '${{ inputs.startDate }}'
const inputEndDate = '${{ inputs.endDate }}'
if (inputStartDate && inputEndDate) {
return { startDate: inputStartDate, endDate: inputEndDate }
}
if (inputStartDate || inputEndDate) {
core.setFailed('Both startDate and endDate are required if one is provided.')
}
const startDate = new Date()
startDate.setDate(startDate.getDate() - 6)
return { startDate: startDate.toISOString().split('T')[0], endDate: (new Date()).toISOString().split('T')[0] }
}
const dateRange = determineDateRange()
const query = `is:issue+repo:${ORGANIZATION}/${REPOSITORY}+project:${ORGANIZATION}/${PROJECT_NUMBER}+created:${dateRange.startDate}..${dateRange.endDate}`
const findLabelDateTime = async (issueNumber) => {
const iterator = github.paginate.iterator(github.rest.issues.listEventsForTimeline, {
owner: ORGANIZATION,
repo: REPOSITORY,
issue_number: issueNumber,
})
for await (const { data: timelineData } of iterator) {
for (const timelineItem of timelineData) {
if (timelineItem.event === 'labeled' && ROUTED_TO_LABELS.includes(timelineItem.label.name)) {
return timelineItem.created_at
}
}
}
}
const calculateElapsedDays = (createdAt, routedOrClosedAt) => {
return Math.round((new Date(routedOrClosedAt) - new Date(createdAt)) / MS_PER_DAY, 0)
}
const iterator = github.paginate.iterator(github.rest.search.issuesAndPullRequests, {
q: query,
per_page: 100,
})
for await (const { data } of iterator) {
for (const issue of data) {
let routedOrClosedAt
if (!issue.pull_request) {
const routedLabel = issue.labels.find((label) => ROUTED_TO_LABELS.includes(label.name))
if (routedLabel) {
routedOrClosedAt = await findLabelDateTime(issue.number)
} else if (issue.state === 'closed') {
routedOrClosedAt = issue.closed_at
}
let elapsedDays
if (routedOrClosedAt) {
elapsedDays = calculateElapsedDays(issue.created_at, routedOrClosedAt)
}
issues.push({
number: issue.number,
title: issue.title,
state: issue.state,
url: issue.html_url,
createdAt: issue.created_at,
routedOrClosedAt,
elapsedDays,
})
}
}
}
const issuesRoutedOrClosedIn7Days = issues.filter((issue) => issue.elapsedDays <= 7).length
const percentage = Number(issues.length > 0 ? issuesRoutedOrClosedIn7Days / issues.length : 0).toLocaleString(undefined, { style: 'percent', minimumFractionDigits: 2 })
console.log(`Triage Metrics (${dateRange.startDate} - ${dateRange.endDate})`)
console.log('Total issues:', issues.length)
console.log(`Issues routed/closed within 7 days: ${issuesRoutedOrClosedIn7Days} (${percentage})`)
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ windowsWorkflowFilters: &windows-workflow-filters
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ linux-arm64, << pipeline.git.branch >> ]
- equal: [ 'marktnoonan/windows-path-fix', << pipeline.git.branch >> ]
- equal: [ 'lmiller/fixing-flake-1', << pipeline.git.branch >> ]
- equal: [ 'skip-or-fix-flaky-tests-2', << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
Expand Down
4 changes: 2 additions & 2 deletions guides/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ In the following instructions, "X.Y.Z" is used to denote the [next version of Cy

3. If there is a new [`cypress-example-kitchensink`](https://github.com/cypress-io/cypress-example-kitchensink/releases) version, update the corresponding dependency in [`packages/example`](../packages/example) to that new version.

4. Once the `develop` branch is passing for all test projects with the new changes and the `linux-x64` binary is present at `https://cdn.cypress.io/beta/binary/X.Y.Z/linux-x64/<sha>/cypress.zip`, and the `linux-x64` cypress npm package is present at `https://cdn.cypress.io/beta/binary/X.Y.Z/linux-x64/<sha>/cypress.tgz`, publishing can proceed.
4. Once the `develop` branch is passing for all test projects with the new changes and the `linux-x64` binary is present at `https://cdn.cypress.io/beta/binary/X.Y.Z/linux-x64/develop-<sha>/cypress.zip`, and the `linux-x64` cypress npm package is present at `https://cdn.cypress.io/beta/npm/X.Y.Z/linux-x64/develop-<sha>/cypress.tgz`, publishing can proceed.

5. Install and test the pre-release version to make sure everything is working.
- Get the pre-release version that matches your system from the latest develop commit.
Expand Down Expand Up @@ -169,7 +169,7 @@ In the following instructions, "X.Y.Z" is used to denote the [next version of Cy
git pull origin develop
git log --pretty=oneline
# copy sha of the previous commit
git tag -a vX.Y.Z <sha>
git tag -a vX.Y.Z -m vX.Y.Z <sha>
git push origin vX.Y.Z
```

Expand Down
8 changes: 6 additions & 2 deletions npm/react18/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import type {
UnmountArgs,
} from '@cypress/react'

let root: any
let root: ReactDOM.Root | null

const cleanup = () => {
if (root) {
root.unmount()

root = null

return true
}

Expand All @@ -27,7 +29,9 @@ export function mount (jsx: React.ReactNode, options: MountOptions = {}, rerende
const internalOptions: InternalMountOptions = {
reactDom: ReactDOM,
render: (reactComponent: ReturnType<typeof React.createElement>, el: HTMLElement) => {
root = ReactDOM.createRoot(el)
if (!root) {
root = ReactDOM.createRoot(el)
}

return root.render(reactComponent)
},
Expand Down
12 changes: 6 additions & 6 deletions packages/app/cypress/e2e/runner/pluginEvents.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
import { getPathForPlatform } from '../../../src/paths'

describe('plugin events', () => {
it('supports "before:run" event', () => {
Expand All @@ -17,7 +17,7 @@ describe('plugin events', () => {
passCount: 1,
})

cy.readFile(path.join(projectRoot, 'beforeRun.json'))
cy.readFile(`${projectRoot}/beforeRun.json`)
.then((details) => {
expect(details).to.have.property('config')
expect(details).to.have.property('cypressVersion')
Expand All @@ -42,14 +42,14 @@ describe('plugin events', () => {
passCount: 1,
})

cy.readFile(path.join(projectRoot, 'beforeSpec.json'))
cy.readFile(`${projectRoot}/beforeSpec.json`)
.then((spec) => {
expect(spec).to.deep.contains({
baseName: 'run_events_spec_1.cy.js',
fileExtension: '.js',
fileName: 'run_events_spec_1',
name: 'run_events_spec_1.cy.js',
relative: 'cypress/e2e/run_events_spec_1.cy.js',
relative: getPathForPlatform('cypress/e2e/run_events_spec_1.cy.js'),
specFileExtension: '.cy.js',
specType: 'integration',
})
Expand All @@ -61,14 +61,14 @@ describe('plugin events', () => {
passCount: 1,
})

cy.readFile(path.join(projectRoot, 'beforeSpec.json'))
cy.readFile(`${projectRoot}/beforeSpec.json`)
.then((spec) => {
expect(spec).to.deep.contains({
baseName: 'run_events_spec_2.cy.js',
fileExtension: '.js',
fileName: 'run_events_spec_2',
name: 'run_events_spec_2.cy.js',
relative: 'cypress/e2e/run_events_spec_2.cy.js',
relative: getPathForPlatform('cypress/e2e/run_events_spec_2.cy.js'),
specFileExtension: '.cy.js',
specType: 'integration',
})
Expand Down
11 changes: 0 additions & 11 deletions packages/app/cypress/e2e/runner/runner.ui.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,5 @@ describe('src/cypress/runner', () => {
cy.get('.runnable-err-message').should('not.contain', 'ran afterEach even though specs were stopped')
cy.get('.runnable-err-message').should('contain', 'Cypress test was stopped while running this command.')
})

// TODO: blocked by UNIFY-1077
it.skip('supports disabling command log reporter with env var NO_COMMAND_LOG', () => {
loadSpec({
filePath: 'runner/disabled-command-log.runner.cy.js',
passCount: 0,
failCount: 0,
})

cy.get('.reporter').should('not.exist')
})
})
})
Loading

0 comments on commit edff645

Please sign in to comment.