mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-05 22:19:46 -06:00
feat: set up auto prs for snapshot metafile changes (#25052)
Co-authored-by: cypress-bot[bot] <2f0651858c6e38e0+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Ryan Manuel <ryanm@cypress.io> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { consolidateDeps } = require('@tooling/v8-snapshot')
|
||||
const { consolidateDeps, getSnapshotCacheDir } = require('@tooling/v8-snapshot')
|
||||
const del = require('del')
|
||||
const esbuild = require('esbuild')
|
||||
const snapshotMetadata = require('@tooling/v8-snapshot/cache/prod-darwin/snapshot-meta.cache.json')
|
||||
const tempDir = require('temp-dir')
|
||||
const workingDir = path.join(tempDir, 'binary-cleanup-workdir')
|
||||
|
||||
@@ -158,6 +157,7 @@ const buildEntryPointAndCleanup = async (buildAppDir) => {
|
||||
])
|
||||
|
||||
// 3. Gather the dependencies that could potentially be removed from the binary due to being in the snapshot or in the entry point bundle
|
||||
const snapshotMetadata = require(path.join(getSnapshotCacheDir(), 'snapshot-meta.json'))
|
||||
const potentiallyRemovedDependencies = [
|
||||
...snapshotMetadata.healthy,
|
||||
...snapshotMetadata.deferred,
|
||||
|
||||
24
scripts/github-actions/create-pull-request.js
Normal file
24
scripts/github-actions/create-pull-request.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const createPullRequest = async ({ context, github, baseBranch, branchName, description, body, reviewers }) => {
|
||||
const { data: { number } } = await github.pulls.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
base: baseBranch,
|
||||
head: branchName,
|
||||
title: `chore: ${description}`,
|
||||
body,
|
||||
maintainer_can_modify: true,
|
||||
})
|
||||
|
||||
if (reviewers) {
|
||||
await github.pulls.requestReviewers({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: number,
|
||||
reviewers,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createPullRequest,
|
||||
}
|
||||
@@ -110,22 +110,9 @@ const updatePRTitle = async ({ context, github, baseBranch, branchName, descript
|
||||
})
|
||||
}
|
||||
|
||||
const createPullRequest = async ({ context, github, baseBranch, branchName, description }) => {
|
||||
await github.pulls.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
base: baseBranch,
|
||||
head: branchName,
|
||||
title: `chore: ${description}`,
|
||||
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
|
||||
maintainer_can_modify: true,
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getVersions,
|
||||
checkNeedForBranchUpdate,
|
||||
updateBrowserVersionsFile,
|
||||
updatePRTitle,
|
||||
createPullRequest,
|
||||
}
|
||||
|
||||
86
scripts/unit/github-actions/create-pull-request-spec.js
Normal file
86
scripts/unit/github-actions/create-pull-request-spec.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const { expect } = require('chai')
|
||||
const {
|
||||
createPullRequest,
|
||||
} = require('../../github-actions/create-pull-request')
|
||||
const sinon = require('sinon')
|
||||
|
||||
describe('pull requests', () => {
|
||||
context('.createPullRequest', () => {
|
||||
it('creates pull request with correct properties', async () => {
|
||||
const github = {
|
||||
pulls: {
|
||||
create: sinon.stub().returns(Promise.resolve({ data: { number: 123 } })),
|
||||
},
|
||||
}
|
||||
|
||||
const context = {
|
||||
repo: {
|
||||
owner: 'cypress-io',
|
||||
repo: 'cypress',
|
||||
},
|
||||
}
|
||||
|
||||
await createPullRequest({
|
||||
context,
|
||||
github,
|
||||
baseBranch: 'develop',
|
||||
branchName: 'some-branch-name',
|
||||
description: 'Update Chrome',
|
||||
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
|
||||
})
|
||||
|
||||
expect(github.pulls.create).to.be.calledWith({
|
||||
owner: 'cypress-io',
|
||||
repo: 'cypress',
|
||||
base: 'develop',
|
||||
head: 'some-branch-name',
|
||||
title: 'chore: Update Chrome',
|
||||
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
|
||||
maintainer_can_modify: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('creates pull request with correct properties including reviewers', async () => {
|
||||
const github = {
|
||||
pulls: {
|
||||
create: sinon.stub().returns(Promise.resolve({ data: { number: 123 } })),
|
||||
requestReviewers: sinon.stub().returns(Promise.resolve()),
|
||||
},
|
||||
}
|
||||
|
||||
const context = {
|
||||
repo: {
|
||||
owner: 'cypress-io',
|
||||
repo: 'cypress',
|
||||
},
|
||||
}
|
||||
|
||||
await createPullRequest({
|
||||
context,
|
||||
github,
|
||||
baseBranch: 'develop',
|
||||
branchName: 'some-branch-name',
|
||||
description: 'Update Chrome',
|
||||
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
|
||||
reviewers: ['ryanthemanuel'],
|
||||
})
|
||||
|
||||
expect(github.pulls.create).to.be.calledWith({
|
||||
owner: 'cypress-io',
|
||||
repo: 'cypress',
|
||||
base: 'develop',
|
||||
head: 'some-branch-name',
|
||||
title: 'chore: Update Chrome',
|
||||
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
|
||||
maintainer_can_modify: true,
|
||||
})
|
||||
|
||||
expect(github.pulls.requestReviewers).to.be.calledWith({
|
||||
owner: 'cypress-io',
|
||||
repo: 'cypress',
|
||||
pull_number: 123,
|
||||
reviewers: ['ryanthemanuel'],
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -13,7 +13,6 @@ const {
|
||||
checkNeedForBranchUpdate,
|
||||
updateBrowserVersionsFile,
|
||||
updatePRTitle,
|
||||
createPullRequest,
|
||||
} = require('../../github-actions/update-browser-versions')
|
||||
|
||||
const coreStub = () => {
|
||||
@@ -355,39 +354,4 @@ describe('update browser version github action', () => {
|
||||
expect(console.log).to.be.calledWith('Could not find PR for branch:', 'some-branch-name')
|
||||
})
|
||||
})
|
||||
|
||||
context('.createPullRequest', () => {
|
||||
it('creates pull request with correct properties', async () => {
|
||||
const github = {
|
||||
pulls: {
|
||||
create: sinon.stub().returns(Promise.resolve()),
|
||||
},
|
||||
}
|
||||
|
||||
const context = {
|
||||
repo: {
|
||||
owner: 'cypress-io',
|
||||
repo: 'cypress',
|
||||
},
|
||||
}
|
||||
|
||||
await createPullRequest({
|
||||
context,
|
||||
github,
|
||||
baseBranch: 'develop',
|
||||
branchName: 'some-branch-name',
|
||||
description: 'Update Chrome',
|
||||
})
|
||||
|
||||
expect(github.pulls.create).to.be.calledWith({
|
||||
owner: 'cypress-io',
|
||||
repo: 'cypress',
|
||||
base: 'develop',
|
||||
head: 'some-branch-name',
|
||||
title: 'chore: Update Chrome',
|
||||
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
|
||||
maintainer_can_modify: true,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user